00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
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_