Collision detection

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
lazar.mihai
Posts: 2
Joined: Mon Jul 17, 2006 11:57 am

Collision detection

Post by lazar.mihai »

Does collision detection only work with bsp maps or can I get it to work with .x files .. and other types of meshes .. ??

I tried to write a program to do it from .x mesh but it didn't work ... any help ?
Lazar Mihai
zulis
Posts: 3
Joined: Thu Jun 08, 2006 7:48 am

Post by zulis »

Works with other formats too.

Managed code example:

Code: Select all

//Add mesh
IAnimatedMesh mesh = smgr.GetMesh("scene.my3d");
ISceneNode meshNode = smgr.AddOctTreeSceneNode(mesh, null, 0, 128);
meshNode.Position = new Vector3D(0, 0, 0);

//Set collision
ITriangleSelector selector = smgr.CreateOctTreeTriangleSelector(mesh.GetMesh(0), meshNode, 128);
ISceneNodeAnimator anim = smgr.CreateCollisionResponseAnimator(selector, camera, new Vector3D(60, 100, 60), new Vector3D(0, 0, 0), new Vector3D(0, 50, 0), 0.0005f);
camera.AddAnimator(anim);
lazar.mihai
Posts: 2
Joined: Mon Jul 17, 2006 11:57 am

Sorry.. it still doesn't work

Post by lazar.mihai »

I tried what you said .. but I still can't get it to work .. I think it has something to do with the Managed implementation of Irrlicht.. cause in native code worked fine ... but in .NET it doesn't work ... I can't figure out why ...

Also .. why isn't there a IMeshBuffer written for Irrlicht.NET ? I thought the alpha phase was over and done with .. but I see there are more to work on still ...
Lazar Mihai
pedro
Posts: 5
Joined: Fri Jul 14, 2006 2:10 pm

Re: Sorry.. it still doesn't work

Post by pedro »

HELLO! TRY THIS!


//Add mesh
IAnimatedMesh mesh = smgr.GetMesh("scene.my3d");
ISceneNode meshNode = smgr.AddOctTreeSceneNode(mesh, null, 0, 128);
meshNode.Position = new Vector3D(0, 0, 0);

//Set collision
ITriangleSelector selector = smgr.CreateOctTreeTriangleSelector(mesh.GetMesh(0), meshNode, 128);
ISceneNodeAnimator anim = smgr.CreateCollisionResponseAnimator(selector, camera, new Vector3D(1, 1, 1), new Vector3D(0, 0, 0), new Vector3D(0, 1, 0), 0.0005f);
camera.AddAnimator(anim);



I had the same problem and i have solve this way!you must be care ful with the parameters of CreateCollisionResponseAnimator.
by!
Post Reply