A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by KamiGazz » Tue Sep 04, 2012 6:32 pm
Hi,
I am trying to build a collision tree from a mesh I have within my graphic engine.
My trouble is that some faces are missing. I implemented some function to draw the wireframe of the actual mesh and wireframe of the collision geometry and I can clearly see that some faces are missing.

- Code: Select all
for (i=0; i < NbrFaces*3; i=i+3)
{
Mesh->GetTriangleInfo(i/3,&vec1, &vec2, &vec3, &Group);
Mesh->GetVertex(vec1, &sVertex[i].x, &sVertex[i].y, &sVertex[i].z, &Temp,&Temp,&Temp,&Temp,&Temp,&Temp,&Temp,&color);
Mesh->GetVertex(vec2, &sVertex[i+1].x, &sVertex[i+1].y, &sVertex[i+1].z, &Temp,&Temp,&Temp,&Temp,&Temp,&Temp,&Temp,&color);
Mesh->GetVertex(vec3, &sVertex[i+2].x, &sVertex[i+2].y, &sVertex[i+2].z, &Temp,&Temp,&Temp,&Temp,&Temp,&Temp,&Temp,&color);
NewtonTreeCollisionAddFace(Collision, 3, &sVertex[i/3].x, sizeof(sVERTEX), 1);
}
The code is quite simple and.... I use the same to draw lines between vertices... and this show a perfect wireframe... so why some faces are missing in the collision geometry??
Any idea or way I could debug this??
-
KamiGazz
-
- Posts: 8
- Joined: Sun Feb 06, 2011 2:13 am
by KamiGazz » Tue Sep 04, 2012 6:38 pm
I forgot, here is the code that draw the newton geometry wireframe.
- Code: Select all
void DebugShowGeometryCollision (void* userData, int vertexCount, const dFloat* faceVertec, int id)
{
CTVScreen2DImmediate* p2D = new CTVScreen2DImmediate();
int i = vertexCount - 1;
dVector p0 (faceVertec[i * 3 + 0], faceVertec[i * 3 + 1], faceVertec[i * 3 + 2]);
for (int i = 0; i < vertexCount; i ++)
{
dVector p1 (faceVertec[i * 3 + 0], faceVertec[i * 3 + 1], faceVertec[i * 3 + 2]);
p2D->Draw_Line3D(p0.m_x, p0.m_y, p0.m_z, p1.m_x, p1.m_y, p1.m_z, WHITE, -2);
p0 = p1;
}
}
void CL3DObject::NewtonDebug(void)
{
dMatrix matrix;
NewtonBodyGetMatrix(pbody, &matrix[0][0]);
NewtonCollisionForEachPolygonDo (NewtonBodyGetCollision(pbody), &matrix[0][0], DebugShowGeometryCollision, NULL);
}
I'm pretty sure this code is ok because the physics interaction match the missing faces.... object goes through my mesh where some faces are missing in the wireframe.
-
KamiGazz
-
- Posts: 8
- Joined: Sun Feb 06, 2011 2:13 am
by Julio Jerez » Tue Sep 04, 2012 8:20 pm
is this core 300?
try not using the optimization flag
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by KamiGazz » Wed Sep 05, 2012 11:12 am
no, this is version 2.53.
Maybe I should swtich to core 300... I guess I was simply too lazy to compile the library!

Changing the Optimization flag gives the same result, I already tested it before I posted my issue... :S
-
KamiGazz
-
- Posts: 8
- Joined: Sun Feb 06, 2011 2:13 am
by Julio Jerez » Wed Sep 05, 2012 11:28 am
do you mean core 1.53? thsi is abpu 8 year old code? I do nor even have the sorce anymore.
if you change the optimization flag, and you got the same result, then ther must be a bug in the code the feed the face to the collision tree.
Not optimized collsion meshes are identical to the original meshes. are you sure your mesh is not a veryex list index list and you are reading the wrong points?
also I recomend moving to core 300, there are great improvement and new funtionlity that does no exist in core 200
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by KamiGazz » Thu Sep 06, 2012 11:35 am
oups... I meant 2.36! I like old school style but not that much!

"are you sure your mesh is not a veryex list index list and you are reading the wrong points?"
I'm not sure I understand what you mean there... but as you can see in the code of my first post, I retreive the vertex faces by faces.
GetTriangleInfo is a built in fonction of my graphic engine that return the indices of the 3 vertices of a face. I then use this info to push the vertices infos in the NewtonTreeCollisionAddFace().
Plus, If I replace the NewtonTreeCollisionAddFace by my debug method that draw a line between the 3 vertex of the face, I get a perfect wireframe of my mesh....
I downloaded core 300 yesterday, I will test it as soon as I am able to compile the DLL, cuz for now I can compile static lib but I'm having linker error to compile the DLL.
-
KamiGazz
-
- Posts: 8
- Joined: Sun Feb 06, 2011 2:13 am
by KamiGazz » Thu Sep 06, 2012 5:15 pm
I'm sure you get bored of hearing this Julio but... you were right!

- Code: Select all
for (i=0; i < NbrFaces*3; i=i+3)
{
Mesh->GetTriangleInfo(i/3,&vec1, &vec2, &vec3, &Group);
Mesh->GetVertex(vec1, &sVertex[i].x, &sVertex[i].y, &sVertex[i].z, &Temp,&Temp,&Temp,&Temp,&Temp,&Temp,&Temp,&color);
Mesh->GetVertex(vec2, &sVertex[i+1].x, &sVertex[i+1].y, &sVertex[i+1].z, &Temp,&Temp,&Temp,&Temp,&Temp,&Temp,&Temp,&color);
Mesh->GetVertex(vec3, &sVertex[i+2].x, &sVertex[i+2].y, &sVertex[i+2].z, &Temp,&Temp,&Temp,&Temp,&Temp,&Temp,&Temp,&color);
NewtonTreeCollisionAddFace(Collision, 3, &sVertex[i/3].x, sizeof(sVERTEX), 1); ***** THERE IS NO NEED FOR /3 HERE ****
}
At least, positive thing is that this hole search kicked my ass to move on to core 300!

Thx
-
KamiGazz
-
- Posts: 8
- Joined: Sun Feb 06, 2011 2:13 am
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 1 guest