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.

158 lines
4.2 KiB

  1. //======= Copyright (c) 1996-2009, Valve Corporation, All rights reserved. ======
  2. //
  3. // A class representing a camera
  4. //
  5. //===============================================================================
  6. #ifndef DMECAMERA_H
  7. #define DMECAMERA_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "movieobjects/dmedag.h"
  12. enum EOrthoAxes
  13. {
  14. AXIS_X = 0,
  15. AXIS_Y,
  16. AXIS_Z,
  17. AXIS_X_NEG,
  18. AXIS_Y_NEG,
  19. AXIS_Z_NEG,
  20. AXIS_COUNT, // == 6
  21. };
  22. //-----------------------------------------------------------------------------
  23. // A class representing a camera
  24. //-----------------------------------------------------------------------------
  25. class CDmeCamera : public CDmeDag
  26. {
  27. DEFINE_ELEMENT( CDmeCamera, CDmeDag );
  28. public:
  29. // Sets up render state in the material system for rendering
  30. // This includes the view matrix and the projection matrix
  31. void SetupRenderState( int nDisplayWidth, int nDisplayHeight, bool bUseEngineCoordinateSystem = false );
  32. // accessors for generated matrices
  33. void GetViewMatrix( VMatrix &view, bool bUseEngineCoordinateSystem = false );
  34. void GetProjectionMatrix( VMatrix &proj, int width, int height );
  35. void GetViewProjectionInverse( VMatrix &viewprojinv, int width, int height );
  36. void ComputeScreenSpacePosition( const Vector &vecWorldPosition, int width, int height, Vector2D *pScreenPosition );
  37. // Returns the x FOV (the full angle)
  38. float GetFOVx() const;
  39. void SetFOVx( float fov );
  40. // Near and far Z
  41. float GetNearZ() const;
  42. void SetNearZ( float zNear );
  43. float GetFarZ() const;
  44. void SetFarZ( float zFar );
  45. // Returns the focal distance in inches
  46. float GetFocalDistance() const;
  47. // Sets the focal distance in inches
  48. void SetFocalDistance( const float &fFocalDistance );
  49. // Zero-parallax distance for stereo rendering
  50. float GetZeroParallaxDistance() const;
  51. void SetZeroParallaxDistance( const float &fZeroParallaxDistance );
  52. // Eye separation for stereo rendering
  53. float GetEyeSeparation() const;
  54. void SetEyeSeparation( const float &flEyeSeparation );
  55. // Returns the aperture size in inches
  56. float GetAperture() const;
  57. // Returns the shutter speed in seconds
  58. DmeTime_t GetShutterSpeed() const;
  59. // Returns the tone map scale
  60. float GetToneMapScale() const;
  61. // Returns the camera's Ambient occlusion bias
  62. float GetAOBias() const;
  63. // Returns the camera's Ambient occlusion sgrength
  64. float GetAOStrength() const;
  65. // Returns the camera's Ambient occlusion radius
  66. float GetAORadius() const;
  67. // Returns the tone map scale
  68. float GetBloomScale() const;
  69. // Returns the tone map scale
  70. float GetBloomWidth() const;
  71. // Returns the view direction
  72. void GetViewDirection( Vector *pDirection );
  73. // Returns Depth of Field quality level
  74. int GetDepthOfFieldQuality() const;
  75. // Returns the Motion Blur quality level
  76. int GetMotionBlurQuality() const;
  77. // Ortho stuff
  78. void OrthoUpdate();
  79. const matrix3x4_t &GetOrthoTransform() const;
  80. const Vector &GetOrthoAbsOrigin() const;
  81. const QAngle &GetOrthoAbsAngles() const;
  82. void FromCamera( CDmeCamera *pCamera );
  83. void ToCamera( CDmeCamera *pCamera );
  84. private:
  85. // Loads the material system view matrix based on the transform
  86. void LoadViewMatrix( bool bUseEngineCoordinateSystem );
  87. // Loads the material system projection matrix based on the fov, etc.
  88. void LoadProjectionMatrix( int nDisplayWidth, int nDisplayHeight );
  89. // Sets the studiorender state
  90. void LoadStudioRenderCameraState();
  91. CDmaVar< float > m_flFieldOfView;
  92. CDmaVar< float > m_zNear;
  93. CDmaVar< float > m_zFar;
  94. CDmaVar< float > m_flFocalDistance;
  95. CDmaVar< float > m_flZeroParallaxDistance;
  96. CDmaVar< float > m_flEyeSeparation;
  97. CDmaVar< float > m_flAperture;
  98. CDmaTime m_shutterSpeed;
  99. CDmaVar< float > m_flToneMapScale;
  100. CDmaVar< float > m_flAOBias;
  101. CDmaVar< float > m_flAOStrength;
  102. CDmaVar< float > m_flAORadius;
  103. CDmaVar< float > m_flBloomScale;
  104. CDmaVar< float > m_flBloomWidth;
  105. CDmaVar< int > m_nDoFQuality;
  106. CDmaVar< int > m_nMotionBlurQuality;
  107. public:
  108. CDmaVar< bool > m_bOrtho;
  109. // Ortho vars
  110. CDmaVar< Vector > m_vecLookAt[ AXIS_COUNT ];
  111. CDmaVar< float > m_flScale[ AXIS_COUNT ];
  112. CDmaVar< float > m_flDistance;
  113. CDmaVar< int > m_nAxis;
  114. CDmaVar< bool > m_bWasBehindFrustum;
  115. private: // private ortho vars
  116. Vector m_vecAxis;
  117. Vector m_vecOrigin;
  118. QAngle m_angRotation;
  119. matrix3x4_t m_Transform;
  120. };
  121. #endif // DMECAMERA_H