Adding collision question

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
NecromanX
Posts: 16
Joined: Sat Jan 24, 2004 6:01 pm

Adding collision question

Post by NecromanX »

I have setted up a scene with a moving node inside a bsp file and i added all the collision detection code and it works fine.
Now i added a static model to the scene and i want this model to be a part of the collision so that my moving node wont run tru it.
Any help on how i should add it?
keless
Posts: 805
Joined: Mon Dec 15, 2003 10:37 pm
Location: Los Angeles, California, USA

Post by keless »

for code, see IrrLichtRPG 'levelmanager.cpp':
http://www.skyesurfer.net/keless/IrrLicht/RPG/

basically, in this aspect IrrLicht is pretty clunky. The only way to have multiple triselectors for use in collision detection is to have them grouped in an IMetaTriangleSelector (so far so good). So when you create your object, dont directly add your world's TriSel, just add an empty IMetaTriSel.

Now, once you've created your world, save a pointer to the TriSel you create from it. Also, for each object you create, save a pointer to its 'TriSelFromBB'.

When an object is created, you will create an IMetaTriSel with it that will be set as its selector. Then you need to add the TriSel of the level, and of all of the other entities to that IMetaTriSel. Do not add that entity's own TriSel to its MetaTS or it will collide with itself and movement will be choppy and bad.

When you want to delete an object, you need to remove its TriSel from all of the IMetaTriSelectors belonging to all the other entities before you remove it.
a screen cap is worth 0x100000 DWORDS
NecromanX
Posts: 16
Joined: Sat Jan 24, 2004 6:01 pm

Post by NecromanX »

Thanks mate you really helped me out :)!
NecromanX
Posts: 16
Joined: Sat Jan 24, 2004 6:01 pm

Post by NecromanX »

hmm i still have a problem :X
You add the trisel from the boundingbox correct?, well I need to add the real model instead of its box because it will have to be possible to walk into that model (it has a door :p) and then the model will be moveable
btw do you have msn messenger? i would like to discuss this issue a little smooter :)
keless
Posts: 805
Joined: Mon Dec 15, 2003 10:37 pm
Location: Los Angeles, California, USA

Post by keless »

just AIM, but you shouldnt use MSN anyway-- its :evil: !

i dont know off the top of my head how to create a triangle selector from a scene node's mesh. look in the documentation.
a screen cap is worth 0x100000 DWORDS
NecromanX
Posts: 16
Joined: Sat Jan 24, 2004 6:01 pm

Post by NecromanX »

I dont think its possible :X
keless
Posts: 805
Joined: Mon Dec 15, 2003 10:37 pm
Location: Los Angeles, California, USA

Post by keless »

okay, we can get the mesh "getMesh()" and we can attach an arbitrary trisel to a scene node "setTriangleSelector()"

we can simply create a new TriSel, and use "getTriangles" on the Mesh so that it is a TS for that mesh, then attach it to the scene node with setTriangleSelector().

Issues to worry about would be:
1) the transformation matrix of the TS should reflect that of the ISceneNode
2) the transformation matrix of the TS should then be updated whenever the ISceneNode is moved/changed
3) animated mesh scenes should update their TriSelector's to reflect the new arrangement of their mesh each frame (which might be expensive, i dont know)

So, it sounds like you'd have to create some custom classes (a custom scene node and maybe an animator to update the TS) if you wanted per-triangle collision detection.
a screen cap is worth 0x100000 DWORDS
buhatkj
Posts: 444
Joined: Fri Dec 12, 2003 4:53 am
Contact:

from the descriptions, tokamak might help

Post by buhatkj »

from my understanding, it is possible also to sort of substitute in tokamak's collision detection. dunno if that helps you...
My irrlicht-based projects have gone underground for now, but if you want, check out my webcomic instead! http://brokenboomerang.net
Post Reply