# How to traverse trough all geoms in ODE space

This topic is 3332 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

The space has only static geometry (geoms with no bodies). How to loop trough all geoms? This code doesn't render anything:
void physics_render()
{
const dReal *realPos;
const dReal *realRot;
GLfloat matrix[16];
dGeomID geomID;

glPushAttrib( GL_POLYGON_BIT|GL_ENABLE_BIT );
glDisable( GL_LIGHTING );
glDisable( GL_TEXTURE_2D );
glDisable( GL_DEPTH_TEST );
glDisable( GL_ALPHA_TEST );
glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
glColor3f( 1.0f, 1.0f, 1.0f );

for( geomID=dGeomGetBodyNext((dGeomID)globals.physics.map_space); geomID != 0; geomID=dGeomGetBodyNext((dGeomID)globals.physics.map_space) )
{
glPushMatrix();

// get data
realPos = dGeomGetPosition( geomID );
realRot = dGeomGetRotation( geomID );

// create a matrix
matrix[0]=  realRot[0];
matrix[1]=  realRot[4];
matrix[2]=  realRot[8];
matrix[3]=  0.0f;
matrix[4]=  realRot[1];
matrix[5]=  realRot[5];
matrix[6]=  realRot[9];
matrix[7]=  0.0f;
matrix[8]=  realRot[2];
matrix[9]=  realRot[6];
matrix[10]= realRot[10];
matrix[11]= 0.0f;
matrix[12]= realPos[0]; // x position
matrix[13]= realPos[1]; // y pos
matrix[14]= realPos[2]; // z pos
matrix[15]= 1.0f;

// multiply the current modelview matrix with this one
glMultMatrixf( (const GLfloat *) &matrix );

int type = dGeomGetClass( geomID );
dVector3 size;

switch( type )
{
case dBoxClass:
dGeomBoxGetLengths( geomID, size );
draw_box( size[0], size[1], size[2] );
break;

case dCylinderClass:
break;

case dSphereClass:
break;

case dCapsuleClass:
break;

default:
fprintf( stderr, "TODO: rendering code for uknown ODE geometry @ physics.c:physics_render()\n" );
break;
}

glPopMatrix();
}

glPopAttrib();
}

The problem is, that the for-loop is never executed.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 13
• 9
• 15
• 14
• 46
• ### Forum Statistics

• Total Topics
634058
• Total Posts
3015289
×