123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- //---------------------------------------------------------------------------
- //
- // MapData.h -- File contains class definitions for the Terrain Mesh
- //
- // MechCommander 2
- //
- //---------------------------------------------------------------------------//
- // Copyright (C) Microsoft Corporation. All rights reserved. //
- //===========================================================================//
- #ifndef MAPDATA_H
- #define MAPDATA_H
- //---------------------------------------------------------------------------
- // Include Files
- #ifndef DMAPDATA_H
- #include "dmapdata.h"
- #endif
- #ifndef HEAP_H
- #include "heap.h"
- #endif
- #ifndef PACKET_H
- #include "packet.h"
- #endif
- #ifndef VERTEX_H
- #include "vertex.h"
- #endif
- #ifndef QUAD_H
- #include "quad.h"
- #endif
- #include <stuff\stuff.hpp>
- //---------------------------------------------------------------------------
- enum Overlays
- {
- INVALID_OVERLAY = -1,
- DIRT_ROAD = 0,
- PAVED_ROAD = 1,
- ROUGH = 2,
- DIRT_ROAD_TO_PAVED_ROAD = 3,
- PAVED_ROAD_CROSSING_DIRT_ROAD = 4,
- TWO_LANE_DIRT_ROAD = 5,
- DAMAGED_ROAD = 6,
- RUNWAY = 7,
- X_DIRT_PAVED = 8,
- X_DIRT_2LANEDIRT = 9,
- X_DIRT_DAMAGED = 10,
- X_2LANEDIRT_PAVED = 11,
- X_DAMAGED_PAVED = 12,
- X_2LANEDIRT_DAMAGED = 13,
- OBRIDGE = 14,
- X_PAVED_ROAD_BRIDGE = 15,
- DAMAGED_BRIDGE = 16,
- NUM_OVERLAY_TYPES = 17
- };
- //---------------------------------------------------------------------------
- // Classes
- class MapData : public HeapManager
- {
- //Data Members
- //-------------
- protected:
- PostcompVertexPtr blocks;
- PostcompVertexPtr blankVertex;
- int hasSelection;
-
- public:
- Stuff::Vector2DOf<float> topLeftVertex;
- static float shallowDepth;
- static float waterDepth;
- static float alphaDepth;
- static DWORD WaterTXMData;
- //Member Functions
- //-----------------
- public:
- void *operator new (size_t mySize);
- void operator delete (void *us);
-
- void init (void)
- {
- HeapManager::init();
- topLeftVertex.Zero();
- blocks = NULL;
- blankVertex = NULL;
- hasSelection = false;
- shallowDepth = 0.0f;
- waterDepth = 0.0f;
- alphaDepth = 0.0f;
- WaterTXMData = 0xffffffff;
- }
- MapData (void) : HeapManager()
- {
- init();
- }
- void destroy (void);
-
- ~MapData (void)
- {
- destroy();
- }
- long init (char *fileName, long numBlocks, long blockSize);
- void newInit (PacketFile* file, long numVertices);
- void newInit (long numVertices);
- long update (void);
- void makeLists (VertexPtr vertexList, long &numVerts, TerrainQuadPtr quadList, long &numTiles);
-
- Stuff::Vector2DOf<float> getTopLeftVertex (void)
- {
- return topLeftVertex;
- }
- void calcLight (void);
- void clearShadows();
-
- float terrainElevation (Stuff::Vector3D &position);
- float terrainElevation ( long tileR, long tileC );
- float terrainAngle (Stuff::Vector3D &position, Stuff::Vector3D* normal = NULL);
- Stuff::Vector3D terrainNormal (Stuff::Vector3D& position);
- float terrainLight (Stuff::Vector3D& position);
-
- float getTopLeftElevation (void);
-
- // old overlay stuff
- void setOverlayTile (long block, long vertex, long offset);
- long getOverlayTile (long block, long vertex);
- // new overlay stuff
- void setOverlay( long tileR, long tileC, Overlays type, unsigned long Offset );
- void getOverlay( long tileR, long tileC, Overlays& type, unsigned long& Offset );
- void setTerrain( long tileR, long tileC, int terrainType );
- long getTerrain( long tileR, long tileC );
- void setVertexHeight( int vertexIndex, float value );
- float getVertexHeight( int vertexIndex );
- PostcompVertexPtr getData (void)
- {
- return blocks;
- }
- unsigned long getTexture( long tileR, long tileC );
- long save( PacketFile* file, int whichPacket);
- void calcWater (float waterDepth, float waterShallowDepth, float waterAlphaDepth);
- void recalcWater (void); //Uses above values already passed in to just recalc the water
-
- float waterElevation () { return waterDepth; }
- void markSeen (Stuff::Vector2DOf<float> &topLeftPosition, VertexPtr vertexList, Stuff::Vector3D &looker, Stuff::Vector3D &lookVector, float cone, float dist, byte who);
- void unselectAll();
- void unhighlightAll();
- void highlightAllTransitionsOver2 (void);
- void selectVertex( unsigned long tileRow, unsigned long tileCol, bool bSelect, bool bToggle );
- bool selection(){ return hasSelection ? true : false; }
- bool isVertexSelected( unsigned long tileRow, unsigned long tileCol );
- void calcTransitions();
- };
- //-----------------------------------------------------------------------------------------------
- #endif
|