A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by Julio Jerez » Tue Oct 28, 2008 9:21 am
You do no nee to set any matrix when using debug display, the point are already in global space.
This is how you code should be
- Code: Select all
void MyDiceApp::NewtonDebugCollision(const NewtonBody* body, int vertexCount, const dFloat* faceVertec, int id)
{
int i;
i = vertexCount - 1;
core::vector3df p0 (faceVertec[i * 3 + 0] * kNewtonToIrr, faceVertec[i * 3 + 1] * kNewtonToIrr, faceVertec[i * 3 + 2]* kNewtonToIrr);
if (driver != 0) {
video::SMaterial material;
material.Lighting = false;
driver->setMaterial(material);
// not setting of any transform point are in global space
//driver->setTransform(video::ETS_WORLD, core::matrix4());
for (i = 0; i < vertexCount; i++) {
core::vector3df p1 (faceVertec[i * 3 + 0] * kNewtonToIrr, faceVertec[i * 3 + 1] * kNewtonToIrr, faceVertec[i * 3 + 2] * kNewtonToIrr);
driver->draw3DLine (p0, p1, AYELLOW);
p0 = p1;
}
}
void MyDiceApp::NewtonDebugBody (const NewtonBody* body)
{
dFloat *nMinVertex = new dFloat(); // 3*3 floats
dFloat *nMaxVertex = new dFloat();
irrAllocatorFast<dFloat> *iaf = new irrAllocatorFast<dFloat>;
nMinVertex = (dFloat*)iaf->allocate(3);
nMaxVertex = (dFloat*)iaf->allocate(3);
NewtonBodyGetAABB(body,nMinVertex,nMaxVertex);
vector3df irrMinVert = NewToIrrFloatVector(nMinVertex);
vector3df irrMaxVert = NewToIrrFloatVector(nMaxVertex);
irrMinVert *= kNewtonToIrr;
irrMaxVert *= kNewtonToIrr;
video::SMaterial material;
material.Lighting = false;
driver->setMaterial(material);
// set mat to identity matrix
core::matrix4 mat = indentitymatrix;
driver->setTransform(video::ETS_WORLD, mat );
aabbox3df box(irrMinVert,irrMaxVert);
driver->draw3DBox(box,ARED);
iaf->destruct(nMinVertex);
iaf->destruct(nMaxVertex);
if (debugMode == 2)
NewtonBodyForEachPolygonDo(body, MyDiceApp::NewtonDebugCollision);
}
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by Kapitan » Wed Oct 29, 2008 3:04 am
Very thanks, i'll try.
Because, by now, i've managed to apply the irrlicht trasform matrix
before adding vertices and it perfectly works.
But the NewtonBodySetMatrix and NewtonBodyGetMatrix problem?
-
Kapitan
-
- Posts: 37
- Joined: Thu Apr 17, 2008 6:07 pm
by Julio Jerez » Wed Oct 29, 2008 7:21 am
OIn 1.53 the code SetMtarix normalize the matrix.
so the matrix and get matrxi will getener tow diffrent value if yuor matrix have a scale build in.
That might explain why difference in size.
teh normalization was removed in SDK 2.0 but teh matrix still have to e normal orthonorormal , white determinant of rotation part equal 1.0
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by JernejL » Wed Oct 29, 2008 8:46 am
Julio Jerez wrote:You do no nee to set any matrix when using debug display, the point are already in global space.
This is how you code should be
- Code: Select all
NewtonBodyForEachPolygonDo
Not in older newton versions, but in newton 2.0 this iterator was replaced with NewtonCollisionForEachPolygonDo which has the points in local collision space since it works on collision rather than a body.
-
JernejL
-
- Posts: 1578
- Joined: Mon Dec 06, 2004 2:00 pm
- Location: Slovenia
-
by Kapitan » Wed Oct 29, 2008 1:50 pm
Julio Jerez wrote:OIn 1.53 the code SetMtarix normalize the matrix.
so the matrix and get matrxi will getener tow diffrent value if yuor matrix have a scale build in.
That might explain why difference in size.
teh normalization was removed in SDK 2.0 but teh matrix still have to e normal orthonorormal , white determinant of rotation part equal 1.0
This explains all things, so the direct set isn't safe from
irrlich, my solution to insert trasformed vertices is good then.
But where can i find beta 2.0 ?
-
Kapitan
-
- Posts: 37
- Joined: Thu Apr 17, 2008 6:07 pm
by Kapitan » Sat Nov 01, 2008 12:40 pm
Julio you have a PM.
-
Kapitan
-
- Posts: 37
- Joined: Thu Apr 17, 2008 6:07 pm
by Julio Jerez » Sun Nov 02, 2008 8:34 am
are you sure you send it, I did not see it.
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by Kapitan » Sun Nov 02, 2008 1:28 pm
sent another
-
Kapitan
-
- Posts: 37
- Joined: Thu Apr 17, 2008 6:07 pm
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 12 guests