diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /utils/hlmv/studio_flex.cpp | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'utils/hlmv/studio_flex.cpp')
| -rw-r--r-- | utils/hlmv/studio_flex.cpp | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/utils/hlmv/studio_flex.cpp b/utils/hlmv/studio_flex.cpp new file mode 100644 index 0000000..9c0b28d --- /dev/null +++ b/utils/hlmv/studio_flex.cpp @@ -0,0 +1,76 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +// +//=============================================================================// +#include <string.h> +#include <assert.h> + +#include "ViewerSettings.h" +#include "StudioModel.h" +#include "bitmap/TGALoader.h" +#include "materialsystem/imaterial.h" +#include "materialsystem/imaterialvar.h" +#include "materialsystem/itexture.h" +#include "matsyswin.h" +#include "istudiorender.h" + +#include "studio_render.h" + +Vector g_viewtarget( 0, 0, 0 ); +float g_flexdescweight[MAXSTUDIOFLEXDESC]; +float g_flexdescweight2[MAXSTUDIOFLEXDESC]; +Vector vright( 1, 0, 0 ); +Vector vup( 0, 1, 0 ); +Vector r_origin( 0, 0, 0 ); + + +// hack! Should probably use the gamma stuff in mathlib since we already linking it. +int LocalLinearToTexture( float v ) +{ + return pow( v, 1.0f / 2.2f ) * 255; +} + +// hack! Should probably use the gamma stuff in mathlib since we already linking it. +float LocalTextureToLinear( int c ) +{ + return pow( c / 255.0, 2.2 ); +} + + + +#define sign( a ) (((a) < 0) ? -1 : (((a) > 0) ? 1 : 0 )) + + +void StudioModel::RunFlexRules( ) +{ + StudioModel *pSrcModel = g_pStudioModel; + + // only the root model has control over flex rules + CStudioHdr *pSrcStudioHdr = pSrcModel->GetStudioHdr(); + CStudioHdr *pDstStudioHdr = GetStudioHdr(); + + if ( !pSrcStudioHdr ) + { + pSrcModel = this; + pSrcStudioHdr = GetStudioHdr(); + } + + float src[MAXSTUDIOFLEXCTRL*4]; + + for (LocalFlexController_t i = LocalFlexController_t(0); i < pSrcStudioHdr->numflexcontrollers(); i++) + { + mstudioflexcontroller_t *pflex = pSrcStudioHdr->pFlexcontroller( i ); + int j = pSrcStudioHdr->pFlexcontroller( i )->localToGlobal; + // remap m_flexweights to full dynamic range, global flexcontroller indexes + if (j >= 0 && j < MAXSTUDIOFLEXCTRL*4) + { + src[j] = pSrcModel->m_flexweight[i] * (pflex->max - pflex->min) + pflex->min; + } + } + + pDstStudioHdr->RunFlexRules( src, g_flexdescweight ); +} + |