31#define MAX_ASE_MATERIALS 32
32#define MAX_ASE_OBJECTS 64
33#define MAX_ASE_ANIMATIONS 32
34#define MAX_ASE_ANIMATION_FRAMES 512
36#define VERBOSE(x) { if (ase.verbose) { Com_Printf x; } }
115 ase.verbose = verbose;
120 Sys_Error(
"Could not allocate memory for ase loading");
133 for (
int i = 0;
i <
ase.currentObject;
i++)
139 return ase.currentObject;
149 return pObject->
name;
159 int numFramesInAnimation;
169 for (
f = 0,
i = 0;
i < numFramesInAnimation;
i++) {
181 for (
int k = 0; k < 3; k++) {
183 const int vIdx = pMesh->
faces[t][k];
221 pObject = &
ase.objects[
ase.currentObject];
243 if ((
ase.curpos -
ase.buffer) ==
ase.len)
247 while (
ase.curpos -
ase.buffer <
ase.len && *
ase.curpos <=
' ') {
251 while ((
ase.curpos -
ase.buffer) <
ase.len) {
313 if (
Q_streq(token,
"*BITMAP")) {
321 len = strlen(bitmap) - 1;
331 if (
Q_streq(token,
"*MAP_DIFFUSE"))
337 if (
Q_streq(token,
"*MATERIAL_COUNT")) {
343 ase.numMaterials = 0;
344 }
else if (
Q_streq(token,
"*MATERIAL")) {
345 VERBOSE((
"..material %d ",
ase.numMaterials));
355 if (
Q_streq(token,
"*MESH_VERTEX")) {
370 Sys_Error(
"pMesh->currentVertex >= pMesh->numVertexes");
372 Sys_Error(
"Unknown token '%s' while parsing MESH_VERTEX_LIST", token);
379 if (
Q_streq(token,
"*MESH_FACE")) {
397 if ((p = strstr(
s_token,
"*MESH_MTLID")) != 0) {
398 p += strlen(
"*MESH_MTLID") + 1;
401 Sys_Error(
"No *MESH_MTLID found for face!");
407 Sys_Error(
"Unknown token '%s' while parsing MESH_FACE_LIST", token);
414 if (
Q_streq(token,
"*MESH_TFACE")) {
434 Sys_Error(
"Unknown token '%s' in MESH_TFACE", token);
441 if (
Q_streq(token,
"*MESH_TVERT")) {
442 char u[80],
v[80], w[80];
461 Sys_Error(
"pMesh->currentVertex > pMesh->numTVertexes");
464 Sys_Error(
"Unknown token '%s' while parsing MESH_TVERTLIST", token);
471 if (
Q_streq(token,
"*TIMEVALUE")) {
476 }
else if (
Q_streq(token,
"*MESH_NUMVERTEX")) {
482 }
else if (
Q_streq(token,
"*MESH_NUMFACES")) {
487 }
else if (
Q_streq(token,
"*MESH_NUMTVFACES")) {
491 Sys_Error(
"MESH_NUMTVFACES != MESH_NUMFACES");
492 }
else if (
Q_streq(token,
"*MESH_NUMTVERTEX")) {
497 }
else if (
Q_streq(token,
"*MESH_VERTEX_LIST")) {
500 VERBOSE((
".....parsing MESH_VERTEX_LIST\n"));
502 }
else if (
Q_streq(token,
"*MESH_TVERTLIST")) {
505 VERBOSE((
".....parsing MESH_TVERTLIST\n"));
507 }
else if (
Q_streq(token,
"*MESH_FACE_LIST")) {
510 VERBOSE((
".....parsing MESH_FACE_LIST\n"));
512 }
else if (
Q_streq(token,
"*MESH_TFACELIST")) {
515 VERBOSE((
".....parsing MESH_TFACE_LIST\n"));
517 }
else if (
Q_streq(token,
"*MESH_NORMALS")) {
524 if (
Q_streq(token,
"*NODE_NAME")) {
525 char*
name =
ase.objects[
ase.currentObject].name;
530 if (strchr(
ase.objects[
ase.currentObject].name,
'"'))
531 *strchr(
ase.objects[
ase.currentObject].name,
'"') = 0;
534 while (strchr(
name,
'_') != strrchr(
name,
'_')) {
535 *strrchr(
name,
'_') = 0;
537 while (strrchr(
name,
' ')) {
538 *strrchr(
name,
' ') = 0;
541 }
else if (
Q_streq(token,
"*NODE_PARENT")) {
545 else if (
Q_streq(token,
"*NODE_TM") ||
Q_streq(token,
"*TM_ANIMATION")) {
549 else if (
Q_streq(token,
"*MESH")) {
551 if (strstr(
ase.objects[
ase.currentObject].name,
"tag_") ==
ase.objects[
ase.currentObject].name) {
552 s_forceStaticMesh =
true;
554 s_forceStaticMesh =
false;
561 ase.objects[
ase.currentObject].anim.numFrames =
ase.objects[
ase.currentObject].anim.currentFrame;
562 ase.objects[
ase.currentObject].numAnimations++;
571 else if (
Q_streq(token,
"*MATERIAL_REF")) {
577 else if (
Q_streq(token,
"*MESH_ANIMATION")) {
581 else if (
Q_streq(token,
"*PROP_MOTIONBLUR") ||
Q_streq(token,
"*PROP_CASTSHADOW") ||
Q_streq(token,
"*PROP_RECVSHADOW")) {
592 int numObjects =
ase.currentObject;
594 for (
int i = 0;
i < numObjects;
i++) {
598 if (strstr(
ase.objects[
i].name,
"tag") ==
ase.objects[
i].name)
601 if (!
ase.objects[
i].numAnimations)
604 for (j =
i + 1; j < numObjects; j++) {
605 if (strstr(
ase.objects[j].name,
"tag") ==
ase.objects[j].name)
608 if (
ase.objects[
i].materialRef ==
ase.objects[j].materialRef)
609 if (
ase.objects[j].numAnimations)
631 if (strstr(
ase.objects[
ase.currentObject].name,
"Bip") ||
632 strstr(
ase.objects[
ase.currentObject].name,
"ignore_")) {
634 VERBOSE((
"(discarding BIP/ignore object)\n"));
645 if (!
ase.currentObject)
const char * ASE_GetSurfaceName(int which)
static void ASE_SkipEnclosingBraces(void)
int ASE_GetNumSurfaces(void)
static void ASE_KeyMAP_DIFFUSE(const char *token)
void ASE_Load(const char *filename, bool verbose)
static void ASE_KeyMATERIAL_LIST(const char *token)
static void ASE_Process(void)
static void ASE_KeyMESH(const char *token)
static void ASE_KeyGEOMOBJECT(const char *token)
static void ASE_KeyMESH_VERTEX_LIST(const char *token)
static int CharIsTokenDelimiter(int ch)
static void ASE_SkipRestOfLine(void)
#define MAX_ASE_ANIMATION_FRAMES
static char s_token[1024]
static void ASE_KeyMESH_FACE_LIST(const char *token)
static aseMesh_t * ASE_GetCurrentMesh(void)
static void ASE_ParseBracedBlock(void(*parser)(const char *token))
polyset_t * ASE_GetSurfaceAnimation(int whichSurface)
Returns an animation (sequence of polysets).
static void ConcatenateObjects(aseGeomObject_t *pObjA, aseGeomObject_t *pObjB)
static void ASE_FreeGeomObject(int ndx)
static int ASE_GetToken(bool restOfLine)
static void ASE_KeyMESH_TVERTLIST(const char *token)
#define MAX_ASE_MATERIALS
static void ASE_KeyMATERIAL(const char *token)
static void ASE_KeyTFACE_LIST(const char *token)
static void CollapseObjects(void)
void Com_Printf(const char *const fmt,...)
int FS_FileLength(qFILE *f)
Returns the size of a given file or -1 if no file is opened.
int FS_Read(void *buffer, int len, qFILE *f)
int FS_OpenFile(const char *filename, qFILE *file, filemode_t mode)
Finds and opens the file in the search path.
void Sys_Error(const char *error,...)
#define Mem_AllocTypeN(type, n)
QGL_EXTERN GLuint GLchar GLuint * len
QGL_EXTERN int GLboolean GLfloat * v
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
void Com_StripExtension(const char *in, char *out, const size_t size)
Removes the file extension from a filename.
aseMaterial_t materials[MAX_ASE_MATERIALS]
aseGeomObject_t objects[MAX_ASE_OBJECTS]
contains the animate sequence of a single surface using a single material
aseMesh_t frames[MAX_ASE_ANIMATION_FRAMES]
#define Vector2Set(v, x, y)
#define VectorSet(v, x, y, z)