www.pudn.com > 3dterrain.zip > Terrain.h


// Terrain.h: interface for the Terrain class. 
// 
////////////////////////////////////////////////////////////////////// 
 
#if !defined(AFX_TERRAIN_H__BAB75D09_6076_40B7_8BA9_C40E2DC771B6__INCLUDED_) 
#define AFX_TERRAIN_H__BAB75D09_6076_40B7_8BA9_C40E2DC771B6__INCLUDED_ 
 
#if _MSC_VER > 1000 
#pragma once 
#endif // _MSC_VER > 1000 
#include "init.h" 
#include "OcTree_Terrain.h" 
#include "load_texture.h" 
#include  
#include "Loader.h" 
using namespace std; 
 
#ifndef PI180 
#define PI180	0.0174532925199432957692369076848861f	// pi / 180 
#endif 
 
// struct cast_pasu{int left,right;}; 
struct Sprechod 
{ 
	unsigned short int x;//,z; 
	unsigned char typ;				// typ prechodu 
//	unsigned short int textura;		// cislo textury 
 
//	unsigned char typ_a;			// typ prechodu 
//	unsigned char typ_b;			// typ prechodu 
//	unsigned short int a;		// cislo textury 
//	unsigned short int b;		// cislo textury 
}; 
 
struct volumetric_sphere 
{ 
	float	p[3]; 
	float	r; 
	float	hustota; 
}; 
 
struct volumetric_plate 
{ 
	float low[4]; 
	float high[4]; 
	float hustota; 
	volumetric_plate(){	low[0] = 0.f; low[1] = 1.f; low[2] = 0.f; low[3] = 0.f;	high[0]= 0.f; high[1]= 1.f; high[2]= 0.f; high[3]= 100.f;	hustota = 0.01f;	} 
}; 
 
#define _01		0 
#define _10		1 
#define __01	2 
#define __10	3 
#define _0001	4 
#define _1110	5 
#define _0100	6 
#define _1011	7 
#define _0010	8 
#define _1101	9 
#define _1000	10 
#define _0111	11 
#define _0110	12 
#define _1001	13 
 
typedef struct 
{ float x,z;}XZ; 
 
class Terrain   
{ 
	unsigned char* height_map;			// pole obsahujuce informacie o vyske 
	int	height_map_x,height_map_z;		// velkost obrazka vyskovej mapy 
	unsigned char* texture_map;			// pole obsahujuce informacie o texture 
	int texture_map_x,texture_map_z;	// velkost obrazka texturovej mapy 
	unsigned int* texture;				// pole cisel textur 
	int pocet_textur; 
	float size_OpenGL_x,size_OpenGL_z;	// velkost plochy v OpenGL 
	int	split_x,split_z;				// delenie plochy v OpenGL 
 
	float scale_height;					// mierka vysky 
	float	*vertex;					// vrcholy terenu 
	float	*normal;					// normaly 
	float	*colors;					// farby pre kazdy vrchol 
	float	*fog;						// pre kazdy vrchol sila hmly z intervalu <0,1> 
	 
	vector *pasy;			// pasy ktore sa kreslia 
	vector *prechod;			// prechody medzi stvorcami 
	vector volum_fog; 
	vector volum_fog_plate; 
 
public: 
	float Diffuse, Ambient;				// osvetlenie terenu 
	OcTree_Terrain	*OcTree; 
	int		triangles;					// pocitadlo trojuholnikov 
 
public: 
	void Maz_fog(); 
	void Vypocitaj_Volumetric_Fog_Plate(float *vp); 
	void Vypocitaj_Volumetric_Fog_Sphere(float *vp, CFrustum *Frustum); 
	void Vypocitaj_Fog( float *vp, float clip_distance); 
	void Kresli_Fog(); 
	void Kresli_glBegin_colors(); 
	void Vypocitaj_osvetlenie( float *p); 
	void Kresli_normaly(); 
	void Kresli_glBegin_normal(); 
	void Vypocitaj_normalove_vektory(); 
	void Usporiadanie_prechodov(); 
	inline bool Je_v_pohlade( unsigned short int x, vector *p); 
	void Vypln_prechody_stvorcov(); 
	void Vypln_prechody_stvorcov(unsigned char a, unsigned char b); 
	void Kresli_(void); 
	void Kresli_glBegin(void); 
	unsigned int Textura(int x, int z); 
	void Vypln_polia_vrcholov(float x, float dx, float z, float dz); 
	void SaveTextura_map(void); 
	float Height(float x, float z); 
	void GetString(char* temp, int size_temp, FILE* sub); 
	Terrain(char * subor); 
	Terrain(); 
	~Terrain(); 
}; 
 
#endif // !defined(AFX_TERRAIN_H__BAB75D09_6076_40B7_8BA9_C40E2DC771B6__INCLUDED_)