Fixed crashes when loading character models (hopefully)
This commit is contained in:
parent
9d330665f3
commit
50e83549ee
@ -8,7 +8,7 @@ namespace irr
|
|||||||
namespace scene
|
namespace scene
|
||||||
{
|
{
|
||||||
|
|
||||||
CM2MeshFileLoader::CM2MeshFileLoader(IrrlichtDevice* device, c8* basedir):Device(device), Basedir(basedir)
|
CM2MeshFileLoader::CM2MeshFileLoader(IrrlichtDevice* device, c8* texdir):Device(device), Texdir(texdir)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -248,9 +248,10 @@ IMB->recalculateBoundingBox();
|
|||||||
//IMB->getMaterial().DiffuseColor.set(255,(M2MSubmeshes[i].meshpartId==0?0:255),(M2MSubmeshes[i].meshpartId==0?255:0),0);
|
//IMB->getMaterial().DiffuseColor.set(255,(M2MSubmeshes[i].meshpartId==0?0:255),(M2MSubmeshes[i].meshpartId==0?255:0),0);
|
||||||
|
|
||||||
|
|
||||||
std::string TexName=Basedir.c_str();
|
std::string TexName=Texdir.c_str();
|
||||||
TexName+="/";
|
TexName+="/";
|
||||||
TexName+=M2MTextureFiles[M2MTextureUnit[i].textureIndex].c_str();
|
if(i<M2MTextureUnit.size())
|
||||||
|
TexName+=M2MTextureFiles[M2MTextureUnit[i].textureIndex].c_str();
|
||||||
|
|
||||||
while(TexName.find('\\')<TexName.size())//Replace \ by /
|
while(TexName.find('\\')<TexName.size())//Replace \ by /
|
||||||
{
|
{
|
||||||
@ -263,10 +264,13 @@ while(TexName.find(' ')<TexName.size())//Replace space by _
|
|||||||
std::transform(TexName.begin(), TexName.end(), TexName.begin(), tolower);
|
std::transform(TexName.begin(), TexName.end(), TexName.begin(), tolower);
|
||||||
|
|
||||||
IMB->getMaterial().setTexture(0,Device->getVideoDriver()->getTexture(TexName.c_str()));
|
IMB->getMaterial().setTexture(0,Device->getVideoDriver()->getTexture(TexName.c_str()));
|
||||||
std::cout<<M2MRenderFlags[i].flags<<"--"<<M2MRenderFlags[i].blending<<"\n";
|
if(i<M2MRenderFlags.size())
|
||||||
IMB->getMaterial().BackfaceCulling=(M2MRenderFlags[i].flags & 0x04)?false:true;
|
{
|
||||||
if(M2MRenderFlags[i].blending==1)
|
std::cout<<M2MRenderFlags[i].flags<<"--"<<M2MRenderFlags[i].blending<<"\n";
|
||||||
IMB->getMaterial().MaterialType=video::EMT_TRANSPARENT_ALPHA_CHANNEL;
|
IMB->getMaterial().BackfaceCulling=(M2MRenderFlags[i].flags & 0x04)?false:true;
|
||||||
|
if(M2MRenderFlags[i].blending==1)
|
||||||
|
IMB->getMaterial().MaterialType=video::EMT_TRANSPARENT_ALPHA_CHANNEL;
|
||||||
|
}
|
||||||
Mesh->addMeshBuffer(IMB);
|
Mesh->addMeshBuffer(IMB);
|
||||||
IMB->drop();
|
IMB->drop();
|
||||||
//std::cout << "Mesh now has "<<Mesh->getMeshBufferCount()<<" Buffers\n";
|
//std::cout << "Mesh now has "<<Mesh->getMeshBufferCount()<<" Buffers\n";
|
||||||
|
|||||||
@ -105,7 +105,7 @@ class CM2MeshFileLoader : public IMeshLoader
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
CM2MeshFileLoader(IrrlichtDevice* device, c8* basedir);
|
CM2MeshFileLoader(IrrlichtDevice* device, c8* texdir);
|
||||||
|
|
||||||
//! destructor
|
//! destructor
|
||||||
virtual ~CM2MeshFileLoader();
|
virtual ~CM2MeshFileLoader();
|
||||||
@ -175,7 +175,7 @@ struct RenderFlags{
|
|||||||
IrrlichtDevice* Device;
|
IrrlichtDevice* Device;
|
||||||
// scene::IMeshManipulator* Manipulator;
|
// scene::IMeshManipulator* Manipulator;
|
||||||
core::stringc M2MeshName;
|
core::stringc M2MeshName;
|
||||||
core::stringc Basedir;
|
core::stringc Texdir;
|
||||||
SAnimatedMesh* aniMesh;
|
SAnimatedMesh* aniMesh;
|
||||||
SMesh* Mesh;
|
SMesh* Mesh;
|
||||||
SMeshBuffer* IMB;
|
SMeshBuffer* IMB;
|
||||||
|
|||||||
@ -121,7 +121,7 @@ void PseuGUI::_Init(void)
|
|||||||
//...
|
//...
|
||||||
|
|
||||||
// register external loaders for not supported filetypes
|
// register external loaders for not supported filetypes
|
||||||
scene::CM2MeshFileLoader* m2loader = new scene::CM2MeshFileLoader(_device, "data");
|
scene::CM2MeshFileLoader* m2loader = new scene::CM2MeshFileLoader(_device, "./data/textures");
|
||||||
_smgr->addExternalMeshLoader(m2loader);
|
_smgr->addExternalMeshLoader(m2loader);
|
||||||
|
|
||||||
_initialized = true;
|
_initialized = true;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user