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; } }
111 Sys_Error(
"File not found '%s'", filename);
120 Sys_Error(
"Could not allocate memory for ase loading");
125 Sys_Error(
"fread() != -1 for '%s'", filename);
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];
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")) {
344 }
else if (
Q_streq(token,
"*MATERIAL")) {
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")) {
533 if (strstr(name,
"tag") == name) {
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")) {
552 s_forceStaticMesh =
true;
554 s_forceStaticMesh =
false;
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")) {
594 for (
int i = 0;
i < numObjects;
i++) {
604 for (j =
i + 1; j < numObjects; j++) {
634 VERBOSE((
"(discarding BIP/ignore object)\n"));
static void ASE_KeyMATERIAL(const char *token)
static void ASE_KeyTFACE_LIST(const char *token)
#define Mem_AllocTypeN(type, n)
void Sys_Error(const char *error,...)
#define VectorSet(v, x, y, z)
static void CollapseObjects(void)
int FS_OpenFile(const char *filename, qFILE *file, filemode_t mode)
Finds and opens the file in the search path.
aseMesh_t frames[MAX_ASE_ANIMATION_FRAMES]
static void ASE_KeyMESH_VERTEX_LIST(const char *token)
void Com_StripExtension(const char *in, char *out, const size_t size)
Removes the file extension from a filename.
static void ASE_KeyMAP_DIFFUSE(const char *token)
contains the animate sequence of a single surface using a single material
static void ASE_ParseBracedBlock(void(*parser)(const char *token))
static void ASE_SkipEnclosingBraces(void)
void Com_Printf(const char *const fmt,...)
void ASE_Load(const char *filename, bool verbose)
static void ConcatenateObjects(aseGeomObject_t *pObjA, aseGeomObject_t *pObjB)
static void ASE_KeyMESH_FACE_LIST(const char *token)
static void ASE_KeyMESH_TVERTLIST(const char *token)
#define MAX_ASE_MATERIALS
polyset_t * ASE_GetSurfaceAnimation(int whichSurface)
Returns an animation (sequence of polysets)
static aseMesh_t * ASE_GetCurrentMesh(void)
static void ASE_Process(void)
#define Vector2Set(v, x, y)
static int CharIsTokenDelimiter(int ch)
const char * ASE_GetSurfaceName(int which)
static char s_token[1024]
#define MAX_ASE_ANIMATION_FRAMES
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 ASE_GetNumSurfaces(void)
QGL_EXTERN GLuint GLchar GLuint * len
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
aseMaterial_t materials[MAX_ASE_MATERIALS]
static void ASE_KeyMESH(const char *token)
static void ASE_FreeGeomObject(int ndx)
static int ASE_GetToken(bool restOfLine)
static void ASE_KeyGEOMOBJECT(const char *token)
QGL_EXTERN int GLboolean GLfloat * v
aseGeomObject_t objects[MAX_ASE_OBJECTS]
static void ASE_SkipRestOfLine(void)
static void ASE_KeyMATERIAL_LIST(const char *token)