Custom SceneNode with collision

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
barebones
Posts: 5
Joined: Sun Mar 23, 2008 4:07 pm

Custom SceneNode with collision

Post by barebones »

Hi, a little n00b question,
how do I add collision detection support to a custom SceneNode? Which interface(s) does the node need to implement? (The node contains a good number of triangles already organized in a tree.)

Thanks.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

I guess you just need to create a triangle selector for the node, not sure how you'd go about it but you could look at how the SceneManager class creates triangle selectors from nodes. Or maybe you can just use that function on your custom node... Have you tried that?
Image Image Image
aheymann
Posts: 153
Joined: Wed Aug 22, 2007 12:25 pm
Location: England

Post by aheymann »

Hallo

I have implemented it in the following way :

(This is a code snippet and might not be optimised)

Code: Select all

// A global selector (World)
IMetaTriangleSelector      *World;
// Declare a SMesh
SMesh         Mesh;
// Declare a local triangle selector
ITriangleSelector *selector;

// _3DPlanes is a SMeshBuffer containing the triangles
Mesh.addMeshBuffer(&_3DPlanes);  
selector = SceneManager->createOctTreeTriangleSelector(&Mesh, this);
setTriangleSelector(selector);
World->addTriangleSelector(selector); // add all the various mesh selectors to this meta selector
Hope it gives you some ideas. The code above will add the triangles in a custom node to a 'local' selector (which can be dropped later) and then in turn adds it to a meta selector (the 'world'). This allows for custom collision detection and searching.

Anton
Post Reply