Terrain.h

Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 5 -*- */
00002 
00003 /*
00004  * Combination of a first person action and a real time strategy battle game.
00005  */
00006  
00007 /*
00008  * Terrain.h
00009  * MetalWarriors
00010  * $Revision: 1.32 $
00011  *
00012  * Created by Daniel Aarno on Sat Oct 18 2003.
00013  * Copyright (c) 2003 - 2007 Daniel Aarno and Erik Ytterberg
00014  * All rights reserved.
00015  *
00016  *     This program is free software; you can redistribute it and/or modify
00017  *     it under the terms of the GNU General Public License as published by
00018  *     the Free Software Foundation; either version 2 of the License, or
00019  *     (at your option) any later version.
00020  *
00021  *     This program is distributed in the hope that it will be useful,
00022  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
00023  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00024  *     GNU General Public License for more details.
00025  *
00026  *     You should have received a copy of the GNU General Public License
00027  *     along with this program; if not, write to the Free Software
00028  *     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00029  */
00030 
00031 #ifndef _TERRAIN_
00032 #define _TERRAIN_
00033 
00034 #include <Demeter/Terrain.h>
00035 #undef VERSION //we don't care about demeters stupid exported version info
00036 #undef PACKAGE 
00037 #undef PACKAGE_VERSION
00038 #undef PACKAGE_TARNAME
00039 #undef PACKAGE_STRING
00040 #undef PACKAGE_NAME
00041 #undef PACKAGE_BUGREPORT
00042 
00043 #include "Sprite.h"
00044 #include "Skydome.h"
00045 #include "Texture.h"
00046 #include "SpaceOrg.h"
00047 #include "undefs.h"
00048 #include "config.h"
00049 #include "Mission.h"
00050 
00051 
00052 #ifndef NINLINE
00053 #define INLINE inline
00054 #else
00055 #define INLINE 
00056 #endif
00057 
00058 typedef struct
00059 {
00060      float xMin;
00061      float xMax;
00062      float yMin;
00063      float yMax;
00064 } WorldSize;
00065 
00066 INLINE void Normalize(float normal[]);
00067 void FlipNormal(float normal[]);
00068 
00069 
00070 class Terrain
00071 {
00072 public:
00073      float **grid;
00074      int x,y;
00075      float spacing, scale;
00076      float camera_position[3];
00077      float camera_view_vector[3];
00078      float camera_view_comp_vector[3];
00079      
00080      Demeter::Terrain *pTerrain;
00081      float *linear_grid;
00082      Uint8 *shadow_map;
00083      Uint8 *detail_tex;
00084      
00085      Skydome *sky;
00086      
00087      float cam_x, cam_y;
00088      char initState;
00089      
00090      SpaceOrg *space;
00091      
00092 public:
00093      Terrain();
00094      Terrain(MissionDef *mission_spec);
00095      virtual ~Terrain(void);
00096      
00097      bool doIncrementalInit(void);
00098      virtual void paint();
00099      virtual void update();
00100      float getHeight(float x_query, float y_query);
00101      WorldSize getSize();
00102      void getNormal(float x_query, float y_query, float real_normal[]);
00103      bool PointInFrustum(float x_query, float y_query);
00104      bool CubeInFrustum(float x_query, float y_query, float width, float length);
00105      
00106 protected:
00107      void generateRandomTerrain(int size, int variance);
00108      void doubleGridSize(void);
00109      void calculateNormal(int x_coord, int y_coord, float *normal1, int step);
00110      void CalcShadowMap(float *light);
00111      float *readHeightMap(char *filename);
00112      
00113 };
00114 
00115 #endif //_TERRAIN_

Generated on Sun Mar 11 15:33:24 2007 for MetalWarriors by  doxygen 1.4.7