Get point coordinate on a mesh

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
LeGars
Posts: 8
Joined: Thu May 11, 2006 1:57 pm

Get point coordinate on a mesh

Post by LeGars »

Hi,

I try to get the point coordinate when I clicked on a 3D model load from a mesh file (md2 or x).
the aim of this is to get the normal of the suface I clicked on and the 3 coordinate of the position.

Can I (and how) do it when I use a model file as md2 or x ? If not what kind of file should I use ?

Thanks.
needforhint
Posts: 322
Joined: Tue Aug 30, 2005 10:34 am
Location: slovakia

Post by needforhint »

don't know wheter you can pick up a normal, but you can pick up the accuret triangle(face,polygon) by triangle selector and colision detection with rayXY .. thats how I would do it
what is this thing...
Elise
Posts: 48
Joined: Tue Jul 19, 2005 6:30 am
Contact:

Post by Elise »

You could try something like this:

Code: Select all

// First get 3d line from camera to cursor position:
line3d<f32> line = irrSceneCollisionManager->
                                getRayFromScreenCoordinates(irrCursorControl->getPosition(), irrCamera);

// Create triangle selector from the node
ITriangleSelector* ts = irrSceneManager->createTriangleSelector(
                                        mesh->getMesh(0), sceneNode);

vector3df intersection; // collision point
triangle3df tri; // collision triangle

// Test for collision
if (irrSceneCollisionManager->getCollisionPoint(line,
                            ts, intersection, tri) == true)
{
    // Collision found, get normal
    vector3df normal = tri.getNormal();
}

I didn't test the above code but it might work.
LeGars
Posts: 8
Joined: Thu May 11, 2006 1:57 pm

Post by LeGars »

Elise : Thanks for that idea, but I can't test it :
I don't have that function :

Code: Select all

getCollisionPoint
I'm working with the .Net version of Irrlicht and C# (but translation with C++ is not problem).

needforhint :
I will try your idea
LeGars
Posts: 8
Joined: Thu May 11, 2006 1:57 pm

Post by LeGars »

I can't find rayXY. Where should I find it ?
Post Reply