I create a selector
// Selector
Code: Select all
ITriangleSelector selector = scene.CreateTerrainTriangleSelector(terrain, 0);
Code: Select all
Line3D line = new Line3D();
Vector3D vector = new Vector3D();
Vector3D intersection = new Vector3D();
Triangle3D triangle = new Triangle3D();
// create ray
line.start = cam.Position;
vector = (cam.Target - line.start).Normalize() * 100000.0f;
line.end.X = line.start.X + vector.X;
line.end.Y = line.start.Y + vector.Y;
line.end.Z = line.start.Z + vector.Z;
// Problem here
if(scene.SceneCollisionManager.GetCollisionPoint(line, selector, intersection, triangle))
{
driver.SetTransform(TransformationState.WORLD, new Matrix4());
driver.Draw3DTriangle(triangle, new Color(0,255,0,0));
}