Counter Strike : Global Offensive Source Code
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.

66 lines
1.7 KiB

  1. //========= Copyright � 1996-2005, 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. CStudioHdr *pStudioHdr = GetStudioHdr();
  39. float src[MAXSTUDIOFLEXCTRL*4];
  40. for (LocalFlexController_t i = LocalFlexController_t(0); i < pStudioHdr->numflexcontrollers(); i++)
  41. {
  42. mstudioflexcontroller_t *pflex = pStudioHdr->pFlexcontroller( i );
  43. int j = pStudioHdr->pFlexcontroller( i )->localToGlobal;
  44. // remap m_flexweights to full dynamic range, global flexcontroller indexes
  45. if (j >= 0 && j < MAXSTUDIOFLEXCTRL*4)
  46. {
  47. src[j] = m_flexweight[i] * (pflex->max - pflex->min) + pflex->min;
  48. }
  49. }
  50. pStudioHdr->RunFlexRules( src, g_flexdescweight );
  51. }