Jump to content
  • Advertisement
Sign in to follow this  

How to traverse trough all geoms in ODE space

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

If you intended to correct an error in the post then please contact us.

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;
    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) )

        // 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;
        float rad, len;

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

            case dCylinderClass:
                dGeomCylinderGetParams( geomID, &rad, &len );
                draw_cylinder( rad, len );

            case dSphereClass:
                rad = dGeomSphereGetRadius( geomID );
                draw_sphere( rad );

            case dCapsuleClass:
                dGeomCapsuleGetParams( geomID, &rad, &len );
                draw_capsule( rad, len );

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

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

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!