Sign in to follow this  

ode collision with nehe lesson 10

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this