UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
r_model_alias.h File Reference

Shared alias model functions. More...

Go to the source code of this file.

Data Structures

struct  mAliasVertex_s
 
struct  mAliasComplexVertex_s
 
struct  mAliasBoneMatrix_s
 
struct  mAliasBoneVertex_s
 
struct  mAliasFrame_s
 
struct  mAliasTagOrientation_s
 
struct  mAliasTag_s
 
struct  mAliasSkin_s
 
struct  mIndexList_s
 
struct  mAliasMesh_s
 
struct  mAliasAnim_s
 
struct  mAliasBone_s
 
struct  mAliasModel_s
 

Macros

#define MODEL_MAX_PATH   64
 
#define MAX_ALIAS_TRIS   4096
 
#define MAX_ALIAS_VERTS   8192
 
#define mAliasCoord_t   vec2_t
 
#define MAX_ANIMS   128
 
#define MAX_ANIMNAME   16
 

Typedefs

typedef struct mAliasVertex_s mAliasVertex_t
 
typedef struct
mAliasComplexVertex_s 
mAliasComplexVertex_t
 
typedef struct mAliasBoneMatrix_s mAliasBoneMatrix_t
 
typedef struct mAliasBoneVertex_s mAliasBoneVertex_t
 
typedef struct mAliasFrame_s mAliasFrame_t
 
typedef struct
mAliasTagOrientation_s 
mAliasTagOrientation_t
 
typedef struct mAliasTag_s mAliasTag_t
 
typedef struct mAliasSkin_s mAliasSkin_t
 
typedef struct mIndexList_s mIndexList_t
 
typedef struct mAliasMesh_s mAliasMesh_t
 
typedef struct mAliasAnim_s mAliasAnim_t
 
typedef struct mAliasBone_s mAliasBone_t
 
typedef struct mAliasModel_s mAliasModel_t
 

Functions

void R_ModLoadAnims (mAliasModel_t *mod, const char *animname)
 
bool R_ModLoadMDX (struct model_s *mod)
 Tries to load a mdx file that contains the normals and the tangents for a model. More...
 
void R_ModCalcUniqueNormalsAndTangents (mAliasMesh_t *mesh, int nFrames, float smoothness)
 Calculates normals and tangents for all frames and does vertex merging based on smoothness. More...
 
void R_FillArrayData (mAliasModel_t *mod, mAliasMesh_t *mesh, float backlerp, int framenum, int oldframenum, bool prerender)
 Converts the model data into the opengl arrays. More...
 
void R_ModLoadArrayData (mAliasModel_t *mod, mAliasMesh_t *mesh, bool loadNormals)
 Allocates data arrays for animated models. Only called once at loading time. More...
 

Detailed Description

Shared alias model functions.

Definition in file r_model_alias.h.

Macro Definition Documentation

#define MAX_ALIAS_TRIS   4096
#define MAX_ANIMNAME   16

Definition at line 130 of file r_model_alias.h.

#define MAX_ANIMS   128

Definition at line 129 of file r_model_alias.h.

Referenced by R_ModLoadAnims().

#define MODEL_MAX_PATH   64

Definition at line 28 of file r_model_alias.h.

Referenced by R_ModLoadAliasMD3Model().

Typedef Documentation

typedef struct mAliasAnim_s mAliasAnim_t
typedef struct mAliasBone_s mAliasBone_t
typedef struct mAliasFrame_s mAliasFrame_t
typedef struct mAliasMesh_s mAliasMesh_t
typedef struct mAliasModel_s mAliasModel_t
typedef struct mAliasSkin_s mAliasSkin_t
typedef struct mAliasTag_s mAliasTag_t

A tag is a reference point that allows us to place other (child-)meshes to that particular location.

The tag has a rotation and a translation vector on a per-frame base. This allows us to place e.g. weapons onto the tag_rweapon tag of a character model and also move this weapon while the character models moves its arm.

The translation and rotation values for one frame of a tag

typedef struct mIndexList_s mIndexList_t

Function Documentation

void R_FillArrayData ( mAliasModel_t mod,
mAliasMesh_t mesh,
float  backlerp,
int  framenum,
int  oldframenum,
bool  prerender 
)

Converts the model data into the opengl arrays.

Parameters
modThe model to convert
meshThe particular mesh of the model to convert
backlerpThe linear back interpolation when loading the data
framenumThe frame number of the mesh to load (if animated)
oldframenumThe old frame number (used to interpolate)
prerenderIf this is true, all data is filled to the arrays. If false, then e.g. the normals are only filled to the arrays if the lighting is activated.
Note
If GLSL programs are enabled, the actual interpolation will be done on the GPU, but this function is still needed to fill the GL arrays for the keyframes
Todo:
damn slow - optimize this

Definition at line 576 of file r_model_alias.cpp.

References mAliasModel_s::curFrame, mAliasModel_s::frames, i, mAliasMesh_s::indexes, lengthof, rstate_s::lighting_enabled, MAX_ALIAS_VERTS, mAliasMesh_s::next_normals, mAliasMesh_s::next_tangents, mAliasMesh_s::next_verts, mAliasMesh_s::normals, mAliasMesh_s::num_tris, mAliasMesh_s::num_verts, mAliasModel_s::oldFrame, mAliasVertex_s::point, R_ModCalcNormalsAndTangents(), R_ReallocateStateArrays(), R_ReallocateTexunitArray(), r_state, mAliasMesh_s::stcoords, mAliasMesh_s::tangents, texunit_diffuse, mAliasFrame_s::translate, v, Vector2Copy, VectorCopy, VectorSet, rstate_s::vertex_array_3d, mAliasMesh_s::vertexes, and mAliasMesh_s::verts.

Referenced by R_DrawAliasFrameLerp(), and R_ModLoadArrayData().

void R_ModCalcUniqueNormalsAndTangents ( mAliasMesh_t mesh,
int  nFrames,
float  smoothness 
)

Calculates normals and tangents for all frames and does vertex merging based on smoothness.

Parameters
meshThe mesh to calculate normals for
nFramesHow many frames the mesh has
smoothnessHow aggressively should normals be smoothed; value is compared with dotproduct of vectors to decide if they should be merged
See also
R_ModCalcNormalsAndTangents

Definition at line 313 of file r_model_alias.cpp.

References Com_Error(), CrossProduct(), DotProduct, ERR_DROP, i, mAliasMesh_s::indexes, mIndexList_s::length, mIndexList_s::list, mAliasCoord_t, MAX_ALIAS_TRIS, MAX_ALIAS_VERTS, Mem_Free, Mem_PoolAllocTypeN, mAliasMesh_s::name, mAliasMesh_s::num_tris, mAliasMesh_s::num_verts, Orthogonalize(), mAliasMesh_s::revIndexes, mAliasMesh_s::stcoords, mAliasComplexVertex_s::tangent, v, Vector2Copy, Vector2Equal, Vector2Subtract, VectorAdd, VectorCopy, VectorEqual, VectorMul, VectorNormalizeFast(), VectorSubtract, mAliasMesh_s::vertexes, and vid_modelPool.

Referenced by PrecalcNormalsAndTangents(), R_ModLoadAliasMD2MeshUnindexed(), and R_ModLoadAliasMD3Model().