Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
1.9 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. #include <string.h>
  9. #include <assert.h>
  10. #include "ViewerSettings.h"
  11. #include "StudioModel.h"
  12. #include "bitmap/TGALoader.h"
  13. #include "materialsystem/imaterial.h"
  14. #include "materialsystem/imaterialvar.h"
  15. #include "materialsystem/itexture.h"
  16. #include "matsyswin.h"
  17. #include "istudiorender.h"
  18. #include "studio_render.h"
  19. Vector g_viewtarget( 0, 0, 0 );
  20. float g_flexdescweight[MAXSTUDIOFLEXDESC];
  21. float g_flexdescweight2[MAXSTUDIOFLEXDESC];
  22. Vector vright( 1, 0, 0 );
  23. Vector vup( 0, 1, 0 );
  24. Vector r_origin( 0, 0, 0 );
  25. // hack! Should probably use the gamma stuff in mathlib since we already linking it.
  26. int LocalLinearToTexture( float v )
  27. {
  28. return pow( v, 1.0f / 2.2f ) * 255;
  29. }
  30. // hack! Should probably use the gamma stuff in mathlib since we already linking it.
  31. float LocalTextureToLinear( int c )
  32. {
  33. return pow( c / 255.0, 2.2 );
  34. }
  35. #define sign( a ) (((a) < 0) ? -1 : (((a) > 0) ? 1 : 0 ))
  36. void StudioModel::RunFlexRules( )
  37. {
  38. StudioModel *pSrcModel = g_pStudioModel;
  39. // only the root model has control over flex rules
  40. CStudioHdr *pSrcStudioHdr = pSrcModel->GetStudioHdr();
  41. CStudioHdr *pDstStudioHdr = GetStudioHdr();
  42. if ( !pSrcStudioHdr )
  43. {
  44. pSrcModel = this;
  45. pSrcStudioHdr = GetStudioHdr();
  46. }
  47. float src[MAXSTUDIOFLEXCTRL*4];
  48. for (LocalFlexController_t i = LocalFlexController_t(0); i < pSrcStudioHdr->numflexcontrollers(); i++)
  49. {
  50. mstudioflexcontroller_t *pflex = pSrcStudioHdr->pFlexcontroller( i );
  51. int j = pSrcStudioHdr->pFlexcontroller( i )->localToGlobal;
  52. // remap m_flexweights to full dynamic range, global flexcontroller indexes
  53. if (j >= 0 && j < MAXSTUDIOFLEXCTRL*4)
  54. {
  55. src[j] = pSrcModel->m_flexweight[i] * (pflex->max - pflex->min) + pflex->min;
  56. }
  57. }
  58. pDstStudioHdr->RunFlexRules( src, g_flexdescweight );
  59. }