00001 /*************************************************************************** 00002 ground.h - description 00003 ------------------- 00004 begin : Sat Jul 21 2001 00005 copyright : (C) 2001 by T Kontkanen 00006 email : tkontkanen@mail.com 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 00018 #ifndef GROUND_H 00019 #define GROUND_H 00020 00021 #include <Terrain.h> //demeter header 00022 #include "game.h" 00023 #include "allincludes.h" 00024 #include "renderer.h" 00025 00029 //using namespace Demeter; 00030 00031 //class Ground : public Renderer { 00032 class Ground { 00033 public: 00034 Ground( Game *parentGame ); 00035 // Ground( Renderer *myRenderer ); 00036 ~Ground(); 00037 int loadMap( const char *fname ); 00038 void unloadMap(); 00039 00040 //rendering 00042 void cameraMoved(); 00044 void renderTerrain(); 00046 void toggleTesslation(); 00047 00048 // get information 00049 float getElevation( float x, float y ) const; //Returns the elevation (z-coordinate) in real units of the specified terrain vertex. (comment ripped from demeter's reference) 00050 float getTerrainWidth() const; //Returns the width of the terrain in real units (this is the length of the terrain along the world's x-axis.) (comment ripped from demeter's reference) 00051 float getTerrainHeight() const; //Returns the height of the terrain in real units (this is the length of the terrain along the world's z-axis.) (comment ripped from demeter's reference) 00052 00053 //helpers 00054 void setBit( unsigned char *buffer, unsigned int bitnum, bool state ); 00055 bool getBit( unsigned char *buffer, unsigned int bitnum ) const; 00056 void setMapReservationPoint( float x, float y, bool state ); // place a marker to area to prevent other units colliding 00057 bool getMapReservationPoint( float x, float y ) const; // get state of area reservation 00058 bool getMapReservationLine( float x1, float y1, float x2, float y2 ) const; // return true if way from (x1,y1) to (x2,y2) is blocked, else return false 00059 void setMapReservationLine( float x1, float y1, float x2, float y2, bool state ); // set reservation for line (x1,y2)->(x2,y2) 00060 bool isSameReservationPoint( float x, float y, float x2, float y2 ) const; // return true if (x,y) is in same reservation area with (x2,y2) 00061 private: 00062 void swapInts( int &i1, int &i2 ) const { // swap values of two integers 00063 int i=i1; 00064 i1=i2; 00065 i2=i; 00066 } 00067 00068 Game *game; 00069 Renderer *renderer; 00070 00072 Demeter::Settings *settings; //demeter settings 00073 Demeter::Terrain *terrain; //demeter terrain 00074 unsigned char *groundGrid; // reservation map=1-bit grid that determines where units are able to move etc. resolution can be changed in gamedefs.h 00075 int grid_h, grid_w, grid_w_bytes; //allocated grid dimensions 00076 float sealevel; 00077 bool terrainrefreshing; // if true, tesslate ground 00078 }; 00079 00080 #endif