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.

77 lines
1.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Heightfield class
  4. //
  5. // $Revision: $
  6. // $NoKeywords: $
  7. //===========================================================================//
  8. #ifndef HEIGHTFIELD_H
  9. #define HEIGHTFIELD_H
  10. #ifdef _WIN32
  11. #pragma once
  12. #endif
  13. #include "materialsystem/MaterialSystemUtil.h"
  14. //-----------------------------------------------------------------------------
  15. // Forward declarations
  16. //-----------------------------------------------------------------------------
  17. class CMeshBuilder;
  18. //-----------------------------------------------------------------------------
  19. // Definition of a heightfield
  20. //-----------------------------------------------------------------------------
  21. class CHeightField
  22. {
  23. public:
  24. CHeightField( int nPowX, int nPowY, int nPowScale );
  25. ~CHeightField();
  26. // Loads the heights from a file
  27. bool LoadHeightFromFile( const char *pFileName );
  28. // Returns the max range of x, y
  29. int GetWidth();
  30. int GetHeight();
  31. // Returns the height of the field at a paticular (x,y)
  32. float GetHeight( float x, float y );
  33. float GetHeightAndSlope( float x, float y, float *dx, float *dy );
  34. // Draws the heightfield
  35. void Draw( );
  36. private:
  37. int m_nPowX;
  38. int m_nPowY;
  39. int m_nWidth;
  40. int m_nHeight;
  41. int m_nScale;
  42. int m_nPowScale;
  43. float m_flOOScale;
  44. float *m_pHeightField;
  45. CMaterialReference m_Material;
  46. CTextureReference m_Texture;
  47. };
  48. //-----------------------------------------------------------------------------
  49. // Returns the max range of x, y (for use in GetHeight)
  50. //-----------------------------------------------------------------------------
  51. inline int CHeightField::GetWidth()
  52. {
  53. return m_nWidth << m_nPowScale;
  54. }
  55. inline int CHeightField::GetHeight()
  56. {
  57. return m_nHeight << m_nPowScale;
  58. }
  59. #endif // HEIGHTFIELD_H