Jump to content
  • Advertisement
Sign in to follow this  
scarypajamas

ode collision with nehe lesson 10

This topic is 3711 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

I'm trying to modify NeHe's OpenGL Lesson 10 tutorial to support ODE trimesh collision. I thought it wouldn't be that difficult, what with all the ode examples and all, but I can't seem to get a grip on it. Thanks for taking a look. //setupworld function from nehe lesson 10 void SetupWorld() { float x, y, z, u, v; int numtriangles; FILE *filein; char oneline[255]; filein = fopen("data/world.txt", "rt"); static float world_vertices[108]; //^^^^ could someone explain how to dynamically allocate this ^^^^ static int world_indices; readstr(filein,oneline); sscanf(oneline, "NUMPOLLIES %d\n", &numtriangles); sector1.triangle = new TRIANGLE[numtriangles]; sector1.numtriangles = numtriangles; for (int loop = 0; loop < numtriangles; loop++) { for (int vert = 0; vert < 3; vert++) { readstr(filein,oneline); sscanf(oneline, "%f %f %f %f %f", &x, &y, &z, &u, &v); sector1.triangle[loop].vertex[vert].x = x; sector1.triangle[loop].vertex[vert].y = y; sector1.triangle[loop].vertex[vert].z = z; sector1.triangle[loop].vertex[vert].u = u; sector1.triangle[loop].vertex[vert].v = v; world_vertices[numtriangles] = x; world_vertices[numtriangles+1] = y; world_vertices[numtriangles+2] = z; world_indices++; } } dMatrix3 R; dTriMeshDataID Data = dGeomTriMeshDataCreate(); int numv = sizeof(world_vertices)/(3*sizeof(float)); int numi = sizeof(world_indices)/ sizeof(int); dGeomTriMeshDataBuildSingle ( Data, world_vertices, 3 * sizeof(float), numv, world_indices, numi, 3 * sizeof(int) ); world_mesh = dCreateTriMesh(Space, Data, 0, 0, 0); dGeomTriMeshEnableTC(world_mesh, dSphereClass, false); dGeomTriMeshEnableTC(world_mesh, dBoxClass, false); dGeomSetPosition(world_mesh, 0, 0, 0); dRSetIdentity(R); fclose(filein); return; }

Share this post


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

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!