Hello,
I will try to give you more informations...
eventreceiver, this executes, when I click on the Start button to start my game:
Code: Select all
case 151:
{
textLog.writeLog("Button '151' clicked.");
env->clear();
loadExercise1(smgr,device,driver,env);
break;
}
loadExercise1 function
Code: Select all
void loadExercise1( ISceneManager* smgr, IrrlichtDevice *device, IVideoDriver * driver, IGUIEnvironment *env){
smgr = device->getSceneManager();
SKeyMap keyMap[8];
keyMap[0].Action = EKA_MOVE_FORWARD;
// (not relevant here...)
keyMap[7].KeyCode = KEY_KEY_D;
smgr->loadScene("models_materials\\game.irr");
camera = smgr->addCameraSceneNodeFPS(0, 120.0f, 0.2f, -1, keyMap, 9, true,0.15f);
f32 aspect = 1.f * driver->getScreenSize().Width / driver->getScreenSize().Height;
camera->setRotation(core::vector3df(0,-90,0));
camera->setPosition(core::vector3df(0,80,0));
camera->setFarValue(20000.0f);
camera->setAspectRatio(aspect);
camera->setFOV(2*PI/5);
metaSelector = smgr->createMetaTriangleSelector();
recursiveFillMetaSelector( smgr->getRootSceneNode(), metaSelector );
curs = smgr->addAnimatedMeshSceneNode(smgr->getMesh("cursors\\szines_babu_final.obj"),camera,-1,core::vector3df(0,3,20));
curs->setScale(vector3df(0.075 , 0.075 , 0.075));
curs->setMaterialFlag(video::EMF_LIGHTING,false);
anim = smgr->createCollisionResponseAnimator( metaSelector, camera, core::vector3df(20,36,20),
core::vector3df(0,-10.0f,0),
core::vector3df(0,85,0));
anim->setEllipsoidRadius( core::vector3df(10,36,10) );
camera->addAnimator(anim);
metaSelector->drop();
admin.setEx1_ObjectsAndActivities();
admin.Ex1_showElements();
admin.Ex1_loadDistinctObjects( admin.patientID ); // SELECT DISTINCT -> to prevent multiple load of the same objects/activities
device->getCursorControl()->setVisible(false);
}
When I push the Q button to quit to the menu:
Code: Select all
switch (event.KeyInput.Key)
{
case KEY_KEY_Q:
{
IGUIEnvironment* env = device->getGUIEnvironment();
smgr->clear();
env->clear();
device->getCursorControl()->setVisible(true);
}
return true;
}
And when, here in the menu, When I click on start once again, the application creashes here:
Code: Select all
recursiveFillMetaSelector( smgr->getRootSceneNode(), metaSelector );
The function:
Code: Select all
void recursiveFillMetaSelector(scene::ISceneNode* node, scene::IMetaTriangleSelector* meta )
{
printf ("Node name is: %s \n",node->getName());
printf ("Node id is: %d \n",node->getID());
printf ("Node type:");
if (node->getType() == ESNT_UNKNOWN) printf("Unknown mesh type \n\n");
if (node->getType() == ESNT_MESH) printf("Standard Mesh \n\n");
if (node->getType() == ESNT_ANIMATED_MESH) printf("Animated Mesh! \n\n");
if (node->getType() == ESNT_SKY_BOX) printf("SkyBox! \n\n");
if (node->getType() == ESNT_CAMERA_FPS) printf("Fps Camera! \n\n");
if (node->getType() == ESNT_CAMERA_MAYA ) printf("Maya Camera! \n\n");
if (node->getType() == ESNT_CAMERA )
{
printf("STD Camera! \n");
camera->setPosition(node->getPosition());
}
if (node->getType() == ESNT_PARTICLE_SYSTEM ) printf("Particles! \n\n");
if (node->getType() == ESNT_LIGHT ) printf("Light! \n\n");
if (node->getType() == ESNT_OCTREE)
{
printf("Occtree! \n");
io::IAttributes* attribs = device->getFileSystem()->createEmptyAttributes();
if (attribs)
{
node->serializeAttributes(attribs);
core::stringc name = attribs->getAttributeAsString("Mesh");
attribs->drop();
scene::IAnimatedMesh* mesh = smgr->getMesh(name.c_str());
if (mesh)
{
selector = smgr->createOctTreeTriangleSelector(mesh->getMesh(0), node, 128);
node->setTriangleSelector(selector);
metaSelector->addTriangleSelector(selector);
selector->drop();
}
}
}
core::list<scene::ISceneNode*>::ConstIterator begin = node->getChildren().begin();
core::list<scene::ISceneNode*>::ConstIterator end = node->getChildren().end();
for (; begin != end; ++begin)
{
recursiveFillMetaSelector(*begin, meta);
}
}