r_model_alias.c File Reference

shared alias model loading code (md2, md3) More...

#include "r_local.h"
#include "../../shared/parse.h"
#include "r_state.h"
Include dependency graph for r_model_alias.c:

Go to the source code of this file.

Functions

void R_ModLoadAnims (mAliasModel_t *mod, void *buffer)
static void R_ModCalcNormalsAndTangents (mAliasMesh_t *mesh, int framenum, const vec3_t translate, qboolean backlerp)
 Calculates a per-vertex tangentspace basis and stores it in GL arrays attached to the mesh.
qboolean R_ModLoadMDX (model_t *mod)
 Tries to load a mdx file that contains the normals and the tangents for a model.
void R_ModCalcUniqueNormalsAndTangents (mAliasMesh_t *mesh, int nFrames, float smoothness)
 Calculates normals and tangents for all frames and does vertex merging based on smoothness.
image_tR_AliasModelGetSkin (const char *modelFileName, const char *skin)
image_tR_AliasModelState (const model_t *mod, int *mesh, int *frame, int *oldFrame, int *skin)
void R_FillArrayData (mAliasModel_t *mod, mAliasMesh_t *mesh, float backlerp, int framenum, int oldframenum, qboolean prerender)
 Converts the model data into the opengl arrays.
void R_ModLoadArrayData (mAliasModel_t *mod, mAliasMesh_t *mesh, qboolean loadNormals)
 Allocates data arrays for animated models. Only called once at loading time.

Detailed Description

shared alias model loading code (md2, md3)

Definition in file r_model_alias.c.


Function Documentation

image_t* R_AliasModelGetSkin ( const char *  modelFileName,
const char *  skin 
)
image_t* R_AliasModelState ( const model_t mod,
int *  mesh,
int *  frame,
int *  oldFrame,
int *  skin 
)
void R_FillArrayData ( mAliasModel_t mod,
mAliasMesh_t mesh,
float  backlerp,
int  framenum,
int  oldframenum,
qboolean  prerender 
)

Converts the model data into the opengl arrays.

Parameters:
mod The model to convert
mesh The particular mesh of the model to convert
backlerp The linear back interpolation when loading the data
framenum The frame number of the mesh to load (if animated)
oldframenum The old frame number (used to interpolate)
prerender If 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 554 of file r_model_alias.c.

References mAliasModel_s::curFrame, mAliasModel_s::frames, i, mAliasMesh_s::indexes, lengthof, rstate_t::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, qfalse, qtrue, R_ModCalcNormalsAndTangents(), r_state, mAliasMesh_s::stcoords, mAliasMesh_s::tangents, texunit_diffuse, mAliasFrame_s::translate, Vector2Copy, VectorCopy, VectorSet, rstate_t::vertex_array_3d, mAliasMesh_s::vertexes, and mAliasMesh_s::verts.

Referenced by R_DrawAliasFrameLerp(), and R_ModLoadArrayData().

static void R_ModCalcNormalsAndTangents ( mAliasMesh_t mesh,
int  framenum,
const vec3_t  translate,
qboolean  backlerp 
) [static]

Calculates a per-vertex tangentspace basis and stores it in GL arrays attached to the mesh.

Parameters:
mesh The mesh to calculate normals for
framenum The animation frame to calculate normals for
translate The frame translation for the given animation frame
backlerp Whether to store the results in the GL arrays for the previous keyframe or the next keyframe
See also:
R_ModCalcUniqueNormalsAndTangents

Definition at line 103 of file r_model_alias.c.

References CrossProduct(), DotProduct, i, mAliasMesh_s::indexes, len, mIndexList_s::length, mIndexList_s::list, mAliasCoord_t, MAX_ALIAS_TRIS, mAliasMesh_s::next_normals, mAliasMesh_s::next_tangents, mAliasMesh_s::next_verts, mAliasMesh_s::normals, mAliasMesh_s::num_tris, mAliasMesh_s::num_verts, Orthogonalize(), mAliasMesh_s::revIndexes, mAliasMesh_s::stcoords, mAliasMesh_s::tangents, mAliasMesh_s::texcoords, Vector2Copy, Vector2Subtract, Vector4Copy, VectorAdd, VectorClear, VectorCopy, VectorMul, VectorNormalize(), VectorSubtract, mAliasMesh_s::vertexes, and mAliasMesh_s::verts.

Referenced by R_FillArrayData().

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:
mesh The mesh to calculate normals for
nFrames How many frames the mesh has
smoothness How 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 292 of file r_model_alias.c.

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

Referenced by PrecalcNormalsAndTangents(), and R_ModLoadAliasMD2MeshUnindexed().

void R_ModLoadAnims ( mAliasModel_t mod,
void *  buffer 
)
void R_ModLoadArrayData ( mAliasModel_t mod,
mAliasMesh_t mesh,
qboolean  loadNormals 
)
qboolean R_ModLoadMDX ( model_t mod  ) 

Generated by  doxygen 1.6.2