Archive for July, 2008

Trimesh is a nice feature for defining the geometry of a body in ODE. You just need a vertices and a faces array. Md3 files encode the faces in CCW and ODE (and OpenGL too) does it in CW. So you need to make the transformation, thus creating a new array of dVector3 (you must do this to unpack the fixed md3 format vertex info).

Here is a llitle piece of code that resumes the proccess: ( GetModel() returns a libmd3_file* )

  libmd3_mesh* meshp;
  meshp = GetModel()->meshes;
 
  int* tri;
  dVector3* triVert;  
 
  tri = (int*) malloc (meshp->mesh_header->triangle_count*sizeof(int));
  triVert = (dVector3*) malloc (meshp->mesh_header->vertex_count*sizeof(dVector3));
 
  std::cout << meshp->mesh_header->triangle_count << std::endl;
  std::cout << meshp->mesh_header->vertex_count << std::endl;
  std::cout << "Faces: ";
  for (int i=0;i < meshp->mesh_header->triangle_count*3; i+=3){
    tri[i+0]=meshp->triangles[i+1];
    tri[i+1]=meshp->triangles[i+2];
    tri[i+2]=meshp->triangles[i+0];
    std::cout << tri[i] << " ";
    std::cout << tri[i+1] << " ";
    std::cout << tri[i+2] << " - ";    
  }
 
  std::cout << " Verts: ";
  for (int i=0;i < meshp->mesh_header->vertex_count; i++){
    triVert[i][0]=meshp->vertices[i*3]*scaleFactor; 
    triVert[i][1]=meshp->vertices[i*3+1]*scaleFactor; 
    triVert[i][2]=meshp->vertices[i*3+2]*scaleFactor; 
    std::cout << "(" << triVert[i][0] << " ";
    std::cout << triVert[i][1] << " ";
    std::cout << triVert[i][2] << ") - ";
 
  }
 
  mtriMesh = dGeomTriMeshDataCreate();
  dGeomTriMeshDataBuildSimple(mtriMesh, (dReal*)triVert, meshp->mesh_header->vertex_count, tri, \
			      meshp->mesh_header->triangle_count);
  mOdeGeom = dCreateTriMesh(sSpace, mtriMesh, NULL, NULL, NULL);
  dGeomSetData(mOdeGeom, (void*)"md3");

Comments No Comments »

lista([]).
lista([_]).
lista([_|_]).
 
concatenar([],X,X).
concatenar([H|T],X,[H|Z]) :- lista(X),concatenar(T,X,Z).
 
invertir([],[]).
invertir([H|T],X) :- lista(X),invertir(T,Y),concatenar(Y,[H],X).
 
longitud([],0).
longitud([H|T],L) :- longitud(T,N), L is N+1.
 
mayor(X,X,X).
mayor(X,Y,X) :- X>Y.
mayor(X,Y,Y) :- Y>X.
 
primero([H|T],H).
 
el_mayor([H|[]],H).
el_mayor([H|T],X) :- el_mayor(T,Z),mayor(H,Z,X).

Comments No Comments »

After looking for a 3D Engine, I’ve choosen to code myself one that fits my needs. The game will be free software, so there no need of a comercial feeling (e.g. packing, hidding … etc.. the fs for the game models, textures, etc…).

At the moment, I’m using:

  • SDL
  • OpenGL (GL and Glu Extensions, not GLUT!)
  • ODE
  • libmd3 (debian package)

There is a lot TO DO:

  • BSP Maps (Blender or GtkRadiant compatible… I still don’t know)
  • Python Scripting
  • Bezier Paths (for the camera tracking)
  • Lots of models
  • Lots of textures
  • Lots of 2D stuff for the non 3D layer (hud, messages, etc…)

If you are interested please contact me.

The project is hosted at: Naves@GoogleCode

Comments No Comments »