Here's my version of debug rendering routines:
Code:
procedure DebugShowGeometryCollision_Wire(const body: PNewtonBody; vertexCount: integer; const FaceArray: PFloat; faceId: integer); cdecl;
var
i: integer;
vn: integer;
procedure rendervertex(const num: integer);
begin
glVertex3fv(pointer(integer(FaceArray) + num * 12));
end;
begin
vn := vertexCount - 1;
for i := 0 to vertexCount - 1 do
begin
rendervertex(vn);
rendervertex(i);
vn := i;
end;
end;
// show rigid body collision geometry
procedure DebugShowBodyCollision_wire(const body: Pnewtonbody); cdecl;
var
tempmatrix: TMatrix4f;
begin
//NewtonBodyForEachPolygonDo(body, @DebugShowGeometryCollision_Wire);
NewtonBodyGetMatrix(body, @tempmatrix);
NewtonCollisionForEachPolygonDo(NewtonBodyGetCollision(body), @tempmatrix, @DebugShowGeometryCollision_Wire, nil);
end;
procedure NewtonWorldForEachBodyDo(const newtonWorld: PNewtonWorld; callback: PNewtonBodyIterator);
var
thebody: PNewtonBody;
begin
thebody := NewtonWorldGetFirstBody(newtonWorld);
while thebody <> nil do
begin
callback(thebody);
thebody := NewtonWorldGetNextBody(newtonWorld, thebody);
end;
end;
// show all collision geometry in debug mode
procedure DebugShowCollision_wire;
begin
NewtonWorldForEachBodyDo(nWorld, DebugShowBodyCollision_wire);
end;
and call:
Code:
glBegin(gl_lines);
DebugShowCollision_wire;
glend;
Bookmarks