metaTriangleSelector problem

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
[dx/x]=HUNT3R
Posts: 271
Joined: Sat Aug 23, 2003 5:52 pm
Location: Hurricane Central, Florida

metaTriangleSelector problem

Post by [dx/x]=HUNT3R »

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);
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

Hi, I tried it out, and you are right, ther must be a bug. I'm gonna try to find it. :)
[dx/x]=HUNT3R
Posts: 271
Joined: Sat Aug 23, 2003 5:52 pm
Location: Hurricane Central, Florida

Post by [dx/x]=HUNT3R »

Thanks Niko, I've tried changing my code every way I can think of and it just won't work right. Nobody seems to be answering this post so I'm guessing that no one else has it working either...
Kane

Post by Kane »

i have this problem too, hope you can fix it fast :wink:
Kane

Post by Kane »

oh, i just saw that this thread is 3 Months old, is the problem still unsolved ??
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

No, it's fixed in 0.4.2
keless
Posts: 805
Joined: Mon Dec 15, 2003 10:37 pm
Location: Los Angeles, California, USA

Post by keless »

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
a screen cap is worth 0x100000 DWORDS
keless
Posts: 805
Joined: Mon Dec 15, 2003 10:37 pm
Location: Los Angeles, California, USA

Post by keless »

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
a screen cap is worth 0x100000 DWORDS
keless
Posts: 805
Joined: Mon Dec 15, 2003 10:37 pm
Location: Los Angeles, California, USA

Post by keless »

hrm, I implemented the function, BUT DIDNT USE IT in the collision response animator--- and recompiled the library

now, when they should be doing exactly as they did before (because the new code is never used) they fall thru the floor instead!

crazy
a screen cap is worth 0x100000 DWORDS
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

strange, indeed..
Post Reply