123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- //---------------------------------------------------------------------------
- //
- // Quad.h -- File contains class definitions for the Terrain Quads
- //
- // MechCommander 2
- //
- //---------------------------------------------------------------------------//
- // Copyright (C) Microsoft Corporation. All rights reserved. //
- //===========================================================================//
- #ifndef QUAD_H
- #define QUAD_H
- //---------------------------------------------------------------------------
- // Include Files
- #ifndef DQUAD_H
- #include "dquad.h"
- #endif
- #ifndef DVERTEX_H
- #include "dvertex.h"
- #endif
- #ifndef DSTD_H
- #include "dstd.h"
- #endif
- //---------------------------------------------------------------------------
- typedef struct _TerrainUVData
- {
- float minU;
- float minV;
- float maxU;
- float maxV;
- } TerrainUVData;
- typedef struct _MineResult
- {
- DWORD mineData;
-
- void init (void)
- {
- mineData = 0;
- }
-
- void setMine (DWORD pos, unsigned char data)
- {
- DWORD result = (data << (pos << 1));
- mineData |= result;
- }
-
- DWORD getMine(DWORD pos)
- {
- DWORD result = (mineData >> (pos << 1)) & (0x3);
- return result;
- }
-
- } MineResult;
- class TerrainQuad
- {
- //Data Members
- //-------------
- public:
- VertexPtr vertices[4]; //Pointers to vertices defining this tile.
- DWORD terrainHandle; //Handle to texture to draw.
- DWORD terrainDetailHandle; //Handle to detail texture to draw.
- DWORD waterHandle; //Handle to water texture to draw.
- DWORD waterDetailHandle; //Handle to Water Detail texture to draw.
- DWORD overlayHandle; //Handle to overlay texture to draw.
- DWORD uvMode; //Is this a top or bottom triangle?
- MineResult mineResult; //Is there a mine or exploded mine in this cell on this tile?
-
- TerrainUVData uvData; //Stores the min and max UVs for this face.
-
- bool isCement; //Need to know if this tile is cement for a number of reasons
-
- static float rainLightLevel; //How much to darken terrain based on rain
- static DWORD lighteningLevel; //How much to lighten terrain based on lightening.
- static DWORD mineTextureHandle; //Handle to the mine textures.
- static DWORD blownTextureHandle;
-
- #ifdef _DEBUG
- bool selected; //Debug to show which triangle I am on.
- #endif
- //Member Functions
- //-----------------
- public:
- void init (void)
- {
- for (int i=0;i<4;i++)
- vertices[i] = NULL;
-
- terrainHandle = 0xffffffff;
- terrainDetailHandle = 0xffffffff;
- waterHandle = 0xffffffff;
- waterDetailHandle = 0xffffffff;
- uvMode = 0;
-
- uvData.maxU = uvData.minU = uvData.minV = uvData.maxV = 0.0f;
-
- mineResult.init();
-
- isCement = false;
- }
- TerrainQuad (void)
- {
- init();
- }
- void destroy (void)
- {
- }
- ~TerrainQuad (void)
- {
- destroy();
- }
- long init (VertexPtr v0, VertexPtr v1, VertexPtr v2, VertexPtr v3);
- void setupTextures (void);
- void draw (void);
- void drawMine (void);
- void drawLine (void);
- void drawDebugCellLine (void);
- void drawLOSLine (void);
- void drawWater (void);
- };
- //---------------------------------------------------------------------------
- #endif
|