Diskordia Game Engine
     
About  Me

COMPlusSurvey

Hanibal

Diskordia -3dsLoader

Diskordia-octree space partitioning

 

Current Libs:


  • .3ds model loader library ( a  screen shot of a short demo)

Using this library

  • Include the 3dsmodel.h header into your project
  • Link the loader.lib library into your project
  • eg.
    C3dsModel model;   //create model object
    FILE* fp=fopen("truck.3ds","rb");//open your 3ds file
    model.SetFile(fp); //send the open file to your lib
    model.LoadModel();//load model
    model.Scale(40); //scaling the object optional(don't pass 0)
    CObject* obj=model.objects;//take first object in the list
    CMaterial* material=model.materials;//take material of the first object
    int index=0;
    while(obj)
    {
    glObj.CreateTexture(material->name,index);//use your own bmp texture loader
    obj=obj->next;
    index++;
    material=material->next;
    }

 

  • In your rendering function
    CObject* obj=model.objects;//take first object in the list
    int index=0;
    while(obj)
    {
    _2dPoint* pTexCoord=obj->texCoord;//pointer to the texture coordinates array of this object
    C3dPoint* pVerCoord=obj->vertices;//the same goes with the vertices
    Face*     pFaceIndices=obj->faces;//and the faces
    //using the vertex arrays for fast rendering
    glBindTexture(GL_TEXTURE_2D,glObj.textureArray[index]);//bind this objects'texture
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    glTexCoordPointer(2,GL_FLOAT,0,pTexCoord);
    glEnableClientState(GL_VERTEX_ARRAY);
    glVertexPointer(3,GL_FLOAT,0,pVerCoord);
    glDrawElements(GL_TRIANGLES,obj->nf*3,GL_UNSIGNED_SHORT,pFaceIndices);
    obj=obj->next;
    index++;
    }
    


  • 3dsmodel.h+ Loader.lib