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.

155 lines
3.6 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef UIGEOMETRY_H
  8. #define UIGEOMETRY_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "tier1/utlvector.h"
  13. #include "tier1/timeutils.h"
  14. #include "materialsystem/materialsystemutil.h"
  15. #include "bitmap/psheet.h"
  16. #include "resourcesystem/stronghandle.h"
  17. #include "rendersystem/irenderdevice.h"
  18. struct StageRenderInfo_t;
  19. class CGraphicGroup;
  20. //-----------------------------------------------------------------------------
  21. // Geometry makes an array of triangles by indexing into the point data
  22. //-----------------------------------------------------------------------------
  23. class CTriangle
  24. {
  25. public:
  26. int m_PointIndex[3];
  27. };
  28. //-----------------------------------------------------------------------------
  29. //
  30. //-----------------------------------------------------------------------------
  31. class CRenderGeometry
  32. {
  33. public:
  34. int GetTriangleCount();
  35. int GetVertexCount();
  36. DmeTime_t GetAnimStartTime();
  37. CUtlVector< Vector2D > m_Positions;
  38. CUtlVector< Vector2D > m_TextureCoords;
  39. CUtlVector< color32 > m_VertexColors;
  40. CUtlVector< CTriangle > m_Triangles;
  41. union
  42. {
  43. int m_SheetSequenceNumber;
  44. int m_FontTextureID;
  45. };
  46. float m_AnimationRate;
  47. DmeTime_t m_AnimStartTime;
  48. bool m_bAnimate;
  49. const char *m_pImageAlias;
  50. };
  51. typedef CUtlVector< CRenderGeometry > RenderGeometryList_t;
  52. struct LayerRenderLists_t
  53. {
  54. CUtlVector< RenderGeometryList_t > m_RenderGeometryLists;
  55. int m_LayerType;
  56. IMaterial *m_pMaterial;
  57. CSheet *m_pSheet;
  58. HRenderTextureStrong m_hTexture;
  59. };
  60. struct RectExtents_t
  61. {
  62. Vector2D m_TopLeft;
  63. Vector2D m_BottomRight;
  64. };
  65. //-----------------------------------------------------------------------------
  66. //
  67. //-----------------------------------------------------------------------------
  68. class CGeometry
  69. {
  70. public:
  71. CGeometry();
  72. int GetTriangleCount()
  73. {
  74. return m_Triangles.Count();
  75. }
  76. void SetResultantColor( color32 parentColor );
  77. void UpdateRenderTransforms( const StageRenderInfo_t &stageRenderInfo, const CGraphicGroup *pGroup );
  78. void UpdateRenderData( CUtlVector< RenderGeometryList_t > &renderGeometryLists, int firstListIndex );
  79. void GetBounds( Rect_t &bounds );
  80. CUtlVector< Vector2D > m_RelativePositions;
  81. CUtlVector< Vector2D > m_TextureCoords;
  82. CUtlVector< color32 > m_VertexColors;
  83. CUtlVector< CTriangle > m_Triangles;
  84. Vector2D m_Center;
  85. Vector2D m_Scale;
  86. float m_Rotation;
  87. color32 m_Color;
  88. color32 m_TopColor;
  89. color32 m_BottomColor;
  90. bool m_bHorizontalGradient;
  91. int m_SheetSequenceNumber;
  92. float m_AnimationRate;
  93. int m_Sublayer;
  94. bool m_bMaintainAspectRatio;
  95. bool m_bVisible;
  96. DmeTime_t m_AnimStartTime;
  97. bool m_bAnimate;
  98. matrix3x4_t m_RenderToScreen;
  99. matrix3x4_t m_RenderToScreenHoldAspectRatio;
  100. bool m_bDirtyExtents; // if true, recalculate extents on the next render.
  101. RectExtents_t m_Extents;
  102. void CalculateExtents();
  103. void DrawExtents( CUtlVector< RenderGeometryList_t > &renderGeometryLists, int firstListIndex, color32 extentLineColor );
  104. private:
  105. void CalculateExtentsMatrix( const StageRenderInfo_t &stageRenderInfo, const CGraphicGroup *pGroup );
  106. // For applying color gradients
  107. void SetResultantColor( bool bTop, color32 parentColor );
  108. void SetTopVerticesColor( color32 c );
  109. void SetBottomVerticesColor( color32 c );
  110. // Use this matrix to calcuate extents positions on screen.
  111. matrix3x4_t m_ExtentsMatrix;
  112. };
  113. extern bool PointTriangleHitTest( Vector2D tringleVert0, Vector2D tringleVert1, Vector2D tringleVert2, Vector2D point );
  114. #endif // UIGEOMETRY_H