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.

60 lines
1.9 KiB

  1. //========= Copyright � Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //==========================================================================//
  6. #ifndef CMATRIXSTACK_H
  7. #define CMATRIXSTACK_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "utlvector.h"
  12. #include "mathlib/vmatrix.h"
  13. // TODO: switch the PS3/OGL shaderapi implementations to use this (replace the incomplete implementation of ID3DXMatrixStack in dxabstract.h)
  14. struct D3DXMATRIX;
  15. struct D3DXVECTOR3;
  16. //-----------------------------------------------------------------------------
  17. // CMatrixStack
  18. // A direct replacement for ID3DXMatrixStack, which has bugs
  19. // NOTE: it uses *TRANSPOSED* VMatrixes internally, to match D3D conventions
  20. class CMatrixStack
  21. {
  22. public:
  23. // NOTE: The stack starts with one matrix, initialized to identity
  24. CMatrixStack();
  25. ~CMatrixStack();
  26. D3DXMATRIX *GetTop();
  27. void Push();
  28. void Pop();
  29. void LoadIdentity();
  30. void LoadMatrix( const D3DXMATRIX *pMat );
  31. void MultMatrix( const D3DXMATRIX *pMat );
  32. void MultMatrixLocal( const D3DXMATRIX *pMat );
  33. // Left multiply the current matrix with the computed scale matrix
  34. // (scaling is about the local origin of the object)
  35. bool ScaleLocal( float x, float y, float z );
  36. // Left multiply the current matrix with the computed rotation
  37. // matrix, counterclockwise about the given axis with the given angle.
  38. // (rotation is about the local origin of the object)
  39. bool RotateAxisLocal( const D3DXVECTOR3 *pV, float angleInRadians );
  40. // Left multiply the current matrix with the computed translation
  41. // matrix. (transformation is about the local origin of the object)
  42. bool TranslateLocal( float x, float y, float z );
  43. private:
  44. CUtlVector<VMatrix> m_Stack; // 'Top' of the stack is at m_stack[count-1] (push increases count, pop decreases)
  45. };
  46. #endif // CMATRIXSTACK_H