Vertex.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. //---------------------------------------------------------------------------
  2. //
  3. // Vertex.h -- File contains class definitions for the Terrain Vertices
  4. //
  5. // MechCommander 2
  6. //
  7. //---------------------------------------------------------------------------//
  8. // Copyright (C) Microsoft Corporation. All rights reserved. //
  9. //===========================================================================//
  10. #ifndef VERTEX_H
  11. #define VERTEX_H
  12. //---------------------------------------------------------------------------
  13. // Include Files
  14. #ifndef DVERTEX_H
  15. #include "dvertex.h"
  16. #endif
  17. #include <stuff\stuff.hpp>
  18. //---------------------------------------------------------------------------
  19. // Macro Definitions
  20. #define BOTTOMRIGHT 0
  21. #define BOTTOMLEFT 1
  22. #ifndef NO_ERR
  23. #define NO_ERR 0
  24. #endif
  25. //---------------------------------------------------------------------------
  26. // Classes
  27. struct PostcompVertex
  28. {
  29. //---------------------------------------------------
  30. // This Structure is used to store the data the 3D
  31. // version of the terrain uses so I don't have to
  32. // recalculate it every frame!
  33. //
  34. // Replaces the pVertex pointer in Vertex Class
  35. Stuff::Vector3D vertexNormal; //Used for lighting
  36. float elevation; //Stored here so terrain can be locally deformed
  37. DWORD textureData; //Top word is Overlay TXM, Bottom Word is Base TXM
  38. DWORD localRGBLight; //aRGB format
  39. DWORD terrainType; //terrainTypeNumber.
  40. BYTE selected; // selection
  41. BYTE water; //Additional Storage to pull into 16 Byte Alignment
  42. BYTE shadow;
  43. BYTE highlighted; //Used to highlight WHOLE FACES!!!
  44. float getElevation (void)
  45. {
  46. return elevation;
  47. }
  48. PostcompVertex& operator=( const PostcompVertex& src );
  49. PostcompVertex( const PostcompVertex& );
  50. PostcompVertex();
  51. };
  52. typedef PostcompVertex *PostcompVertexPtr;
  53. //---------------------------------------------------------------------------
  54. class Vertex
  55. {
  56. //Data Members
  57. //-------------
  58. public:
  59. PostcompVertexPtr pVertex; //Pointer to PostcompVertex for this Vertex
  60. float vx,vy; //Unrotated World Coordinates of Vertex
  61. float px,py; //Screen Coordinates of vertex.
  62. float pz,pw; //Depth of vertex.
  63. long vertexNum; //Physical Vertex Position in mapData
  64. //Used by new Object positioning system.
  65. long blockVertex; //What terrain block is this vertex part of.vertexNumber;
  66. //What vertex number in the block
  67. long posTile; //Where are we on the tile! Saves 24 divides per tile if overlay on tile!!!
  68. //Saves a mere 8 if no overlay!
  69. DWORD clipInfo; //Stores data on vertex clip information.
  70. DWORD lightRGB; //Light at this vertex.
  71. DWORD fogRGB; //Fog at this vertex.
  72. float wx,wy; //Screen Coordinates of water face if there is one!
  73. float wz,ww; //Depth of vertex for water if there is one!
  74. float wAlpha; //Used to environment Map Sky onto water.
  75. DWORD calcThisFrame; //Calced this vertex this frame?
  76. float hazeFactor; //Used to distance fog the terrain.
  77. #ifdef _DEBUG
  78. bool selected; //Debug to show which triangle I am on.
  79. #endif
  80. //Member Functions
  81. //-----------------
  82. public:
  83. void init (void)
  84. {
  85. pVertex = NULL;
  86. px = py = 0.0f;
  87. pz = pw = 0.0f;
  88. wx = wy = 0.0f;
  89. wz = ww = 0.0f;
  90. posTile = -1;
  91. vertexNum = -1;
  92. lightRGB = fogRGB = 0xffffffff;
  93. calcThisFrame = false;
  94. }
  95. Vertex (void)
  96. {
  97. init();
  98. }
  99. void destroy (void)
  100. {
  101. }
  102. ~Vertex (void)
  103. {
  104. destroy();
  105. }
  106. long init (PostcompVertexPtr preVertex)
  107. {
  108. init();
  109. pVertex = preVertex;
  110. return(NO_ERR);
  111. }
  112. long getBlockNumber (void)
  113. {
  114. return (blockVertex>>16);
  115. }
  116. long getVertexNumber (void)
  117. {
  118. return (blockVertex & 0x0000ffff);
  119. }
  120. };
  121. //---------------------------------------------------------------------------
  122. extern long numTerrainFaces;
  123. //---------------------------------------------------------------------------
  124. #endif