My game has been blocked
I have base Class
Code: Select all
class gameModel
{
protected:
u32 id;
IrrlichtDevice* device;
IAnimatedMesh* mesh;
IAnimatedMeshSceneNode* node;
public:
gameModel(IrrlichtDevice *device);
bool LoadModel(string s_mesh, core::vector3df obj_pos, core::vector3df obj_rotate, core::vector3df obj_scale);
void setCollisionObject(IAnimatedMeshSceneNode* object);
// some code ...
};
/***********************************************************/
// i load model here
bool gameModel::LoadModel(string s_mesh, core::vector3df obj_pos, core::vector3df obj_rotate, core::vector3df obj_scale)
{
video::IVideoDriver* driver = this->device->getVideoDriver();
scene::ISceneManager* smgr = this->device->getSceneManager();
this->mesh = smgr->getMesh(s_mesh.c_str());
if (!this->mesh)
{
device->drop();
return false;
}
this->node = smgr->addAnimatedMeshSceneNode(this->mesh); // set node
if (this->node)
{
//scene::ICameraSceneNode* camera = smgr->getActiveCamera();
this->node->setPosition(obj_pos);
this->node->setRotation(obj_rotate);
this->node->setScale(obj_scale);
//this->node->setMaterialFlag(video::EMF_LIGHTING, false);//global light for example, here this parametr work, but in child`s ...
}
return true;
}
/***********************************************************/
// and child class,
class goMarker : public gameModel
{
protected:
u32 id;
IrrlichtDevice* device;
IAnimatedMesh* mesh;
IAnimatedMeshSceneNode* node;
public:
goMarker(IrrlichtDevice *device, IAnimatedMeshSceneNode* object, core::vector3df obj_pos, core::vector3df obj_rotate): gameModel(device) // parent`s constructor
{
this->mesh = 0;
this->node = 0;
this->LoadModel("obj/items/piramid1.3DS", obj_pos, obj_rotate, core::vector3df(1.0,1.0,1.0));
//if(this->node)
{ // this block do not work, because this->node == NULL
//every time my programm terminate
this->node->setMaterialFlag(video::EMF_LIGHTING, false);
}
}
bool LoadModel(string s_mesh, core::vector3df obj_pos, core::vector3df obj_rotate, core::vector3df obj_scale) {return gameModel::LoadModel(s_mesh,obj_pos,obj_rotate,obj_scale);}
// some code...
};
/***********************************************************/
//in init block i load my model
gameModel* pir1 = new goMarker(device,this->player.node,core::vector3df(5400,980,2800),core::vector3df(0,0,0));