2018-01-19 18:00:32 +01:00
|
|
|
//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============
|
2016-06-04 15:24:23 +02:00
|
|
|
//
|
|
|
|
// Purpose:
|
|
|
|
//
|
|
|
|
// $NoKeywords: $
|
|
|
|
//=============================================================================
|
|
|
|
|
2017-12-10 21:40:41 +01:00
|
|
|
#pragma once
|
2016-06-04 15:24:23 +02:00
|
|
|
#if !defined ( STUDIOMODELRENDERER_H )
|
|
|
|
#define STUDIOMODELRENDERER_H
|
|
|
|
|
|
|
|
/*
|
|
|
|
====================
|
|
|
|
CStudioModelRenderer
|
|
|
|
|
|
|
|
====================
|
|
|
|
*/
|
|
|
|
class CStudioModelRenderer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// Construction/Destruction
|
|
|
|
CStudioModelRenderer( void );
|
|
|
|
virtual ~CStudioModelRenderer( void );
|
|
|
|
|
|
|
|
// Initialization
|
|
|
|
virtual void Init( void );
|
|
|
|
|
2016-08-01 13:13:13 +02:00
|
|
|
public:
|
2016-06-04 15:24:23 +02:00
|
|
|
// Public Interfaces
|
2016-08-01 13:13:13 +02:00
|
|
|
virtual int StudioDrawModel( int flags );
|
|
|
|
virtual int StudioDrawPlayer( int flags, struct entity_state_s *pplayer );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
// Local interfaces
|
|
|
|
//
|
|
|
|
|
|
|
|
// Look up animation data for sequence
|
2016-08-01 13:13:13 +02:00
|
|
|
virtual mstudioanim_t *StudioGetAnim( model_t *m_pSubModel, mstudioseqdesc_t *pseqdesc );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// Interpolate model position and angles and set up matrices
|
2016-08-01 13:13:13 +02:00
|
|
|
virtual void StudioSetUpTransform( int trivial_accept );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// Set up model bone positions
|
2016-08-01 13:13:13 +02:00
|
|
|
virtual void StudioSetupBones( void );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// Find final attachment points
|
2016-08-01 13:13:13 +02:00
|
|
|
virtual void StudioCalcAttachments( void );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// Save bone matrices and names
|
|
|
|
virtual void StudioSaveBones( void );
|
|
|
|
|
|
|
|
// Merge cached bones with current bones for model
|
2016-08-01 13:13:13 +02:00
|
|
|
virtual void StudioMergeBones( model_t *m_pSubModel );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// Determine interpolation fraction
|
|
|
|
virtual float StudioEstimateInterpolant( void );
|
|
|
|
|
|
|
|
// Determine current frame for rendering
|
2016-08-01 13:13:13 +02:00
|
|
|
virtual float StudioEstimateFrame( mstudioseqdesc_t *pseqdesc );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// Apply special effects to transform matrix
|
|
|
|
virtual void StudioFxTransform( cl_entity_t *ent, float transform[3][4] );
|
|
|
|
|
|
|
|
// Spherical interpolation of bones
|
2016-08-01 13:13:13 +02:00
|
|
|
virtual void StudioSlerpBones( vec4_t q1[], float pos1[][3], vec4_t q2[], float pos2[][3], float s );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-08-01 13:13:13 +02:00
|
|
|
// Compute bone adjustments( bone controllers )
|
|
|
|
virtual void StudioCalcBoneAdj( float dadt, float *adj, const byte *pcontroller1, const byte *pcontroller2, byte mouthopen );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// Get bone quaternions
|
2016-08-01 13:13:13 +02:00
|
|
|
virtual void StudioCalcBoneQuaterion( int frame, float s, mstudiobone_t *pbone, mstudioanim_t *panim, float *adj, float *q );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// Get bone positions
|
2016-08-01 13:13:13 +02:00
|
|
|
virtual void StudioCalcBonePosition( int frame, float s, mstudiobone_t *pbone, mstudioanim_t *panim, float *adj, float *pos );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// Compute rotations
|
2016-08-01 13:13:13 +02:00
|
|
|
virtual void StudioCalcRotations( float pos[][3], vec4_t *q, mstudioseqdesc_t *pseqdesc, mstudioanim_t *panim, float f );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// Send bones and verts to renderer
|
2016-08-01 13:13:13 +02:00
|
|
|
virtual void StudioRenderModel( void );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// Finalize rendering
|
2016-08-01 13:13:13 +02:00
|
|
|
virtual void StudioRenderFinal( void );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// GL&D3D vs. Software renderer finishing functions
|
2016-08-01 13:13:13 +02:00
|
|
|
virtual void StudioRenderFinal_Software( void );
|
|
|
|
virtual void StudioRenderFinal_Hardware( void );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// Player specific data
|
|
|
|
// Determine pitch and blending amounts for players
|
2016-08-01 13:13:13 +02:00
|
|
|
virtual void StudioPlayerBlend( mstudioseqdesc_t *pseqdesc, int *pBlend, float *pPitch );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// Estimate gait frame for player
|
2016-08-01 13:13:13 +02:00
|
|
|
virtual void StudioEstimateGait( entity_state_t *pplayer );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// Process movement of player
|
2016-08-01 13:13:13 +02:00
|
|
|
virtual void StudioProcessGait( entity_state_t *pplayer );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
// Client clock
|
|
|
|
double m_clTime;
|
|
|
|
// Old Client clock
|
|
|
|
double m_clOldTime;
|
|
|
|
|
|
|
|
// Do interpolation?
|
|
|
|
int m_fDoInterp;
|
|
|
|
// Do gait estimation?
|
|
|
|
int m_fGaitEstimation;
|
|
|
|
|
|
|
|
// Current render frame #
|
|
|
|
int m_nFrameCount;
|
|
|
|
|
|
|
|
// Cvars that studio model code needs to reference
|
|
|
|
//
|
|
|
|
// Use high quality models?
|
|
|
|
cvar_t *m_pCvarHiModels;
|
|
|
|
// Developer debug output desired?
|
|
|
|
cvar_t *m_pCvarDeveloper;
|
|
|
|
// Draw entities bone hit boxes, etc?
|
|
|
|
cvar_t *m_pCvarDrawEntities;
|
|
|
|
|
|
|
|
// The entity which we are currently rendering.
|
|
|
|
cl_entity_t *m_pCurrentEntity;
|
|
|
|
|
|
|
|
// The model for the entity being rendered
|
|
|
|
model_t *m_pRenderModel;
|
|
|
|
|
|
|
|
// Player info for current player, if drawing a player
|
|
|
|
player_info_t *m_pPlayerInfo;
|
|
|
|
|
|
|
|
// The index of the player being drawn
|
|
|
|
int m_nPlayerIndex;
|
|
|
|
|
|
|
|
// The player's gait movement
|
|
|
|
float m_flGaitMovement;
|
|
|
|
|
|
|
|
// Pointer to header block for studio model data
|
|
|
|
studiohdr_t *m_pStudioHeader;
|
|
|
|
|
|
|
|
// Pointers to current body part and submodel
|
|
|
|
mstudiobodyparts_t *m_pBodyPart;
|
|
|
|
mstudiomodel_t *m_pSubModel;
|
|
|
|
|
|
|
|
// Palette substition for top and bottom of model
|
2016-08-01 13:13:13 +02:00
|
|
|
int m_nTopColor;
|
2016-06-04 15:24:23 +02:00
|
|
|
int m_nBottomColor;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Sprite model used for drawing studio model chrome
|
|
|
|
model_t *m_pChromeSprite;
|
|
|
|
|
|
|
|
// Caching
|
|
|
|
// Number of bones in bone cache
|
|
|
|
int m_nCachedBones;
|
|
|
|
// Names of cached bones
|
2016-08-01 13:13:13 +02:00
|
|
|
char m_nCachedBoneNames[MAXSTUDIOBONES][32];
|
2016-06-04 15:24:23 +02:00
|
|
|
// Cached bone & light transformation matrices
|
2016-08-01 13:13:13 +02:00
|
|
|
float m_rgCachedBoneTransform[MAXSTUDIOBONES][3][4];
|
|
|
|
float m_rgCachedLightTransform[MAXSTUDIOBONES][3][4];
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// Software renderer scale factors
|
|
|
|
float m_fSoftwareXScale, m_fSoftwareYScale;
|
|
|
|
|
|
|
|
// Current view vectors and render origin
|
2016-08-01 13:13:13 +02:00
|
|
|
float m_vUp[3];
|
|
|
|
float m_vRight[3];
|
|
|
|
float m_vNormal[3];
|
|
|
|
|
|
|
|
float m_vRenderOrigin[3];
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// Model render counters ( from engine )
|
|
|
|
int *m_pStudioModelCount;
|
|
|
|
int *m_pModelsDrawn;
|
|
|
|
|
|
|
|
// Matrices
|
|
|
|
// Model to world transformation
|
2016-08-01 13:13:13 +02:00
|
|
|
float (*m_protationmatrix)[3][4];
|
2016-06-04 15:24:23 +02:00
|
|
|
// Model to view transformation
|
2016-08-01 13:13:13 +02:00
|
|
|
float (*m_paliastransform)[3][4];
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// Concatenated bone and light transforms
|
2016-08-01 13:13:13 +02:00
|
|
|
float (*m_pbonetransform)[MAXSTUDIOBONES][3][4];
|
|
|
|
float (*m_plighttransform)[MAXSTUDIOBONES][3][4];
|
2016-06-04 15:24:23 +02:00
|
|
|
};
|
|
|
|
|
2016-08-01 13:13:13 +02:00
|
|
|
#endif // STUDIOMODELRENDERER_H
|