Jump to content
  • Advertisement
Sign in to follow this  

ASE loader?

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

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()

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)
glScalef(currentScale, currentScale, currentScale);

void ASE::displaylist()
// Put drawing in the display list
dlist = glGenLists(1);
glNewList(dlist, GL_COMPILE);

void ASE::draw()

if (loaded) {
if (currentScale != 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

// Reset the color to normal again
glColor3ub(255, 255, 255);

// Bind the texture map to the object by it's materialID
else {
// Turn off texture mapping and turn on color

// 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
outs("OUT OF ASE::draw",0);

bool ASE::importModel(tASEModel *pModel)
// Make sure we have a valid model
if (!pModel || !fp)
return false;
// let's read in the info!

// let's compute the vertex normals for lighting

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

// 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

// 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

// 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]

Share this post

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

  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!