UFO: Alien Invasion
|
Mesh Model drawing code. More...
#include "r_local.h"
#include "r_lightmap.h"
#include "r_light.h"
#include "r_mesh.h"
#include "r_mesh_anim.h"
#include "r_error.h"
#include "r_draw.h"
#include "../battlescape/cl_particle.h"
Go to the source code of this file.
Macros | |
#define | R_GetTagOrientByFrame(mod, tagIndex, frame) &(((mod)->alias.tags)[tagIndex].orient[frame]) |
Functions | |
static void | R_TransformModelDirect (modelInfo_t *mi) |
static void | R_DrawMeshModelShell (const mAliasMesh_t *mesh, const vec4_t color) |
Draws an animated, colored shell for the specified entity. Rather than re-lerping or re-scaling the entity, the currently bound vertex arrays are simply re-drawn using a small depth offset and varying texcoord delta. More... | |
static void | R_DrawAliasFrameLerp (mAliasModel_t *mod, mAliasMesh_t *mesh, float backlerp, int framenum, int oldframenum, const vec4_t shellColor) |
Animated model render function. More... | |
static void | R_DrawAliasStatic (const mAliasMesh_t *mesh, const vec4_t shellColor) |
Static model render function. More... | |
static void | R_ResetArraysAfterStaticMeshRender (void) |
static void | R_DrawAliasStaticWithReset (const mAliasMesh_t *mesh, const vec4_t shellColor) |
static void | R_ComputeGLMatrixFromTag (float *glMatrix, const mAliasTagOrientation_t *orient) |
void | R_GetTags (const model_t *mod, const char *tagName, int currentFrame, int oldFrame, const mAliasTagOrientation_t **current, const mAliasTagOrientation_t **old) |
bool | R_GetTagMatrix (const model_t *mod, const char *tagName, int frame, float matrix[16]) |
void | R_InterpolateTransform (float backLerp, int numframes, const mAliasTagOrientation_t *current, const mAliasTagOrientation_t *old, float *interpolated) |
Interpolate the transform for a model places on a tag of another model. More... | |
int | R_GetTagIndexByName (const model_t *mod, const char *tagName) |
Searches the tag data for the given name. More... | |
void | R_ModelAutoScale (const vec2_t boxSize, modelInfo_t *mi, vec3_t scale, vec3_t center) |
Compute scale and center for a model info data structure. More... | |
void | R_DrawModelDirect (modelInfo_t *mi, modelInfo_t *pmi, const char *tagname) |
Draws a model in 2d mode (for rendering model data from the ui) More... | |
void | R_DrawModelParticle (modelInfo_t *mi) |
Renders a particle model for the battlescape. More... | |
bool | R_CullMeshModel (const entity_t *e) |
Checks whether a model is visible in the current scene. More... | |
static mAliasMesh_t * | R_GetLevelOfDetailForModel (const vec3_t origin, const mAliasModel_t *mod) |
Searches an appropriate level-of-detail mesh for the given model. More... | |
static void | R_DrawAliasTags (const mAliasModel_t *mod) |
static mAliasMesh_t * | R_DrawAliasModelBuffer (entity_t *e) |
static bool | R_UpdateShadowOrigin (entity_t *e) |
static void | R_RotateForMeshShadow (const entity_t *e) |
Applies translation, rotation and scale for the shadow of the specified entity. In order to reuse the vertex arrays from the primary rendering pass, the shadow origin must transformed into model-view space. More... | |
static void | R_DrawMeshShadow (entity_t *e, const mAliasMesh_t *mesh) |
Re-draws the mesh using the stencil test. Meshes with stale lighting information, or with a lighting point above our view, are not drawn. More... | |
void | R_DrawAliasModel (entity_t *e) |
Draw a model from the battlescape entity list. More... | |
Variables | |
static const float | MESH_SHADOW_MAX_DISTANCE = 512.0 |
static const float | MESH_SHADOW_ALPHA = 0.3 |
Mesh Model drawing code.
Definition in file r_mesh.cpp.
#define R_GetTagOrientByFrame | ( | mod, | |
tagIndex, | |||
frame | |||
) | &(((mod)->alias.tags)[tagIndex].orient[frame]) |
Definition at line 166 of file r_mesh.cpp.
Referenced by R_GetTagMatrix(), and R_GetTags().
|
static |
Definition at line 143 of file r_mesh.cpp.
References mAliasTagOrientation_s::axis, and mAliasTagOrientation_s::origin.
Referenced by R_GetTagMatrix(), and R_InterpolateTransform().
bool R_CullMeshModel | ( | const entity_t * | e | ) |
Checks whether a model is visible in the current scene.
[in] | e | The entity to check |
false
if visible, true
if the entity is outside the current view Definition at line 446 of file r_mesh.cpp.
References AngleVectors(), cBspPlane_s::dist, DotProduct, f, rlocals_s::frustum, i, lengthof, cBspPlane_s::normal, entity_t::origin, r_locals, VectorAdd, VectorCopy, and YAW.
Referenced by R_CullEntity().
|
static |
Animated model render function.
Definition at line 86 of file r_mesh.cpp.
References rendererData_t::batchCount, mAliasMesh_s::num_tris, R_CheckError, R_DrawMeshModelShell(), R_EnableAnimation(), R_FillArrayData(), and refdef.
Referenced by R_DrawAliasModelBuffer(), R_DrawModelDirect(), and R_DrawModelParticle().
Draw a model from the battlescape entity list.
Definition at line 717 of file r_mesh.cpp.
References rstate_s::active_normalmap, CL_ParticleSpawn(), f, mAliasFrame_s::fBox, mAliasModel_s::frames, image_s::glowmap, i, cvar_s::integer, mAliasModel_s::meshes, image_s::normalmap, mAliasModel_s::num_frames, entity_t::origin, R_BindTexture, R_Color(), r_debug_lights, R_DrawAliasModelBuffer(), R_DrawBoundingBox(), R_DrawMeshShadow(), r_dynamic_lights, R_EnableBumpmap(), R_EnableGlowMap(), R_EnableModelLights(), R_EnableRoughnessMap(), R_EnableSpecularMap(), R_ResetArraysAfterStaticMeshRender(), r_showbox, r_state, R_UpdateLightList(), RDF_IRGOGGLES, refdef, rendererData_t::rendererFlags, RF_IRGOGGLES, RF_PULSE, image_s::roughnessmap, rstate_s::roughnessmap_enabled, mAliasSkin_s::skin, mAliasMesh_s::skins, image_s::specularmap, rstate_s::specularmap_enabled, image_s::texnum, rendererData_t::time, Vector4Set, VectorNotEmpty, and VectorScale.
Referenced by R_DrawMeshEntities().
|
static |
Definition at line 585 of file r_mesh.cpp.
References rendererData_t::aliasCount, cvar_s::integer, mAliasModel_s::num_frames, mAliasMesh_s::num_tris, entity_t::origin, R_DrawAliasFrameLerp(), R_DrawAliasStatic(), R_DrawAliasTags(), r_drawtags, R_GetLevelOfDetailForModel(), R_ResetArrayState(), and refdef.
Referenced by R_DrawAliasModel().
|
static |
Static model render function.
Definition at line 107 of file r_mesh.cpp.
References rstate_s::active_normalmap, rendererData_t::batchCount, rstate_s::dynamic_lighting_enabled, GL_TANGENT_ARRAY, mAliasMesh_s::normals, mAliasMesh_s::num_tris, R_BindArray(), R_DrawMeshModelShell(), r_state, refdef, mAliasMesh_s::tangents, mAliasMesh_s::texcoords, and mAliasMesh_s::verts.
Referenced by R_DrawAliasModelBuffer(), and R_DrawAliasStaticWithReset().
|
static |
Definition at line 131 of file r_mesh.cpp.
References R_DrawAliasStatic(), and R_ResetArraysAfterStaticMeshRender().
Referenced by R_DrawModelDirect(), and R_DrawModelParticle().
|
static |
Definition at line 549 of file r_mesh.cpp.
References mAliasTagOrientation_s::axis, rendererData_t::batchCount, mAliasModel_s::curFrame, i, mAliasModel_s::num_tags, mAliasTag_s::orient, mAliasTagOrientation_s::origin, R_BindArray(), R_BindDefaultArray(), R_EnableColorArray(), R_EnableTexture(), refdef, mAliasModel_s::tags, texunit_diffuse, and VectorMA().
Referenced by R_DrawAliasModelBuffer().
|
static |
Draws an animated, colored shell for the specified entity. Rather than re-lerping or re-scaling the entity, the currently bound vertex arrays are simply re-drawn using a small depth offset and varying texcoord delta.
Definition at line 61 of file r_mesh.cpp.
References rendererData_t::batchCount, mAliasMesh_s::num_tris, R_BindTexture, R_Color(), R_EnableShell(), r_envmaptextures, refdef, and VectorNotEmpty.
Referenced by R_DrawAliasFrameLerp(), and R_DrawAliasStatic().
|
static |
Re-draws the mesh using the stencil test. Meshes with stale lighting information, or with a lighting point above our view, are not drawn.
Definition at line 664 of file r_mesh.cpp.
References rstate_s::active_program, rendererData_t::batchCount, rstate_s::blend_enabled, cvar_s::integer, rstate_s::lighting_enabled, MESH_SHADOW_ALPHA, mAliasMesh_s::num_tris, R_Color(), R_EnableBlend(), R_EnableLighting(), R_EnableStencilTest(), R_EnableTexture(), R_RotateForMeshShadow(), r_shadows, r_state, r_stencilshadows, R_UpdateShadowOrigin(), r_wire, refdef, RF_NO_SHADOW, RF_TRANSLUCENT, texunit_diffuse, cvar_s::value, Vector4Set, and rendererData_t::viewOrigin.
Referenced by R_DrawAliasModel().
void R_DrawModelDirect | ( | modelInfo_t * | mi, |
modelInfo_t * | pmi, | ||
const char * | tagname | ||
) |
Draws a model in 2d mode (for rendering model data from the ui)
[in,out] | mi | All the needed model information to render the model |
[in,out] | pmi | The model information of the parent model. This is used in those cases, where the model that should get rendered here is placed relativly to an already existing model in the world. |
[in] | tagname | If a parent model is given, a tagname is given in most cases, too. It's used to transform the model location relative to the parent model location again. E.g. a tagname of tag_rweapon will transform the location to the right hand of an actor. |
Definition at line 306 of file r_mesh.cpp.
References model_s::alias, rendererData_t::aliasCount, modelInfo_t::backlerp, modelInfo_t::color, Com_Printf(), mAliasFrame_s::fBox, modelInfo_t::frame, mAliasModel_s::frames, cvar_s::integer, model_s::loaded, modelInfo_t::mesh, mAliasModel_s::meshes, modelInfo_t::model, modelInfo_t::name, mAliasModel_s::num_frames, mAliasMesh_s::num_tris, modelInfo_t::oldframe, Q_strnull(), R_AliasModelState(), R_BindTexture, R_CheckError, R_Color(), R_DrawAliasFrameLerp(), R_DrawAliasStaticWithReset(), R_DrawBoundingBox(), R_FindModel(), R_GetTags(), R_InterpolateTransform(), r_showbox, R_TransformModelDirect(), refdef, viddef_t::rx, viddef_t::ry, modelInfo_t::skin, image_s::texnum, vec4_origin, and viddef.
Referenced by R_Draw2DMapMarkers(), R_Draw3DMapMarkers(), UI_DrawItem(), UI_DrawModelNode(), and UI_DrawModelNodeWithUIModel().
void R_DrawModelParticle | ( | modelInfo_t * | mi | ) |
Renders a particle model for the battlescape.
[in,out] | mi | The model information that is used to render the particle model. |
Definition at line 397 of file r_mesh.cpp.
References model_s::alias, rendererData_t::aliasCount, modelInfo_t::angles, modelInfo_t::backlerp, modelInfo_t::color, Com_Printf(), mAliasFrame_s::fBox, modelInfo_t::frame, mAliasModel_s::frames, cvar_s::integer, model_s::loaded, modelInfo_t::mesh, mAliasModel_s::meshes, modelInfo_t::model, modelInfo_t::name, mAliasModel_s::num_frames, mAliasMesh_s::num_tris, modelInfo_t::oldframe, modelInfo_t::origin, PITCH, R_AliasModelState(), R_BindTexture, R_Color(), R_DrawAliasFrameLerp(), R_DrawAliasStaticWithReset(), R_DrawBoundingBox(), r_showbox, refdef, ROLL, modelInfo_t::skin, image_s::texnum, vec4_origin, and YAW.
Referenced by R_DrawParticleModel().
|
static |
Searches an appropriate level-of-detail mesh for the given model.
origin | The origin the model should be placed to in the world |
mod | The model where we are searching an appropriate level-of-detail mesh for |
Definition at line 526 of file r_mesh.cpp.
References length, mAliasModel_s::meshes, mAliasModel_s::num_meshes, RDF_NOWORLDMODEL, refdef, rendererData_t::rendererFlags, VectorLength(), VectorSubtract, and rendererData_t::viewOrigin.
Referenced by R_DrawAliasModelBuffer().
Searches the tag data for the given name.
[in] | mod | The model to search the tag data. Can be nullptr |
[in] | tagName | The name of the tag to get the matrix for. Might not be nullptr |
-1
if no tag with the given name was found Definition at line 247 of file r_mesh.cpp.
References model_s::alias, i, mAliasTag_s::name, mAliasModel_s::num_tags, Q_streq, and mAliasModel_s::tags.
Referenced by CL_ActorGetMuzzle(), CL_AddActor(), R_GetTagMatrix(), and R_GetTags().
[in] | mod | The model to get the tag transformation matrix for |
[in] | tagName | The name of the tag to get the transformation matrix for |
[in] | frame | The frame of the tag to get the transformation matrix for |
[out] | matrix | The transformation matrix |
false
if the tag name for the given model wasn't found, true
if the matrix was filled. Definition at line 189 of file r_mesh.cpp.
References Com_Printf(), index, model_s::name, R_ComputeGLMatrixFromTag(), R_GetTagIndexByName(), and R_GetTagOrientByFrame.
Referenced by CL_ActorGetMuzzle().
void R_GetTags | ( | const model_t * | mod, |
const char * | tagName, | ||
int | currentFrame, | ||
int | oldFrame, | ||
const mAliasTagOrientation_t ** | current, | ||
const mAliasTagOrientation_t ** | old | ||
) |
Definition at line 168 of file r_mesh.cpp.
References Com_Printf(), index, model_s::name, R_GetTagIndexByName(), and R_GetTagOrientByFrame.
Referenced by R_CalcTransform(), and R_DrawModelDirect().
void R_InterpolateTransform | ( | float | backLerp, |
int | numframes, | ||
const mAliasTagOrientation_t * | current, | ||
const mAliasTagOrientation_t * | old, | ||
float * | interpolated | ||
) |
Interpolate the transform for a model places on a tag of another model.
[out] | interpolated | This is an array of 16 floats |
[in] | current | The current frame tag data |
[in] | old | The old frame tag data |
[in] | backLerp | the linear interpolation value [0.0,1.0] |
[in] | numframes | The max frames of the tag data |
Definition at line 212 of file r_mesh.cpp.
References mAliasTagOrientation_s::axis, i, mAliasTagOrientation_s::origin, R_ComputeGLMatrixFromTag(), and VectorNormalizeFast().
Referenced by R_CalcTransform(), and R_DrawModelDirect().
void R_ModelAutoScale | ( | const vec2_t | boxSize, |
modelInfo_t * | mi, | ||
vec3_t | scale, | ||
vec3_t | center | ||
) |
Compute scale and center for a model info data structure.
[in] | boxSize | The size the model should fit into |
[in,out] | mi | The model info that contains the model that should be scaled |
[out] | scale | The scale vector |
[out] | center | The center of the model (center of the model's bounding box) |
modelInfo_t
struct only holds pointers to the vectors. modelInfo_t
into account Definition at line 278 of file r_mesh.cpp.
References modelInfo_t::center, AABB::getCenter(), AABB::getWidthX(), AABB::getWidthZ(), model_s::modBox, modelInfo_t::model, modelInfo_t::scale, scale, VectorNegate, and VectorSet.
Referenced by R_Draw2DMapMarkers(), R_Draw3DMapMarkers(), UI_DrawModelNode(), and UI_DrawModelNodeWithUIModel().
Definition at line 122 of file r_mesh.cpp.
References rstate_s::active_normalmap, rstate_s::dynamic_lighting_enabled, GL_TANGENT_ARRAY, R_BindDefaultArray(), and r_state.
Referenced by R_DrawAliasModel(), and R_DrawAliasStaticWithReset().
Applies translation, rotation and scale for the shadow of the specified entity. In order to reuse the vertex arrays from the primary rendering pass, the shadow origin must transformed into model-view space.
Definition at line 641 of file r_mesh.cpp.
References PITCH, and R_TransformForEntity().
Referenced by R_DrawMeshShadow().
|
static |
Definition at line 40 of file r_mesh.cpp.
References modelInfo_t::angles, modelInfo_t::center, modelInfo_t::origin, and modelInfo_t::scale.
Referenced by R_DrawModelDirect().
|
static |
Definition at line 607 of file r_mesh.cpp.
References trace_s::endpos, rlocals_s::frame, trace_s::leafnum, MASK_SOLID, MESH_SHADOW_MAX_DISTANCE, entity_t::origin, r_locals, R_Trace(), refdef, rendererData_t::trace, and VectorCopy.
Referenced by R_DrawMeshShadow().
|
static |
Definition at line 38 of file r_mesh.cpp.
Referenced by R_DrawMeshShadow().
|
static |
Definition at line 37 of file r_mesh.cpp.
Referenced by R_UpdateShadowOrigin().