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