I swear this has to be a bug, but I would like someone to prove me wrong. I have 2 models in space and the player. I create both models separately and create a separate triangle selector for each one, and then add each triangle selector in turn to the metaTriangleSelector, and then create the player (camera) and attach the metaTriangleSelector to the player. But when I run the game, collision occurs with only one of the models, the last one which was added to the metaTriangleSelector.
Has anyone else encountered this problem?
Does anyone else have similar code for 2 or more models in which your collsion detection IS working for both? If so I would like to see what you did different.
Here's my code:
(global)
scene::IMetaTriangleSelector* mainTriangleSelector = 0;
(local)
// MODELS /////////////////////////////////////////////
mainTriangleSelector = smgr->createMetaTriangleSelector();
Model = smgr->getMesh("model.ms3d");
node = smgr->addAnimatedMeshSceneNode(Model);
node->setMaterialFlag(video::EMF_LIGHTING, true);
node->setMaterialTexture(0, driver->getTexture("texture.jpg"));
node->setPosition(core::vector3df(0,0,2000));
scene::ITriangleSelector* s = smgr->createTriangleSelectorFromBoundingBox(node);
node->setTriangleSelector(s);
mainTriangleSelector->addTriangleSelector(s);
s->drop();
Model2 = smgr->getMesh("model.ms3d");
node2 = smgr->addAnimatedMeshSceneNode(Model2);
node2->setMaterialFlag(video::EMF_LIGHTING, true);
node2->setMaterialTexture(0, driver->getTexture("texture.jpg"));
node2->setPosition(core::vector3df(2000,0,0));
scene::ITriangleSelector* s2 = smgr->createTriangleSelectorFromBoundingBox(node2);
node2->setTriangleSelector(s2);
mainTriangleSelector->addTriangleSelector(s2);
s2->drop();
// CAMERA /////////////////////////////////////////////
Player = smgr->addCameraSceneNodeFPS(0, 100.0f, 500.0f);
Player->setFarValue(MAX_VIEW_DISTANCE);
anim = smgr->createCollisionResponseAnimator(mainTriangleSelector, Player, core::vector3df(30,50,30), core::vector3df(0,0,0), 100.0f, core::vector3df(0,20,0));
Player->addAnimator(anim);
anim->drop();
Player->setFOV(1.50f);
metaTriangleSelector problem
-
- Posts: 271
- Joined: Sat Aug 23, 2003 5:52 pm
- Location: Hurricane Central, Florida
-
- Posts: 271
- Joined: Sat Aug 23, 2003 5:52 pm
- Location: Hurricane Central, Florida
I am currently using MetaTriangleSelector now-- and I have a problem which is different from the above one (which was resolved). but I thought I might as well stick it in this thread.
Basically, I have 3 objects: a .3ds room, and two .md2 objects
I create an OctTree Triangle Selector from the room, and 2 different Triangle Selectors from Bounding Box (one for each md2 scene).
Now, when the MD2 model moves around, it sticks to the floor.
If I DONT add a BB-selector for one of the models, that particular model wont have this problem (but the one with a BBselector will).
I wonder if when a collision animator is working on a scene node using a triangleSelector which includes that node's own geometry (ie: its bounding box) it is colliding with itself?
I suppose I'll be looking into the irrlicht engine to see if this is the case, and if i can fix it or not
Basically, I have 3 objects: a .3ds room, and two .md2 objects
I create an OctTree Triangle Selector from the room, and 2 different Triangle Selectors from Bounding Box (one for each md2 scene).
Now, when the MD2 model moves around, it sticks to the floor.
If I DONT add a BB-selector for one of the models, that particular model wont have this problem (but the one with a BBselector will).
I wonder if when a collision animator is working on a scene node using a triangleSelector which includes that node's own geometry (ie: its bounding box) it is colliding with itself?
I suppose I'll be looking into the irrlicht engine to see if this is the case, and if i can fix it or not
a screen cap is worth 0x100000 DWORDS
Okay, so currently, there is no way for a collision response animator to know if the scene it is dealing with is inside of the MetaTriangle selector it is using.
this is because it doesnt know its using a meta triangle selector. but if it DID know, it could simply ask the MetaTriangleSelector to send all of its TSs (except any that match the current scene node) to getCollisionResultPosition()
but, MTS does inherit from TS, so what if we added a virtual function to TS:
getTrisExcludeScene(ISceneNode* node);
in CTriangleSelector it would be implemented as:
if(node == this->SceneNode) return NULL;
else return this;
in CMetaTriangleSelector, it would be implemented as:
CMetaTriangleSelector result;
for(each x in TriangleSelectors)
if( x->SceneNode != node) result.addTriangleSelector(x);
return result;
and finally, you'd have to change the call to getCollisionResultPosition() to send World->getTrisExcludeScene(Object)
and make sure getCollisionResultPosition doesnt fail if the TriangleSelector sent to it is just a NULL
this is because it doesnt know its using a meta triangle selector. but if it DID know, it could simply ask the MetaTriangleSelector to send all of its TSs (except any that match the current scene node) to getCollisionResultPosition()
but, MTS does inherit from TS, so what if we added a virtual function to TS:
getTrisExcludeScene(ISceneNode* node);
in CTriangleSelector it would be implemented as:
if(node == this->SceneNode) return NULL;
else return this;
in CMetaTriangleSelector, it would be implemented as:
CMetaTriangleSelector result;
for(each x in TriangleSelectors)
if( x->SceneNode != node) result.addTriangleSelector(x);
return result;
and finally, you'd have to change the call to getCollisionResultPosition() to send World->getTrisExcludeScene(Object)
and make sure getCollisionResultPosition doesnt fail if the TriangleSelector sent to it is just a NULL
a screen cap is worth 0x100000 DWORDS