Team Fortress 2 Source Code as on 22/4/2020
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.

119 lines
4.9 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //===========================================================================//
  7. #if !defined( BEAMSEGDRAW_H )
  8. #define BEAMSEGDRAW_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #define NOISE_DIVISIONS 128
  13. #include "mathlib/vector.h"
  14. #include "materialsystem/imesh.h"
  15. //-----------------------------------------------------------------------------
  16. // Forward declarations
  17. //-----------------------------------------------------------------------------
  18. struct BeamTrail_t;
  19. class IMaterial;
  20. //-----------------------------------------------------------------------------
  21. // CBeamSegDraw is a simple interface to beam rendering.
  22. //-----------------------------------------------------------------------------
  23. struct BeamSeg_t
  24. {
  25. Vector m_vPos;
  26. Vector m_vColor;
  27. float m_flTexCoord; // Y texture coordinate
  28. float m_flWidth;
  29. float m_flAlpha;
  30. };
  31. class CBeamSegDraw
  32. {
  33. public:
  34. CBeamSegDraw() : m_pRenderContext( NULL ) {}
  35. // Pass null for pMaterial if you have already set the material you want.
  36. void Start( IMatRenderContext *pRenderContext, int nSegs, IMaterial *pMaterial=0, CMeshBuilder *pMeshBuilder = NULL, int nMeshVertCount = 0 );
  37. virtual void NextSeg( BeamSeg_t *pSeg );
  38. void End();
  39. protected:
  40. void SpecifySeg( const Vector &vecCameraPos, const Vector &vNextPos );
  41. void ComputeNormal( const Vector &vecCameraPos, const Vector &vStartPos, const Vector &vNextPos, Vector *pNormal );
  42. CMeshBuilder *m_pMeshBuilder;
  43. int m_nMeshVertCount;
  44. CMeshBuilder m_Mesh;
  45. BeamSeg_t m_Seg;
  46. int m_nTotalSegs;
  47. int m_nSegsDrawn;
  48. Vector m_vNormalLast;
  49. IMatRenderContext *m_pRenderContext;
  50. };
  51. class CBeamSegDrawArbitrary : public CBeamSegDraw
  52. {
  53. public:
  54. void SetNormal( const Vector &normal );
  55. void NextSeg( BeamSeg_t *pSeg );
  56. protected:
  57. void SpecifySeg( const Vector &vNextPos );
  58. BeamSeg_t m_PrevSeg;
  59. };
  60. #if 0
  61. int ScreenTransform( const Vector& point, Vector& screen );
  62. void DrawSegs( int noise_divisions, float *prgNoise, const model_t* spritemodel,
  63. float frame, int rendermode, const Vector& source, const Vector& delta,
  64. float startWidth, float endWidth, float scale, float freq, float speed, int segments,
  65. int flags, float* color, float fadeLength, float flHDRColorScale = 1.0f );
  66. void DrawTeslaSegs( int noise_divisions, float *prgNoise, const model_t* spritemodel,
  67. float frame, int rendermode, const Vector& source, const Vector& delta,
  68. float startWidth, float endWidth, float scale, float freq, float speed, int segments,
  69. int flags, float* color, float fadeLength, float flHDRColorScale = 1.0f );
  70. void DrawSplineSegs( int noise_divisions, float *prgNoise,
  71. const model_t* beammodel, const model_t* halomodel, float flHaloScale,
  72. float frame, int rendermode, int numAttachments, Vector* attachment,
  73. float startWidth, float endWidth, float scale, float freq, float speed, int segments,
  74. int flags, float* color, float fadeLength, float flHDRColorScale = 1.0f );
  75. void DrawHalo(IMaterial* pMaterial, const Vector& source, float scale, float const* color, float flHDRColorScale = 1.0f );
  76. void BeamDrawHalo( const model_t* spritemodel, float frame, int rendermode, const Vector& source,
  77. float scale, float* color, float flHDRColorScale = 1.0f );
  78. void DrawDisk( int noise_divisions, float *prgNoise, const model_t* spritemodel,
  79. float frame, int rendermode, const Vector& source, const Vector& delta,
  80. float width, float scale, float freq, float speed,
  81. int segments, float* color, float flHDRColorScale = 1.0f );
  82. void DrawCylinder( int noise_divisions, float *prgNoise, const model_t* spritemodel,
  83. float frame, int rendermode, const Vector& source,
  84. const Vector& delta, float width, float scale, float freq,
  85. float speed, int segments, float* color, float flHDRColorScale = 1.0f );
  86. void DrawRing( int noise_divisions, float *prgNoise, void (*pfnNoise)( float *noise, int divs, float scale ),
  87. const model_t* spritemodel, float frame, int rendermode,
  88. const Vector& source, const Vector& delta, float width, float amplitude,
  89. float freq, float speed, int segments, float* color, float flHDRColorScale = 1.0f );
  90. void DrawBeamFollow( const model_t* spritemodel, BeamTrail_t* pHead, int frame, int rendermode, Vector& delta,
  91. Vector& screen, Vector& screenLast, float die, const Vector& source,
  92. int flags, float width, float amplitude, float freq, float* color, float flHDRColorScale = 1.0f );
  93. void DrawBeamQuadratic( const Vector &start, const Vector &control, const Vector &end, float width, const Vector &color, float scrollOffset, float flHDRColorScale = 1.0f );
  94. #endif
  95. //-----------------------------------------------------------------------------
  96. // Assumes the material has already been bound
  97. //-----------------------------------------------------------------------------
  98. void DrawSprite( const Vector &vecOrigin, float flWidth, float flHeight, color32 color );
  99. #endif // BEAMDRAW_H