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.
Get point coordinate on a mesh
-
- Posts: 322
- Joined: Tue Aug 30, 2005 10:34 am
- Location: slovakia
You could try something like this:
I didn't test the above code but it might work.
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();
}
Elise : Thanks for that idea, but I can't test it :
I don't have that function :
I'm working with the .Net version of Irrlicht and C# (but translation with C++ is not problem).
needforhint :
I will try your idea
I don't have that function :
Code: Select all
getCollisionPoint
needforhint :
I will try your idea