NODE DROP ERROR

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Mh025
Posts: 16
Joined: Wed Jul 11, 2007 4:10 pm

NODE DROP ERROR

Post by Mh025 »

Hi all,
I have a IAnimatedMeshSceneNode that I have to drop, this is the node:

Code: Select all

enemy[i].mesh = smgr->getMesh("./data/enemy/zombie.b3d");
enemy[i].node = smgr->addAnimatedMeshSceneNode(enemy[i].mesh);
f(enemy[i].node)
{
      enemy[i].node->setPosition(core::vector3df(enemy[i].pos)); 
      enemy[i].node->setScale(core::vector3df(13, 13, 13));
      enemy[i].node->setMaterialFlag(EMF_LIGHTING, false); 
      enemy[i].selector = smgr->createTriangleSelector(enemy[i].mesh->getMesh(0), enemy[i].node);
      enemy[i].node->setTriangleSelector(enemy[i].selector);
      enemy[i].selector->drop();
}
But when i try to drop it with drop() i get a windows error: "There is an error in program.exe, the application will be close: Submit error, debug, ecc. "
I have tryed also with smgr->addToDeletionQueue(node) and node->remove() but i get always the same windows error, what i have to do for dropping it?
P.S: The animation has collisions, texture and animations.
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

first of all: you should never drop a node !!!

from the docu of addAnimatedMeshSceneNode:
Returns:
Returns pointer to the created scene node. This pointer should not be dropped. See IUnknown::drop() for more information.
node->remove() should work for this...
it seems you're trying to do something with the node after it was removed, for example setPosition, setRotation, setScale, or something similar...
you always should test if the node still exists (like you do in the code snipet above), but that means if you remove the node you also must set the pointer to 0, because it will not be set to 0 just if you remove the node !!!
so after removing the node set it to 0 like this:

Code: Select all

enemy[i].node->remove();
enemy[i].node = 0;
then later check if it still exists

Code: Select all

if(enemy[i].node){
  // do something with the node
}
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Mh025
Posts: 16
Joined: Wed Jul 11, 2007 4:10 pm

Post by Mh025 »

Acki wrote:it seems you're trying to do something with the node after it was removed, for example setPosition, setRotation, setScale, or something similar...
Those things are executed when i create the node, anyway i have tryed to set enemy.node = 0 and I don't get windows error! But the collision still exist, how i can remove it?
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Mh025 wrote:Those things are executed when i create the node, anyway i have tryed to set enemy.node = 0 and I don't get windows error!
I'm sure you're doing something with it after removing, but the main point is you got it to run... ;)

unfortunatly I'm not really familiar with Irrlicht's collision system (I'm using Newton)... :cry:
But as far as you have several triangle selectors, don't you use a MetaTriangleSelector then ??? :shock:
If you use a MetaTriangleSelector you can remove a single selector with IMetaTriangleSelector::removeTriangleSelector(ITriangleSelector* toRemove), otherwise I don't know, maybe someone with more knowledge of the Irrlicht collision system can help you then ???
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Mh025
Posts: 16
Joined: Wed Jul 11, 2007 4:10 pm

Post by Mh025 »

All was solved with a simple enemy.node->deleteAnimator(animcam) (animcam is the collision animator), Tnx for your help!!
Post Reply