Collision Detection

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Collision Detection

Postby RemSpam » Wed Oct 22, 2008 2:03 am

I try to use Newton as collision detection engine. But my simple test doesn't work. I have 2 intersecting trimesh objects but NewtonCollisionCollide returns that there is no collisions between them. What's wrong?

Code: Select all
procedure TForm1.NewtonTest(Sender: TObject);
const
  Min: array[0..2] of Single = (-10, -10, -10);
  Max: array[0..2] of Single = ( 10,  10,  10);
var
  World: PNewtonWorld;
  Coll1, Coll2: PNewtonCollision;
  Face: array[0..2] of TPoint;
  Contacts, Normals, Penetration: array[0..2] of TVector3f;
begin
  World := NewtonCreate(nil, nil);
  NewtonSetWorldSize(World, @Min[0], @Max[0]);

  Coll1 := NewtonCreateTreeCollision(World, nil);
  NewtonTreeCollisionBeginBuild(Coll1);
  Face[0].x := 0; Face[0].y := 0; Face[0].z := 0;
  Face[1].x := 5; Face[1].y := 0; Face[1].z := 0;
  Face[2].x := 5; Face[2].y := 5; Face[2].z := 0;
  NewtonTreeCollisionAddFace(Coll1, 3, @Face[0], SizeOf(TPoint), 1);
  NewtonTreeCollisionEndBuild(Coll1, 0);

  Coll2 := NewtonCreateTreeCollision(World, nil);
  NewtonTreeCollisionBeginBuild(Coll2);
  Face[0].x := 2; Face[0].y := -2; Face[0].z := -1;
  Face[1].x := 2; Face[1].y := 2; Face[1].z := -1;
  Face[2].x := 2; Face[2].y := 0; Face[2].z := 1;
  NewtonTreeCollisionAddFace(Coll2, 3, @Face[0], SizeOf(TPoint), 1);
  NewtonTreeCollisionEndBuild(Coll2, 0);

  ShowMessage(IntToStr(NewtonCollisionCollide(World, 3,
        Coll1, @IdentityMatrix4f[0][0],
        Coll2, @IdentityMatrix4f[0][0],
        @Contacts[0][0], @Normals[0][0], @Penetration[0][0])));  //it shows 0

  NewtonDestroy(World);
end;
RemSpam
 
Posts: 4
Joined: Mon Jan 28, 2008 2:43 am

Re: Collision Detection

Postby Julio Jerez » Wed Oct 22, 2008 9:58 am

collirion trees in 1.53 need more than one face
Julio Jerez
Moderator
Moderator
 
Posts: 11154
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Collision Detection

Postby RemSpam » Wed Oct 22, 2008 10:42 am

In my program (not in the test one) every mesh consist of at least 12 triangles. But program still doesn't work.
RemSpam
 
Posts: 4
Joined: Mon Jan 28, 2008 2:43 am

Re: Collision Detection

Postby Julio Jerez » Wed Oct 22, 2008 10:57 am

are you using 2.0?
Julio Jerez
Moderator
Moderator
 
Posts: 11154
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Collision Detection

Postby RemSpam » Wed Oct 22, 2008 11:54 am

I'm using 1.53
RemSpam
 
Posts: 4
Joined: Mon Jan 28, 2008 2:43 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 4 guests

cron