A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by g0bl1n » Fri Nov 05, 2010 12:02 am
I'm having a problem integrating Newton with Irrlicht. I'm using the most up to date version of both engines. I've gotten both engines to work with each other fairly well. I've gone through a lot of tutorials and one in particular was a great help. However for some reason if I create a body above my level mesh body, the created body freezes in mid air before colliding with the level mesh body. However if the create body collides with another body, or with the level at any point, they work perfectly fine. I've gone through my code several times, but I have yet to come up with a solution.
Here is my source.
P.S.
If all you see is a white screen, move you mouse, I forgot to set the camera's target!!!
-
g0bl1n
-
- Posts: 5
- Joined: Thu Nov 04, 2010 11:09 pm
by Julio Jerez » Fri Nov 05, 2010 2:40 am
has you implemned deguf display, it may be tha yous static mesh is in a wrong place.
-
Julio Jerez
- Moderator

-
- Posts: 12452
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by g0bl1n » Fri Nov 05, 2010 11:38 am
That doesn't explain why when the bodys finally collide with the mesh they act normally, or if they collide with each other they act normally. Sometimes if I create them in the air, they work sometimes, others not. It must be a uninitialized variable or something along those lines. I've tried several different test levels to no avail.
I keep on going through the code and I cannot find anything that I left out, I know its there somewhere, but I'm completely stumped!
-
g0bl1n
-
- Posts: 5
- Joined: Thu Nov 04, 2010 11:09 pm
by Julio Jerez » Fri Nov 05, 2010 2:08 pm
not it does not but it let you see what the physics is doing.
Debug display is your freind
-
Julio Jerez
- Moderator

-
- Posts: 12452
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by g0bl1n » Fri Nov 05, 2010 7:01 pm
Oh there is an actual debug display? I had no idea, can you point me in the direction of a tutorial or an example? I looked through the headers and found a few debug commands, but I can't find very much documentation, or I I'm just not searching for the right keywords. Does the debug mode draw the edges and all that jazz? Or is it just text based? Or is it however I program it?
-
g0bl1n
-
- Posts: 5
- Joined: Thu Nov 04, 2010 11:09 pm
by Julio Jerez » Fri Nov 05, 2010 10:14 pm
ther are not graphics funtion in the engine, whe you get are utility funtion that you cna use to render th ephysics geometry
here is and example
- Code: Select all
static void DebugSubmitGeometryCollision (void* userData, int vertexCount, const dFloat* faceVertec, int id)
{
id;
int i = vertexCount - 1;
dVector p0 (faceVertec[i * 3 + 0], faceVertec[i * 3 + 1], faceVertec[i * 3 + 2]);
dVector color(1, 1, 1, 1);
if (userData) {
color = *((dVector*)userData);
}
for (int i = 0; (i < vertexCount) && (debugPointsCount < MAX_DEBUG_CONTACTS); i ++) {
dVector p1 (faceVertec[i * 3 + 0], faceVertec[i * 3 + 1], faceVertec[i * 3 + 2]);
debugDisplayList[debugPointsCount].m_color = color;
debugDisplayList[debugPointsCount].m_p0 = p0;
debugDisplayList[debugPointsCount].m_p1 = p1;
debugDisplayList[debugPointsCount].m_isContact = false;
debugPointsCount ++;
p0 = p1;
}
}
void DebugDrawCollision (const NewtonCollision* collision, dMatrix& matrix, dVector color)
{
NewtonCollisionForEachPolygonDo (collision, &matrix[0][0], DebugSubmitGeometryCollision, &color);
}
void DebugShowBodyCollision (const NewtonBody* body, void* userData)
{
dMatrix matrix;
NewtonBodyGetMatrix(body, &matrix[0][0]);
NewtonCollisionForEachPolygonDo (NewtonBodyGetCollision(body), &matrix[0][0], DebugShowGeometryCollision, NULL);
}
void DebugRenderWorldCollision (const NewtonWorld* world)
{
glDisable (GL_LIGHTING);
glDisable(GL_TEXTURE_2D);
dVector aabbP0 (-1000.0f, -500.0f, -1000.0f);
dVector aabbP1 (1000.0f, 500.0f, 1000.0f);
glColor3f(1.0f, 1.0f, 1.0f);
glBegin(GL_LINES);
NewtonWorldForEachBodyInAABBDo (world, &aabbP0[0], &aabbP1[0], DebugShowBodyCollision, NULL);
glEnd();
}
function DebugRenderWorldCollision (const NewtonWorld* world)
will render teh comple work in wire frame in open GL.
will display hwo the collision geometry looks like
-
Julio Jerez
- Moderator

-
- Posts: 12452
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by g0bl1n » Sat Nov 06, 2010 3:42 am
I haven't implemented the debug view yet, but while I was doing it I noticed something. If I create a body at 0,0,0; then the body will rise up to 0,100,0 like it is colliding with the level. Just thought I would bring it up, maybe that will help narrow the problem down!
-
g0bl1n
-
- Posts: 5
- Joined: Thu Nov 04, 2010 11:09 pm
by Julio Jerez » Sat Nov 06, 2010 8:45 am
Ha maybe you did no set the world size.
the default world size is a box of 100 x 100 x 100
whne a body go outrsize that box it will stop
if you implemnetd the NewtonSetBodyLeaveWorldEvent, the engine will call tha funtion whn th body leave teh world
-
Julio Jerez
- Moderator

-
- Posts: 12452
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by g0bl1n » Sat Nov 06, 2010 4:28 pm
I set the world size, it's quite large! I'm having some troubles implementing the debug mode, most of the variables are not declared and I'm working through it, so it may be a little bit before I get it implemented.
-
g0bl1n
-
- Posts: 5
- Joined: Thu Nov 04, 2010 11:09 pm
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 73 guests