r_model_dpm.h File Reference
dpm model loading
More...
Go to the source code of this file.
Detailed Description
dpm model loading
- Note:
- type 2 model (hierarchical skeletal pose) within this specification, int is assumed to be 32bit, float is assumed to be 32bit, char is assumed to be 8bit, text is assumed to be an array of chars with NULL termination all values are big endian (also known as network byte ordering), NOT x86 little endian general notes: a pose is a 3x4 matrix (rotation matrix, and translate vector) parent bones must always be lower in number than their children, models will be rejected if this is not obeyed (can be fixed by modelling utilities)
-
utility notes: if a hard edge is desired (faceted lighting, or a jump to another set of skin coordinates), vertices must be duplicated ability to visually edit groupids of triangles is highly recommended bones should be markable as 'attach' somehow (up to the utility) and thus protected from culling of unused resources frame 0 is always the base pose (the one the skeleton was built for)
-
game notes: the loader should be very thorough about error checking, all vertex and bone indices should be validated, etc the gamecode can look up bone numbers by name using a builtin function, for use in attachment situations (the client should have the same model as the host of the gamecode in question - that is to say if the server gamecode is setting the bone number, the client and server must have vaguely compatible models so the client understands, and if the client gamecode is setting the bone number, the server could have a completely different model with no harm done) the triangle groupid values are up to the gamecode, it is recommended that gamecode process this in an object-oriented fashion (I.E. bullet hits entity, call that entity's function for getting properties of that groupid) frame 0 should be usable, not skipped speed optimizations for the saver to do: remove all unused data (unused bones, vertices, etc, be sure to check if bones are used for attachments however) sort triangles into strips sort vertices according to first use in a triangle (caching benefits) after sorting triangles speed optimizations for the loader to do: if the model only has one frame, process it at load time to create a simple static vertex mesh to render (this is a hassle, but it is rewarding to optimize all such models)
-
rendering process: 1*. one or two poses are looked up by number 2*. boneposes (matrices) are interpolated, building bone matrix array 3. bones are parsed sequentially, each bone's matrix is transformed by it's parent bone (which can be -1; the model to world matrix) 4. meshs are parsed sequentially, as follows: 1. vertices are parsed sequentially and may be influenced by more than one bone (the results of the 3x4 matrix transform will be added together - weighting is already built into these) 2. shader is looked up and called, passing vertex buffer (temporary) and triangle indices (which are stored in the mesh) 5. rendering is complete
- these stages can be replaced with completely dynamic animation instead of pose animations.
Definition in file r_model_dpm.h.
Function Documentation
void R_ModelLoadDPMVertsForFrame |
( |
struct model_s * |
mod, |
|
|
int |
frame | |
|
) |
| | |
Transforms the bones vertices of the given frame to the initial mesh structure of the given model.
Definition at line 31 of file r_model_dpm.c.
References model_s::alias, mAliasFrame_s::boneMatrix, mAliasMesh_s::bonesVertexes, mAliasModel_s::frames, i, mAliasBoneVertex_s::influence, mAliasBoneMatrix_s::matrix, Mem_Free, Mem_PoolAlloc, mAliasModel_s::meshes, mAliasMesh_s::num_verts, mAliasBoneVertex_s::origin, mAliasMesh_s::vertexes, and vid_modelPool.
Referenced by R_ModLoadAliasDPMModel().
void R_ModLoadAliasDPMModel |
( |
model_t * |
mod, |
|
|
byte * |
buffer, |
|
|
int |
bufSize | |
|
) |
| | |
Load dpm models from file.
- Todo:
- Load this into mAliasModel_t structure
Definition at line 72 of file r_model_dpm.c.
References model_s::alias, dpmframe_s::allradius, dpmheader_s::allradius, BigFloat(), BigLong(), mAliasFrame_s::boneMatrix, mAliasBoneVertex_s::bonenum, dpmbonevert_s::bonenum, mAliasModel_s::bones, mAliasMesh_s::bonesVertexes, byte, Com_Error(), ERR_DROP, dpmbone_s::flags, mAliasBone_s::flags, mAliasModel_s::frames, i, mAliasMesh_s::indexes, mAliasBoneVertex_s::influence, dpmbonevert_s::influence, mAliasCoord_t, dpmbonepose_s::matrix, mAliasBoneMatrix_s::matrix, dpmframe_s::maxs, mAliasFrame_s::maxs, dpmheader_s::maxs, model_s::maxs, Mem_PoolAlloc, mAliasModel_s::meshes, dpmframe_s::mins, mAliasFrame_s::mins, dpmheader_s::mins, model_s::mins, mod_alias_dpm, image_s::name, mAliasSkin_s::name, model_s::name, mAliasBoneVertex_s::normal, dpmbonevert_s::normal, dpmheader_s::num_bones, mAliasModel_s::num_bones, dpmheader_s::num_frames, mAliasModel_s::num_frames, mAliasModel_s::num_meshes, dpmheader_s::num_meshs, dpmmesh_s::num_tris, mAliasMesh_s::num_tris, dpmmesh_s::num_verts, mAliasMesh_s::num_verts, dpmvertex_s::numbones, dpmframe_s::ofs_bonepositions, dpmheader_s::ofs_bones, dpmheader_s::ofs_frames, dpmmesh_s::ofs_groupids, dpmmesh_s::ofs_indices, dpmheader_s::ofs_meshs, dpmmesh_s::ofs_texcoords, dpmmesh_s::ofs_verts, mAliasBoneVertex_s::origin, dpmbonevert_s::origin, dpmbone_s::parent, mAliasBone_s::parent, Q_strncpyz(), qtrue, R_AliasModelGetSkin(), R_ModelLoadDPMVertsForFrame(), R_ModLoadArrayData(), mAliasFrame_s::radius, model_s::radius, dpmmesh_s::shadername, mAliasSkin_s::skin, mAliasMesh_s::skins, mAliasMesh_s::stcoords, dpmheader_s::type, model_s::type, VectorCopy, and vid_modelPool.
Referenced by LoadModel(), and R_ModForName().