Problem with GetCollisionPoint(). Help me !

Irrlicht.Net is no longer developed or supported, Irrlicht.Net Cross Platform is a much more complete wrapper. Please ask your C# related questions on their forums first.
Locked
TrueLiar
Posts: 16
Joined: Thu Sep 29, 2005 2:13 pm
Location: Vietnam

Problem with GetCollisionPoint(). Help me !

Post by TrueLiar »

I'm using C# to write my app. I create a height map and want to pick triangles.
I create a selector
// Selector

Code: Select all

ITriangleSelector selector = scene.CreateTerrainTriangleSelector(terrain, 0);
Into render stuff, create intersector and triangle:

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));
}
When I move the camera lookat into heightmap, GetCollisionPoint() return true (correct). But intersection and triangle is value (0,0,0) and (0,0,0). So it donot draw a triangle then I expected. Any one help me !
jerky
Posts: 12
Joined: Sun Aug 14, 2005 4:53 am

Post by jerky »

Just test the triangle against one that has a value of (0,0,0)

Code: Select all

Triangle3D zeroTriangle = new Triangle3D(); 
if(scene.SceneCollisionManager.GetCollisionPoint(line, selector, intersection, triangle) && !triangle.Equals(zeroTriangle))
   { /*etc. */ }
The same problem exists in "normal c++" irrlicht.
check out JohnnyAppleseed: Irrlicht Terrain Editor at http://home.case.edu/~jcp16/johnnyappleseed
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

You can download Irrlicht-Spintz, link in my sig.

I have fixes for this, there are known bugs with collision, especially with DirectX, because of an FPU precision thing. You can apply individual fixes, by looking in the bug reports section, i think there's 3 total posts about different bugs that need to be applied.
Image
Locked