From 504abd5f0c89234ac3c4c4766bc0effbcefbf355 Mon Sep 17 00:00:00 2001 From: havoc Date: Tue, 22 Jul 2003 20:02:16 +0000 Subject: [PATCH] now loads md3 tags git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@3315 d7cf8633-e32d-0410-b094-e92efae38249 --- model_alias.c | 19 +++++++++++++++++-- model_alias.h | 8 ++++++++ model_shared.h | 8 ++++++-- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/model_alias.c b/model_alias.c index 61ee6507..4488936f 100644 --- a/model_alias.c +++ b/model_alias.c @@ -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)); diff --git a/model_alias.h b/model_alias.h index aa15feaf..ba62714a 100644 --- a/model_alias.h +++ b/model_alias.h @@ -270,5 +270,13 @@ typedef struct aliasmesh_s } aliasmesh_t; +typedef struct aliastag_s +{ + char name[MD3NAME]; + matrix4x4_t matrix; +} +aliastag_t; + + #endif diff --git a/model_shared.h b/model_shared.h index 2de9ec8f..2fc1937d 100644 --- a/model_shared.h +++ b/model_shared.h @@ -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; -- 2.39.2