ASE loader?

Started by
3 comments, last by juanmanuelsanchez 17 years, 2 months ago
hi all ! Im new to game programing, and I want to find a loader that can "load" mesh and materials from an ASE file. Can someone point me at the right direction? Thanks!
Advertisement
One of the most complete ASE loaders I have seen is part of Paul Nettle's FSRad tool

Apart from that, you can't really go wrong with a good [Google]

http://www.google.com/search?hl=en&q=ase+loader&btnG=Google+Search

Regards,
ViLiO
Richard 'ViLiO' Thomasv.net | Twitter | YouTube
wotsit.org
Bunch of file format description, including ASE ;)
the first thing I tried was google... but didnt find anything usefull. Still looking tho :)
OK Im not going to make another thread for this, the thing is that I got an ASE loader. The problem is that even if the information I get from the file is good all I get is a black window, can anyone help me out?

thanks a lot
bool CGfxOpenGL::Init(){	  //glEnable(GL_LIGHTING);   glShadeModel(GL_SMOOTH);                           // Enable Smooth Shading   glClearColor(0.0f, 0.0f, 0.0f, 0.5f);              // Black Background   glClearDepth(1.0f);                                // Depth Buffer Setup   glDepthFunc(GL_LEQUAL);                            // The Type Of Depth Testing To Do   glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations   glEnable(GL_COLOR_MATERIAL);						  // Enable Coloring Of Material	return true;}void ASE::render() {    if (! loaded)   return;   glPushMatrix();   glScalef(currentScale, currentScale, currentScale);   glCallList(dlist);   glPopMatrix(); }     void ASE::displaylist() {    // Put drawing in the display list   outs("ASE::displaylist",0);   dlist = glGenLists(1);   glNewList(dlist, GL_COMPILE);   draw();   glEndList(); }     void ASE::draw() {   outs("ASE::draw",0);   if (loaded) {     if (currentScale != desiredScale)       setScale(desiredScale);     // Since we know how many objects our model has, go through each of them.	      for (int i=0; i < ASEModel.numOfObjects; i++) {        // Make sure we have valid objects just in case. (size() is in the vector class)       if (ASEModel.pObject.size() <= 0) break;        // Get the current object that we are displaying       tASEObject *pObject = &ASEModel.pObject;        // Check to see if this object has a texture map, if so bind the texture to it.       if (pObject->bHasTexture) {         // Turn on texture mapping and turn off color         glEnable(GL_TEXTURE_2D);         // Reset the color to normal again         glColor3ub(255, 255, 255);         // Bind the texture map to the object by it's materialID        bindTexture2D(ASEModel.pMaterials[pObject->materialID].texureId);     }      else {         // Turn off texture mapping and turn on color        glDisable(GL_TEXTURE_2D);        glEnable(GL_COLOR);         glEnable(GL_COLOR_MATERIAL);          // Reset the color to normal again         glColor3ub(255, 255, 255);       }        glBegin(GL_TRIANGLES);    // Begin drawing with our selected mode (triangles or lines)       outs("pObject->numOfFaces ",pObject->numOfFaces,0);       // Go through all of the faces (polygons) of the object and draw them       for (int j=0; j < pObject->numOfFaces; j++) {		   outs("Triangles: ",j,0);         // Go through each corner of the triangle and draw it.         for (int whichVertex=0; whichVertex < 3; whichVertex++) {           // Get the vertex index for each point of the face           int vertIndex = pObject->pFaces[j].vertIndex[whichVertex];            // Give OpenGL the normal for this vertex.           glNormal3f(pObject->pNormals[ vertIndex ].x, pObject->pNormals[ vertIndex ].y, pObject->pNormals[ vertIndex ].z);            // If the object has a texture associated with it, give it a texture coordinate.           if (pObject->bHasTexture) {            // Make sure there was a UVW map applied to the object or else it won't have tex coords.             if (pObject->pTexVerts) {               // Get the texture coordinate index              int coordIndex = pObject->pFaces[j].coordIndex[whichVertex];                // Assign the UV coordinates to the current vertex being rendered               glTexCoord2f(pObject->pTexVerts[ coordIndex ].x, pObject->pTexVerts[ coordIndex ].y);             }           }          else {             // Make sure there is a valid material/color assigned to this object             if (ASEModel.pMaterials.size() && pObject->materialID >= 0) {               // Get and set the color that the object is, since it must not have a texture               float *pColor = ASEModel.pMaterials[pObject->materialID].fColor;                // Assign the current color to this model               glColor3f(pColor[0], pColor[1], pColor[2]);			              }           }            // Pass in the current vertex of the object (Corner of current face)           glVertex3f(pObject->pVerts[ vertIndex ].x, pObject->pVerts[ vertIndex ].y, pObject->pVerts[ vertIndex ].z);         }       }       glEnd();          // End the drawing       glColor3f(0,0,0);       glDisable(GL_TEXTURE_2D);       glDisable(GL_COLOR_MATERIAL);     }   }   outs("OUT OF ASE::draw",0); }  bool ASE::importModel(tASEModel *pModel) {  // Make sure we have a valid model   if (!pModel || !fp)     return false; outs("ASE::importModel",0);   // let's read in the info!   ReadAseFile(pModel);    // let's compute the vertex normals for lighting   ComputeNormals(pModel);   fclose(fp);   return true; }  void ASE::ReadAseFile(tASEModel *pModel) {   tASEMaterialInfo newMaterial; // This will be used to push on a new material   tASEObject newObject = {0};   // This will be used to push on a new object outs("ASE::ReadAseFile",0);   // This function is the head for reading in the .ase data and information.   // We count the objects then we count the materials.   // Then for each material and each object we read the data in.    // This will return the number of objects stored in the .ase file   pModel->numOfObjects   = GetObjectCount();        // This will return the number of materials stored in the .ase file   pModel->numOfMaterials = GetMaterialCount();      // Go through all the materials and fill in their data and info  for (int i=0; i < pModel->numOfMaterials; i++) {    // Add a new material to our list of materials using the STL "vector" class     pModel->pMaterials.push_back(newMaterial);      // Get the material info for the current material.  We add 1 because we     // want to start at 1 and i starts at 0.     GetTextureInfo(&(pModel->pMaterials), i + 1);   }   // Go through all the objects and fill in their data and info   for (int y=0; y < pModel->numOfObjects; y++) {     // Add a new object to our list of objects using the STL "vector" class     pModel->pObject.push_back(newObject);         // Set the material ID to -1 to initialize it.  This will be changed     // if there is a texture/material assigned to this object.     pModel->pObject[y].materialID = -1;     // Move the file pointer to the desired object.  We add one because our     // object count starts at 1 and i starts at 0    MoveToObject(y + 1);      // Find out the number of vertices, faces and texture coordinates for this object,     // then allocate the memory needed to store that amount that needs to be read in.     ReadObjectInfo(&(pModel->pObject[y]), y + 1);        // Read the vertices, face indices and texture coordinates for this object     ReadObjectData(pModel, &(pModel->pObject[y]), y + 1);     outs("OUT OF ASE::ReadAseFile",0);   }    }


[Edited by - juanmanuelsanchez on January 29, 2007 8:36:27 AM]

This topic is closed to new replies.

Advertisement