Debug with Newton 2.0

Post your questions, suggestions and experiences regarding game design, integration of external libraries here. For irrEdit, irrXML and irrKlang, see the
ambiera forums
Post Reply
Scarabol
Posts: 167
Joined: Sat Jan 03, 2009 5:26 pm
Location: Aachen, Germany

Debug with Newton 2.0

Post by Scarabol »

Hi,

is there any example on how to use the new

Code: Select all

NewtonCollisionForEachPolygonDo()
void NewtonCollisionForEachPolygonDo (const NewtonCollision* collision, const dFloat* matrix, NewtonCollisionIterator callback, void* userData);
???

Especially im interested on the layout of the "NewtonCollisionIterator callback" function?
How does it look like?

MfG
Scarabol
Seven
Posts: 1030
Joined: Mon Nov 14, 2005 2:03 pm

Post by Seven »

Code: Select all

////////////////////////////////////////////////////////////////////
void DebugShowGeometryCollision (void* userData, int vertexCount, const dFloat* faceVertec, int id)
{
	// get a pointer to the object
	CPhysicsObject_Newton2* obj = (CPhysicsObject_Newton2*)userData;
	IrrlichtDevice* device = obj->GetPhysicsWorld()->GetPhysicsManager()->GetDevice();
	
	int i;
	core::vector3df line;

	i = vertexCount - 1;
	core::vector3df p0 (faceVertec[i * 3 + 0] * NewtonToIrr, faceVertec[i * 3 + 1] * NewtonToIrr, faceVertec[i * 3 + 2] * NewtonToIrr);

	for (i = 0; i < vertexCount; i ++) 
	{
		core::vector3df p1 (faceVertec[i * 3 + 0] * NewtonToIrr, faceVertec[i * 3 + 1] * NewtonToIrr, faceVertec[i * 3 + 2] * NewtonToIrr);
		device->getVideoDriver()->draw3DLine (p0, p1, obj->GetPhysicsWorld()->GetPhysicsManager()->m_DebugColor); 
 		p0 = p1;
	}
}

Code: Select all

 matrix4 matrix;
 NewtonBodyGetMatrix(m_NewtonBody, &matrix[0]);
 NewtonCollisionForEachPolygonDo (NewtonBodyGetCollision(m_NewtonBody), &matrix[0], DebugShowGeometryCollision, this);
Scarabol
Posts: 167
Joined: Sat Jan 03, 2009 5:26 pm
Location: Aachen, Germany

Post by Scarabol »

Hi,

thx a lot it works!

MfG
Scarabol
Post Reply