Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

aselib.c File Reference

#include "aselib.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>

Include dependency graph for aselib.c:

Include dependency graph

Go to the source code of this file.

Data Structures

struct  ase_t
struct  aseGeomObject_t
struct  aseMaterial_t
struct  aseMesh_t
struct  aseMeshAnimation_t
struct  aseTVertex_t
struct  aseVertex_t

Defines

#define MAX_ASE_ANIMATION_FRAMES   512
#define MAX_ASE_ANIMATIONS   32
#define MAX_ASE_MATERIALS   32
#define MAX_ASE_OBJECTS   64
#define VERBOSE(x)   { if ( ase.verbose ) { printf x ; } }

Typedefs

typedef int aseFace_t [3]

Functions

void ASE_Free (void)
void ASE_FreeGeomObject (int ndx)
aseMesh_tASE_GetCurrentMesh (void)
int ASE_GetNumSurfaces (void)
polyset_tASE_GetSurfaceAnimation (int which, int *pNumFrames, int skipFrameStart, int skipFrameEnd, int maxFrames)
const char * ASE_GetSurfaceName (int which)
int ASE_GetToken (qboolean restOfLine)
void ASE_KeyGEOMOBJECT (const char *token)
void ASE_KeyMAP_DIFFUSE (const char *token)
void ASE_KeyMATERIAL (const char *token)
void ASE_KeyMATERIAL_LIST (const char *token)
void ASE_KeyMESH (const char *token)
void ASE_KeyMESH_ANIMATION (const char *token)
void ASE_KeyMESH_FACE_LIST (const char *token)
void ASE_KeyMESH_TVERTLIST (const char *token)
void ASE_KeyMESH_VERTEX_LIST (const char *token)
void ASE_KeyTFACE_LIST (const char *token)
void ASE_Load (const char *filename, qboolean verbose, qboolean grabAnims)
void ASE_ParseBracedBlock (void(*parser)(const char *token))
void ASE_Process (void)
void ASE_SkipEnclosingBraces (void)
void ASE_SkipRestOfLine (void)
int CharIsTokenDelimiter (int ch)
void CollapseObjects (void)
void ConcatenateObjects (aseGeomObject_t *pObjA, aseGeomObject_t *pObjB)

Variables

ase_t ase
char s_token [1024]


Define Documentation

#define MAX_ASE_ANIMATION_FRAMES   512
 

Definition at line 32 of file aselib.c.

#define MAX_ASE_ANIMATIONS   32
 

Definition at line 31 of file aselib.c.

#define MAX_ASE_MATERIALS   32
 

Definition at line 29 of file aselib.c.

#define MAX_ASE_OBJECTS   64
 

Definition at line 30 of file aselib.c.

#define VERBOSE  )     { if ( ase.verbose ) { printf x ; } }
 

Definition at line 34 of file aselib.c.

Referenced by ASE_KeyGEOMOBJECT(), ASE_KeyMATERIAL_LIST(), ASE_KeyMESH(), ASE_KeyMESH_ANIMATION(), and ASE_Process().


Typedef Documentation

typedef int aseFace_t[3]
 

Definition at line 48 of file aselib.c.

Referenced by ASE_KeyMESH().


Function Documentation

void ASE_Free void   ) 
 

Definition at line 149 of file aselib.c.

References ase, ASE_FreeGeomObject(), ase_t::currentObject, and i.

00150 {
00151     int i;
00152 
00153     for ( i = 0; i < ase.currentObject; i++ )
00154     {
00155         ASE_FreeGeomObject( i );
00156     }
00157 }

Here is the call graph for this function:

void ASE_FreeGeomObject int  ndx  )  [static]
 

Definition at line 258 of file aselib.c.

References aseGeomObject_t::anim, ase, aseMesh_t::faces, aseMeshAnimation_t::frames, free(), i, memset(), aseMeshAnimation_t::numFrames, ase_t::objects, aseMesh_t::tfaces, aseMesh_t::tvertexes, and aseMesh_t::vertexes.

Referenced by ASE_Free(), and ASE_Process().

00259 {
00260     aseGeomObject_t *pObject;
00261     int i;
00262 
00263     pObject = &ase.objects[ndx];
00264 
00265     for ( i = 0; i < pObject->anim.numFrames; i++ )
00266     {
00267         if ( pObject->anim.frames[i].vertexes )
00268         {
00269             free( pObject->anim.frames[i].vertexes );
00270         }
00271         if ( pObject->anim.frames[i].tvertexes )
00272         {
00273             free( pObject->anim.frames[i].tvertexes );
00274         }
00275         if ( pObject->anim.frames[i].faces )
00276         {
00277             free( pObject->anim.frames[i].faces );
00278         }
00279         if ( pObject->anim.frames[i].tfaces )
00280         {
00281             free( pObject->anim.frames[i].tfaces );
00282         }
00283     }
00284 
00285     memset( pObject, 0, sizeof( *pObject ) );
00286 }

Here is the call graph for this function:

aseMesh_t* ASE_GetCurrentMesh void   )  [static]
 

Definition at line 288 of file aselib.c.

References aseGeomObject_t::anim, ase, aseMeshAnimation_t::currentFrame, ase_t::currentObject, Error(), aseMeshAnimation_t::frames, and ase_t::objects.

Referenced by ASE_KeyMESH(), ASE_KeyMESH_ANIMATION(), ASE_KeyMESH_FACE_LIST(), ASE_KeyMESH_TVERTLIST(), ASE_KeyMESH_VERTEX_LIST(), and ASE_KeyTFACE_LIST().

00289 {
00290     aseGeomObject_t *pObject;
00291 
00292     if ( ase.currentObject >= MAX_ASE_OBJECTS )
00293     {
00294         Error( "Too many GEOMOBJECTs" );
00295         return 0; // never called
00296     }
00297 
00298     pObject = &ase.objects[ase.currentObject];
00299 
00300     if ( pObject->anim.currentFrame >= MAX_ASE_ANIMATION_FRAMES )
00301     {
00302         Error( "Too many MESHes" );
00303         return 0;
00304     }
00305 
00306     return &pObject->anim.frames[pObject->anim.currentFrame];
00307 }

Here is the call graph for this function:

int ASE_GetNumSurfaces void   ) 
 

Definition at line 162 of file aselib.c.

References ase, and ase_t::currentObject.

Referenced by InsertASEModel().

00163 {
00164     return ase.currentObject;
00165 }

polyset_t* ASE_GetSurfaceAnimation int  which,
int *  pNumFrames,
int  skipFrameStart,
int  skipFrameEnd,
int  maxFrames
 

Definition at line 185 of file aselib.c.

References aseGeomObject_t::anim, ase, calloc(), f, aseMeshAnimation_t::frames, i, k, aseGeomObject_t::materialRef, ase_t::materials, name, aseGeomObject_t::name, aseMesh_t::numFaces, aseMeshAnimation_t::numFrames, polyset_t::numtriangles, ase_t::objects, pMesh, printf(), strcpy(), t, triangle_t::texcoords, polyset_t::triangles, and triangle_t::verts.

Referenced by InsertASEModel().

00186 {
00187     aseGeomObject_t *pObject = &ase.objects[which];
00188     polyset_t *psets;
00189     int numFramesInAnimation;
00190     int numFramesToKeep;
00191     int i, f;
00192 
00193     if ( !pObject->anim.numFrames )
00194         return 0;
00195 
00196     if ( pObject->anim.numFrames > maxFrames && maxFrames != -1 )
00197     {
00198         numFramesInAnimation = maxFrames;
00199     }
00200     else 
00201     {
00202         numFramesInAnimation = pObject->anim.numFrames;
00203         if ( maxFrames != -1 )
00204             printf( "WARNING: ASE_GetSurfaceAnimation maxFrames > numFramesInAnimation\n" );
00205     }
00206 
00207     if ( skipFrameEnd != -1 )
00208         numFramesToKeep = numFramesInAnimation - ( skipFrameEnd - skipFrameStart + 1 );
00209     else
00210         numFramesToKeep = numFramesInAnimation;
00211 
00212     *pNumFrames = numFramesToKeep;
00213 
00214     psets = calloc( sizeof( polyset_t ) * numFramesToKeep, 1 );
00215 
00216     for ( f = 0, i = 0; i < numFramesInAnimation; i++ )
00217     {
00218         int t;
00219         aseMesh_t *pMesh = &pObject->anim.frames[i];
00220 
00221         if ( skipFrameStart != -1 )
00222         {
00223             if ( i >= skipFrameStart && i <= skipFrameEnd )
00224                 continue;
00225         }
00226 
00227         strcpy( psets[f].name, pObject->name );
00228         strcpy( psets[f].materialname, ase.materials[pObject->materialRef].name );
00229 
00230         psets[f].triangles = calloc( sizeof( triangle_t ) * pObject->anim.frames[i].numFaces, 1 );
00231         psets[f].numtriangles = pObject->anim.frames[i].numFaces;
00232 
00233         for ( t = 0; t < pObject->anim.frames[i].numFaces; t++ )
00234         {
00235             int k;
00236 
00237             for ( k = 0; k < 3; k++ )
00238             {
00239                 psets[f].triangles[t].verts[k][0] = pMesh->vertexes[pMesh->faces[t][k]].x;
00240                 psets[f].triangles[t].verts[k][1] = pMesh->vertexes[pMesh->faces[t][k]].y;
00241                 psets[f].triangles[t].verts[k][2] = pMesh->vertexes[pMesh->faces[t][k]].z;
00242 
00243                 if ( pMesh->tvertexes && pMesh->tfaces )
00244                 {
00245                     psets[f].triangles[t].texcoords[k][0] = pMesh->tvertexes[pMesh->tfaces[t][k]].s;
00246                     psets[f].triangles[t].texcoords[k][1] = pMesh->tvertexes[pMesh->tfaces[t][k]].t;
00247                 }
00248 
00249             }
00250         }
00251 
00252         f++;
00253     }
00254 
00255     return psets;
00256 }

Here is the call graph for this function:

const char* ASE_GetSurfaceName int  which  ) 
 

Definition at line 170 of file aselib.c.

References aseGeomObject_t::anim, ase, aseGeomObject_t::name, aseMeshAnimation_t::numFrames, and ase_t::objects.

Referenced by InsertASEModel().

00171 {
00172     aseGeomObject_t *pObject = &ase.objects[which];
00173 
00174     if ( !pObject->anim.numFrames )
00175         return 0;
00176 
00177     return pObject->name;
00178 }

int ASE_GetToken qboolean  restOfLine  )  [static]
 

Definition at line 316 of file aselib.c.

References ase, ase_t::buffer, CharIsTokenDelimiter(), ase_t::curpos, i, ase_t::len, and s_token.

Referenced by ASE_KeyGEOMOBJECT(), ASE_KeyMAP_DIFFUSE(), ASE_KeyMATERIAL_LIST(), ASE_KeyMESH(), ASE_KeyMESH_FACE_LIST(), ASE_KeyMESH_TVERTLIST(), ASE_KeyMESH_VERTEX_LIST(), ASE_KeyTFACE_LIST(), ASE_ParseBracedBlock(), ASE_Process(), ASE_SkipEnclosingBraces(), and ASE_SkipRestOfLine().

00317 {
00318     int i = 0;
00319 
00320     if ( ase.buffer == 0 )
00321         return 0;
00322 
00323     if ( ( ase.curpos - ase.buffer ) == ase.len )
00324         return 0;
00325 
00326     // skip over crap
00327     while ( ( ( ase.curpos - ase.buffer ) < ase.len ) &&
00328             ( *ase.curpos <= 32 ) )
00329     {
00330         ase.curpos++;
00331     }
00332 
00333     while ( ( ase.curpos - ase.buffer ) < ase.len )
00334     {
00335         s_token[i] = *ase.curpos;
00336 
00337         ase.curpos++;
00338         i++;
00339 
00340         if ( ( CharIsTokenDelimiter( s_token[i-1] ) && !restOfLine ) ||
00341              ( ( s_token[i-1] == '\n' ) || ( s_token[i-1] == '\r' ) ) )
00342         {
00343             s_token[i-1] = 0;
00344             break;
00345         }
00346     }
00347 
00348     s_token[i] = 0;
00349 
00350     return 1;
00351 }

Here is the call graph for this function:

void ASE_KeyGEOMOBJECT const char *  token  )  [static]
 

Definition at line 735 of file aselib.c.

References aseGeomObject_t::anim, ase, ASE_GetToken(), ASE_KeyMESH(), ASE_KeyMESH_ANIMATION(), ASE_ParseBracedBlock(), ASE_SkipEnclosingBraces(), ASE_SkipRestOfLine(), atoi, aseMeshAnimation_t::currentFrame, ase_t::currentObject, Error(), ase_t::grabAnims, aseGeomObject_t::materialRef, aseGeomObject_t::name, name, aseGeomObject_t::numAnimations, aseMeshAnimation_t::numFrames, ase_t::objects, qfalse, qtrue, s_token, strchr(), strcmp(), strcpy(), strrchr(), strstr(), token, and VERBOSE.

Referenced by ASE_Process().

00736 {
00737     if ( !strcmp( token, "*NODE_NAME" ) )
00738     {
00739         char *name = ase.objects[ase.currentObject].name;
00740 
00741         ASE_GetToken( qtrue );
00742         VERBOSE( ( " %s\n", s_token ) );
00743         strcpy( ase.objects[ase.currentObject].name, s_token + 1 );
00744         if ( strchr( ase.objects[ase.currentObject].name, '"' ) )
00745             *strchr( ase.objects[ase.currentObject].name, '"' ) = 0;
00746 
00747         if ( strstr( name, "tag" ) == name )
00748         {
00749             while ( strchr( name, '_' ) != strrchr( name, '_' ) )
00750             {
00751                 *strrchr( name, '_' ) = 0;
00752             }
00753             while ( strrchr( name, ' ' ) )
00754             {
00755                 *strrchr( name, ' ' ) = 0;
00756             }
00757         }
00758     }
00759     else if ( !strcmp( token, "*NODE_PARENT" ) )
00760     {
00761         ASE_SkipRestOfLine();
00762     }
00763     // ignore unused data blocks
00764     else if ( !strcmp( token, "*NODE_TM" ) ||
00765               !strcmp( token, "*TM_ANIMATION" ) )
00766     {
00767         ASE_ParseBracedBlock( 0 );
00768     }
00769     // ignore regular meshes that aren't part of animation
00770     else if ( !strcmp( token, "*MESH" ) && !ase.grabAnims )
00771     {
00772 /*
00773         if ( strstr( ase.objects[ase.currentObject].name, "tag_" ) == ase.objects[ase.currentObject].name ) 
00774         {
00775             s_forceStaticMesh = true;
00776             ASE_ParseBracedBlock( ASE_KeyMESH );
00777             s_forceStaticMesh = false;
00778         }
00779 */
00780         ASE_ParseBracedBlock( ASE_KeyMESH );
00781         if ( ++ase.objects[ase.currentObject].anim.currentFrame == MAX_ASE_ANIMATION_FRAMES )
00782         {
00783             Error( "Too many animation frames" );
00784         }
00785         ase.objects[ase.currentObject].anim.numFrames = ase.objects[ase.currentObject].anim.currentFrame;
00786         ase.objects[ase.currentObject].numAnimations++;
00787 /*
00788         // ignore meshes that aren't part of animations if this object isn't a 
00789         // a tag
00790         else
00791         {
00792             ASE_ParseBracedBlock( 0 );
00793         }
00794 */
00795     }
00796     // according to spec these are obsolete
00797     else if ( !strcmp( token, "*MATERIAL_REF" ) )
00798     {
00799         ASE_GetToken( qfalse );
00800 
00801         ase.objects[ase.currentObject].materialRef = atoi( s_token );
00802     }
00803     // loads a sequence of animation frames
00804     else if ( !strcmp( token, "*MESH_ANIMATION" ) )
00805     {
00806         if ( ase.grabAnims )
00807         {
00808             VERBOSE( ( "..found MESH_ANIMATION\n" ) );
00809 
00810             if ( ase.objects[ase.currentObject].numAnimations )
00811             {
00812                 Error( "Multiple MESH_ANIMATIONS within a single GEOM_OBJECT" );
00813             }
00814             ASE_ParseBracedBlock( ASE_KeyMESH_ANIMATION );
00815             ase.objects[ase.currentObject].anim.numFrames = ase.objects[ase.currentObject].anim.currentFrame;
00816             ase.objects[ase.currentObject].numAnimations++;
00817         }
00818         else
00819         {
00820             ASE_SkipEnclosingBraces();
00821         }
00822     }
00823     // skip unused info
00824     else if ( !strcmp( token, "*PROP_MOTIONBLUR" ) ||
00825               !strcmp( token, "*PROP_CASTSHADOW" ) ||
00826               !strcmp( token, "*PROP_RECVSHADOW" ) )
00827     {
00828         ASE_SkipRestOfLine();
00829     }
00830 }

Here is the call graph for this function:

void ASE_KeyMAP_DIFFUSE const char *  token  )  [static]
 

Definition at line 405 of file aselib.c.

References ase, ASE_GetToken(), buffer, gamedir, i, ase_t::materials, ase_t::numMaterials, printf(), qfalse, s_token, sprintf(), strchr(), strcmp(), strcpy(), strlen(), strlwr(), strstr(), and token.

Referenced by ASE_KeyMATERIAL().

00406 {
00407     char buffer[1024], buff1[1024], buff2[1024];
00408   char *buf1, *buf2;
00409     int i = 0, count;
00410 
00411     if ( !strcmp( token, "*BITMAP" ) )
00412     {
00413         ASE_GetToken( qfalse );
00414 
00415         strcpy( buffer, s_token + 1 );
00416         if ( strchr( buffer, '"' ) )
00417             *strchr( buffer, '"' ) = 0;
00418 
00419         while ( buffer[i] )
00420         {
00421             if ( buffer[i] == '\\' )
00422                 buffer[i] = '/';
00423             i++;
00424         }
00425 
00426     buf1 = buffer;
00427     buf2 = gamedir;
00428     // need to compare win32 volumes to potential unix junk
00429     // 
00430     if ( (gamedir[1] == ':' && (buffer[0] == '/' && buffer[1] == '/')) ||
00431       (buffer[1] == ':' && (gamedir[0] == '/' && gamedir[1] == '/')) ) {
00432       if (buffer[1] == ':') {
00433         buf1 = buffer + 2;
00434         buf2 = gamedir + 2;
00435       } else {
00436         buf1 = gamedir + 2;
00437         buf2 = buffer +2;
00438       }
00439       count = 0;
00440       while (*buf2 && count < 2) {
00441         if (*buf2 == '/') {
00442           count++;
00443         }
00444         buf2++;
00445       }
00446     } 
00447     strcpy(buff1, buf1);
00448     strlwr(buff1);
00449     strcpy(buff2, buf2);
00450     strlwr(buff2);
00451     if ( strstr( buff2, buff1 + 2 ) )
00452         {
00453             strcpy( ase.materials[ase.numMaterials].name, strstr( buff2, buff1 + 2 ) + strlen( buff1 ) - 2 );
00454         }
00455         else
00456         {
00457             sprintf( ase.materials[ase.numMaterials].name, "(not converted: '%s')", buffer );
00458             printf( "WARNING: illegal material name '%s'\n", buffer );
00459         }
00460     }
00461     else
00462     {
00463     }
00464 }

Here is the call graph for this function:

void ASE_KeyMATERIAL const char *  token  )  [static]
 

Definition at line 466 of file aselib.c.

References ASE_KeyMAP_DIFFUSE(), ASE_ParseBracedBlock(), strcmp(), and token.

Referenced by ASE_KeyMATERIAL_LIST().

00467 {
00468     if ( !strcmp( token, "*MAP_DIFFUSE" ) )
00469     {
00470         ASE_ParseBracedBlock( ASE_KeyMAP_DIFFUSE );
00471     }
00472     else
00473     {
00474     }
00475 }

Here is the call graph for this function:

void ASE_KeyMATERIAL_LIST const char *  token  )  [static]
 

Definition at line 477 of file aselib.c.

References ase, ASE_GetToken(), ASE_KeyMATERIAL(), ASE_ParseBracedBlock(), atoi, Error(), ase_t::numMaterials, qfalse, s_token, strcmp(), token, and VERBOSE.

Referenced by ASE_Process().

00478 {
00479     if ( !strcmp( token, "*MATERIAL_COUNT" ) )
00480     {
00481         ASE_GetToken( qfalse );
00482         VERBOSE( ( "..num materials: %s\n", s_token ) );
00483         if ( atoi( s_token ) > MAX_ASE_MATERIALS )
00484         {
00485             Error( "Too many materials!" );
00486         }
00487         ase.numMaterials = 0;
00488     }
00489     else if ( !strcmp( token, "*MATERIAL" ) )
00490     {
00491         VERBOSE( ( "..material %d ", ase.numMaterials ) );
00492         ASE_ParseBracedBlock( ASE_KeyMATERIAL );
00493         ase.numMaterials++;
00494     }
00495 }

Here is the call graph for this function:

void ASE_KeyMESH const char *  token  )  [static]
 

Definition at line 633 of file aselib.c.

References ASE_GetCurrentMesh(), ASE_GetToken(), ASE_KeyMESH_FACE_LIST(), ASE_KeyMESH_TVERTLIST(), ASE_KeyMESH_VERTEX_LIST(), ASE_KeyTFACE_LIST(), ASE_ParseBracedBlock(), aseFace_t, atoi, calloc(), Error(), pMesh, qfalse, s_token, strcmp(), token, and VERBOSE.

Referenced by ASE_KeyGEOMOBJECT(), and ASE_KeyMESH_ANIMATION().

00634 {
00635     aseMesh_t *pMesh = ASE_GetCurrentMesh();
00636 
00637     if ( !strcmp( token, "*TIMEVALUE" ) )
00638     {
00639         ASE_GetToken( qfalse );
00640 
00641         pMesh->timeValue = atoi( s_token );
00642         VERBOSE( ( ".....timevalue: %d\n", pMesh->timeValue ) );
00643     }
00644     else if ( !strcmp( token, "*MESH_NUMVERTEX" ) )
00645     {
00646         ASE_GetToken( qfalse );
00647 
00648         pMesh->numVertexes = atoi( s_token );
00649         VERBOSE( ( ".....TIMEVALUE: %d\n", pMesh->timeValue ) );
00650         VERBOSE( ( ".....num vertexes: %d\n", pMesh->numVertexes ) );
00651     }
00652     else if ( !strcmp( token, "*MESH_NUMFACES" ) )
00653     {
00654         ASE_GetToken( qfalse );
00655 
00656         pMesh->numFaces = atoi( s_token );
00657         VERBOSE( ( ".....num faces: %d\n", pMesh->numFaces ) );
00658     }
00659     else if ( !strcmp( token, "*MESH_NUMTVFACES" ) )
00660     {
00661         ASE_GetToken( qfalse );
00662 
00663         if ( atoi( s_token ) != pMesh->numFaces )
00664         {
00665             Error( "MESH_NUMTVFACES != MESH_NUMFACES" );
00666         }
00667     }
00668     else if ( !strcmp( token, "*MESH_NUMTVERTEX" ) )
00669     {
00670         ASE_GetToken( qfalse );
00671 
00672         pMesh->numTVertexes = atoi( s_token );
00673         VERBOSE( ( ".....num tvertexes: %d\n", pMesh->numTVertexes ) );
00674     }
00675     else if ( !strcmp( token, "*MESH_VERTEX_LIST" ) )
00676     {
00677         pMesh->vertexes = calloc( sizeof( aseVertex_t ) * pMesh->numVertexes, 1 );
00678         pMesh->currentVertex = 0;
00679         VERBOSE( ( ".....parsing MESH_VERTEX_LIST\n" ) );
00680         ASE_ParseBracedBlock( ASE_KeyMESH_VERTEX_LIST );
00681     }
00682     else if ( !strcmp( token, "*MESH_TVERTLIST" ) )
00683     {
00684         pMesh->currentVertex = 0;
00685         pMesh->tvertexes = calloc( sizeof( aseTVertex_t ) * pMesh->numTVertexes, 1 );
00686         VERBOSE( ( ".....parsing MESH_TVERTLIST\n" ) );
00687         ASE_ParseBracedBlock( ASE_KeyMESH_TVERTLIST );
00688     }
00689     else if ( !strcmp( token, "*MESH_FACE_LIST" ) )
00690     {
00691         pMesh->faces = calloc( sizeof( aseFace_t ) * pMesh->numFaces, 1 );
00692         pMesh->currentFace = 0;
00693         VERBOSE( ( ".....parsing MESH_FACE_LIST\n" ) );
00694         ASE_ParseBracedBlock( ASE_KeyMESH_FACE_LIST );
00695     }
00696     else if ( !strcmp( token, "*MESH_TFACELIST" ) )
00697     {
00698         pMesh->tfaces = calloc( sizeof( aseFace_t ) * pMesh->numFaces, 1 );
00699         pMesh->currentFace = 0;
00700         VERBOSE( ( ".....parsing MESH_TFACE_LIST\n" ) );
00701         ASE_ParseBracedBlock( ASE_KeyTFACE_LIST );
00702     }
00703     else if ( !strcmp( token, "*MESH_NORMALS" ) )
00704     {
00705         ASE_ParseBracedBlock( 0 );
00706     }
00707 }

Here is the call graph for this function:

void ASE_KeyMESH_ANIMATION const char *  token  )  [static]
 

Definition at line 709 of file aselib.c.

References aseGeomObject_t::anim, ase, ASE_GetCurrentMesh(), ASE_KeyMESH(), ASE_ParseBracedBlock(), assert, aseMeshAnimation_t::currentFrame, ase_t::currentObject, Error(), memset(), ase_t::objects, pMesh, strcmp(), token, and VERBOSE.

Referenced by ASE_KeyGEOMOBJECT().

00710 {
00711     aseMesh_t *pMesh = ASE_GetCurrentMesh();
00712 
00713     // loads a single animation frame
00714     if ( !strcmp( token, "*MESH" ) )
00715     {
00716         VERBOSE( ( "...found MESH\n" ) );
00717         assert( pMesh->faces == 0 );
00718         assert( pMesh->vertexes == 0 );
00719         assert( pMesh->tvertexes == 0 );
00720         memset( pMesh, 0, sizeof( *pMesh ) );
00721 
00722         ASE_ParseBracedBlock( ASE_KeyMESH );
00723 
00724         if ( ++ase.objects[ase.currentObject].anim.currentFrame == MAX_ASE_ANIMATION_FRAMES )
00725         {
00726             Error( "Too many animation frames" );
00727         }
00728     }
00729     else
00730     {
00731         Error( "Unknown token '%s' while parsing MESH_ANIMATION", token );
00732     }
00733 }

Here is the call graph for this function:

void ASE_KeyMESH_FACE_LIST const char *  token  )  [static]
 

Definition at line 527 of file aselib.c.

References ASE_GetCurrentMesh(), ASE_GetToken(), atoi, Error(), pMesh, qfalse, qtrue, s_token, strcmp(), and token.

Referenced by ASE_KeyMESH().

00528 {
00529     aseMesh_t *pMesh = ASE_GetCurrentMesh();
00530 
00531     if ( !strcmp( token, "*MESH_FACE" ) )
00532     {
00533         ASE_GetToken( qfalse ); // skip face number
00534 
00535         ASE_GetToken( qfalse ); // skip label
00536         ASE_GetToken( qfalse ); // first vertex
00537         pMesh->faces[pMesh->currentFace][0] = atoi( s_token );
00538 
00539         ASE_GetToken( qfalse ); // skip label
00540         ASE_GetToken( qfalse ); // second vertex
00541         pMesh->faces[pMesh->currentFace][2] = atoi( s_token );
00542 
00543         ASE_GetToken( qfalse ); // skip label
00544         ASE_GetToken( qfalse ); // third vertex
00545         pMesh->faces[pMesh->currentFace][1] = atoi( s_token );
00546 
00547         ASE_GetToken( qtrue );
00548 
00549 /*
00550         if ( ( p = strstr( s_token, "*MESH_MTLID" ) ) != 0 )
00551         {
00552             p += strlen( "*MESH_MTLID" ) + 1;
00553             mtlID = atoi( p );
00554         }
00555         else
00556         {
00557             Error( "No *MESH_MTLID found for face!" );
00558         }
00559 */
00560 
00561         pMesh->currentFace++;
00562     }
00563     else
00564     {
00565         Error( "Unknown token '%s' while parsing MESH_FACE_LIST", token );
00566     }
00567 }

Here is the call graph for this function:

void ASE_KeyMESH_TVERTLIST const char *  token  )  [static]
 

Definition at line 598 of file aselib.c.

References ASE_GetCurrentMesh(), ASE_GetToken(), atof(), Error(), pMesh, qfalse, s_token, strcmp(), strcpy(), token, v, and w.

Referenced by ASE_KeyMESH().

00599 {
00600     aseMesh_t *pMesh = ASE_GetCurrentMesh();
00601 
00602     if ( !strcmp( token, "*MESH_TVERT" ) )
00603     {
00604         char u[80], v[80], w[80];
00605 
00606         ASE_GetToken( qfalse );
00607 
00608         ASE_GetToken( qfalse );
00609         strcpy( u, s_token );
00610 
00611         ASE_GetToken( qfalse );
00612         strcpy( v, s_token );
00613 
00614         ASE_GetToken( qfalse );
00615         strcpy( w, s_token );
00616 
00617         pMesh->tvertexes[pMesh->currentVertex].s = atof( u );
00618         pMesh->tvertexes[pMesh->currentVertex].t = 1.0f - atof( v );
00619 
00620         pMesh->currentVertex++;
00621 
00622         if ( pMesh->currentVertex > pMesh->numTVertexes )
00623         {
00624             Error( "pMesh->currentVertex > pMesh->numTVertexes" );
00625         }
00626     }
00627     else
00628     {
00629         Error( "Unknown token '%s' while parsing MESH_TVERTLIST" );
00630     }
00631 }

Here is the call graph for this function:

void ASE_KeyMESH_VERTEX_LIST const char *  token  )  [static]
 

Definition at line 497 of file aselib.c.

References ASE_GetCurrentMesh(), ASE_GetToken(), atof(), Error(), pMesh, qfalse, s_token, strcmp(), and token.

Referenced by ASE_KeyMESH().

00498 {
00499     aseMesh_t *pMesh = ASE_GetCurrentMesh();
00500 
00501     if ( !strcmp( token, "*MESH_VERTEX" ) )
00502     {
00503         ASE_GetToken( qfalse );     // skip number
00504 
00505         ASE_GetToken( qfalse );
00506         pMesh->vertexes[pMesh->currentVertex].y = atof( s_token );
00507 
00508         ASE_GetToken( qfalse );
00509         pMesh->vertexes[pMesh->currentVertex].x = -atof( s_token );
00510 
00511         ASE_GetToken( qfalse );
00512         pMesh->vertexes[pMesh->currentVertex].z = atof( s_token );
00513 
00514         pMesh->currentVertex++;
00515 
00516         if ( pMesh->currentVertex > pMesh->numVertexes )
00517         {
00518             Error( "pMesh->currentVertex >= pMesh->numVertexes" );
00519         }
00520     }
00521     else
00522     {
00523         Error( "Unknown token '%s' while parsing MESH_VERTEX_LIST", token );
00524     }
00525 }

Here is the call graph for this function:

void ASE_KeyTFACE_LIST const char *  token  )  [static]
 

Definition at line 569 of file aselib.c.

References a, ASE_GetCurrentMesh(), ASE_GetToken(), atoi, b, c, Error(), pMesh, qfalse, s_token, strcmp(), and token.

Referenced by ASE_KeyMESH().

00570 {
00571     aseMesh_t *pMesh = ASE_GetCurrentMesh();
00572 
00573     if ( !strcmp( token, "*MESH_TFACE" ) )
00574     {
00575         int a, b, c;
00576 
00577         ASE_GetToken( qfalse );
00578 
00579         ASE_GetToken( qfalse );
00580         a = atoi( s_token );
00581         ASE_GetToken( qfalse );
00582         c = atoi( s_token );
00583         ASE_GetToken( qfalse );
00584         b = atoi( s_token );
00585 
00586         pMesh->tfaces[pMesh->currentFace][0] = a;
00587         pMesh->tfaces[pMesh->currentFace][1] = b;
00588         pMesh->tfaces[pMesh->currentFace][2] = c;
00589 
00590         pMesh->currentFace++;
00591     }
00592     else
00593     {
00594         Error( "Unknown token '%s' in MESH_TFACE", token );
00595     }
00596 }

Here is the call graph for this function:

void ASE_Load const char *  filename,
qboolean  verbose,
qboolean  grabAnims
 

Definition at line 118 of file aselib.c.

References ase, ASE_Process(), ase_t::buffer, ase_t::curpos, Error(), fclose(), fopen(), fp, fread(), ase_t::grabAnims, ase_t::len, malloc(), memset(), printf(), Q_filelength(), and ase_t::verbose.

Referenced by InsertASEModel().

00119 {
00120     FILE *fp = fopen( filename, "rb" );
00121 
00122     if ( !fp )
00123         Error( "File not found '%s'", filename );
00124 
00125     memset( &ase, 0, sizeof( ase ) );
00126 
00127     ase.verbose = verbose;
00128     ase.grabAnims = grabAnims;
00129     ase.len = Q_filelength( fp );
00130 
00131     ase.curpos = ase.buffer = malloc( ase.len );
00132 
00133     printf( "Processing '%s'\n", filename );
00134 
00135     if (