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.

163 lines
3.4 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: This module contains helper functions for use with scratch pads.
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef SCRATCHPADUTILS_H
  8. #define SCRATCHPADUTILS_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "iscratchpad3d.h"
  13. // Use this to make a graph.
  14. class CScratchPadGraph
  15. {
  16. public:
  17. typedef int LineID;
  18. CScratchPadGraph();
  19. // Initialze the orientation and scales of the two axes.
  20. // Axis indices are 0, 1, or 2 for x, y, and z.
  21. void Init(
  22. IScratchPad3D *pPad,
  23. Vector vTimeAxis = Vector(0,-1,0),
  24. float flInchesPerSecond=1,
  25. Vector vTimeLineColor=Vector(0,0,1),
  26. float flTimeOrigin=0, // Where the origin of the graph is.
  27. float flTimeLabelEveryNSeconds=1,
  28. Vector vValueAxis = Vector(0,0,1),
  29. float flInchesPerValue=1,
  30. Vector vValueLineColor=Vector(1,0,0),
  31. float flValueOrigin=0 // Where the origin of the graph is.
  32. );
  33. bool IsInitted() const;
  34. // Add another line into the graph.
  35. LineID AddLine( Vector vColor );
  36. void AddSample( LineID iLine, float flTime, float flValue );
  37. void AddVerticalLine( float flTime, float flMinValue, float flMaxValue, const CSPColor &vColor );
  38. // Get the 3D position of a sample on the graph (so you can draw other things there).
  39. Vector GetSamplePosition( float flTime, float flValue );
  40. private:
  41. void UpdateTicksAndStuff( float flTime, float flValue );
  42. private:
  43. class CLineInfo
  44. {
  45. public:
  46. bool m_bFirst;
  47. float m_flLastTime;
  48. float m_flLastValue;
  49. Vector m_vColor;
  50. };
  51. IScratchPad3D *m_pPad;
  52. CUtlVector<CLineInfo> m_LineInfos;
  53. Vector m_vTimeAxis;
  54. float m_flInchesPerSecond;
  55. Vector m_vValueAxis;
  56. float m_flInchesPerValue;
  57. // How often to make a time label.
  58. float m_flTimeLabelEveryNSeconds;
  59. int m_nTimeLabelsDrawn;
  60. Vector m_vTimeLineColor;
  61. Vector m_vValueLineColor;
  62. float m_flTimeOrigin;
  63. float m_flValueOrigin;
  64. // Used to extend the value border.
  65. float m_flHighestValue;
  66. float m_flHighestTime;
  67. };
  68. // Draw a cone.
  69. void ScratchPad_DrawLitCone(
  70. IScratchPad3D *pPad,
  71. const Vector &vBaseCenter,
  72. const Vector &vTip,
  73. const Vector &vBrightColor,
  74. const Vector &vDarkColor,
  75. const Vector &vLightDir,
  76. float baseWidth,
  77. int nSegments );
  78. // Draw a cylinder.
  79. void ScratchPad_DrawLitCylinder(
  80. IScratchPad3D *pPad,
  81. const Vector &v1,
  82. const Vector &v2,
  83. const Vector &vBrightColor,
  84. const Vector &vDarkColor,
  85. const Vector &vLightDir,
  86. float width,
  87. int nSegments );
  88. // Draw an arrow.
  89. void ScratchPad_DrawArrow(
  90. IScratchPad3D *pPad,
  91. const Vector &vPos,
  92. const Vector &vDirection,
  93. const Vector &vColor,
  94. float flLength=20,
  95. float flLineWidth=3,
  96. float flHeadWidth=8,
  97. int nCylinderSegments=5,
  98. int nHeadSegments=8,
  99. float flArrowHeadPercentage = 0.3f // How much of the line is the arrow head.
  100. );
  101. // Draw an arrow with less parameters.. it generates parameters based on length
  102. // automatically to make the arrow look good.
  103. void ScratchPad_DrawArrowSimple(
  104. IScratchPad3D *pPad,
  105. const Vector &vPos,
  106. const Vector &vDirection,
  107. const Vector &vColor,
  108. float flLength );
  109. void ScratchPad_DrawSphere(
  110. IScratchPad3D *pPad,
  111. const Vector &vCenter,
  112. float flRadius,
  113. const Vector &vColor,
  114. int nSubDivs=7 );
  115. void ScratchPad_DrawAABB(
  116. IScratchPad3D *pPad,
  117. const Vector &vMins,
  118. const Vector &vMaxs,
  119. const Vector &vColor = Vector( 1,1,1 ) );
  120. #endif // SCRATCHPADUTILS_H