now loads md3 tags
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 22 Jul 2003 20:02:16 +0000 (20:02 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 22 Jul 2003 20:02:16 +0000 (20:02 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@3315 d7cf8633-e32d-0410-b094-e92efae38249

model_alias.c
model_alias.h
model_shared.h

index 61ee650..4488936 100644 (file)
@@ -723,10 +723,11 @@ void Mod_IDP2_Load(model_t *mod, void *buffer)
 
 void Mod_IDP3_Load(model_t *mod, void *buffer)
 {
-       int i, j, version;
+       int i, j, k, version;
        md3modelheader_t *pinmodel;
        md3frameinfo_t *pinframe;
        md3mesh_t *pinmesh;
+       md3tag_t *pintag;
        aliasmesh_t *mesh;
        skinframe_t tempskinframe;
 
@@ -770,7 +771,21 @@ void Mod_IDP3_Load(model_t *mod, void *buffer)
                loadmodel->animscenes[i].loop = true;
        }
 
-       // tags are not loaded yet
+       // load tags
+       loadmodel->alias.aliasnum_tagframes = loadmodel->numframes;
+       loadmodel->alias.aliasnum_tags = LittleLong(pinmodel->num_tags);
+       loadmodel->alias.aliasdata_tags = Mem_Alloc(loadmodel->mempool, loadmodel->alias.aliasnum_tagframes * loadmodel->alias.aliasnum_tags * sizeof(aliastag_t));
+       for (i = 0, pintag = (md3tag_t *)((qbyte *)pinmodel + LittleLong(pinmodel->lump_tags));i < loadmodel->alias.aliasnum_tagframes * loadmodel->alias.aliasnum_tags;i++, pinframe++)
+       {
+               strcpy(loadmodel->alias.aliasdata_tags[i].name, pintag->name);
+               Matrix4x4_CreateIdentity(&loadmodel->alias.aliasdata_tags[i].matrix);
+               for (j = 0;j < 3;j++)
+               {
+                       for (k = 0;k < 3;k++)
+                               loadmodel->alias.aliasdata_tags[i].matrix.m[k][j] = LittleLong(pintag->rotationmatrix[j * 3 + k]);
+                       loadmodel->alias.aliasdata_tags[i].matrix.m[j][3] = LittleLong(pintag->origin[j]);
+               }
+       }
 
        // load meshes
        loadmodel->alias.aliasdata_meshes = Mem_Alloc(loadmodel->mempool, loadmodel->alias.aliasnum_meshes * sizeof(aliasmesh_t));
index aa15fea..ba62714 100644 (file)
@@ -270,5 +270,13 @@ typedef struct aliasmesh_s
 }
 aliasmesh_t;
 
+typedef struct aliastag_s
+{
+       char name[MD3NAME];
+       matrix4x4_t matrix;
+}
+aliastag_t;
+
+
 #endif
 
index 2de9ec8..2fc1937 100644 (file)
@@ -83,12 +83,12 @@ typedef struct shadowmesh_s
 shadowmesh_t;
 
 
+#include "matrixlib.h"
+
 #include "model_brush.h"
 #include "model_sprite.h"
 #include "model_alias.h"
 
-#include "matrixlib.h"
-
 typedef struct model_alias_s
 {
        // LordHavoc: Q2/ZYM model support
@@ -98,6 +98,10 @@ typedef struct model_alias_s
        int                             aliasnum_meshes;
        aliasmesh_t             *aliasdata_meshes;
 
+       int                             aliasnum_tags;
+       int                             aliasnum_tagframes;
+       aliastag_t              *aliasdata_tags;
+
        // for Zymotic models
        int                             zymnum_verts;
        int                             zymnum_tris;