#pragma once #include // Standard-Vektor einschließen #include #include #include "./GameManager.h" #include "./Object3d.h" #include #include #include #include "Node.h" #include "Vector.h" using namespace std; #define SPTR boost::shared_ptr class Terrain : public Node { public: Terrain(void); ~Terrain(void); void generateTerrain(std::string filename, int _numVertsPerRow, int _numVertsPerCol); float getHeight(float x, float y); float getOriginalHeight(float x, float y); float getSizeX(); float getSizeZ(); float getSlopeX(float x, float z); float getSlopeZ(float x, float z); void impact(float x, float z, int power); void setTextures(std::string texture0, std::string texture1, std::string texture2); private: struct Vertex { Vertex(float _x, float _y, float _z, float _nx, float _ny, float _nz, DWORD _color, float _u, float _v) { x = _x; y = _y; z = _z; nx = _nx; ny = _ny; nz = _nz; color = _color; u = _u; v = _v; } float x, y, z; float nx, ny, nz; DWORD color; float u, v; enum FVF { FVF_Flags = D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX1 }; }; std::vector readRawFile(std::string fileName); void createTerrainPatches(); void updatePatch(int patchNumber, int x_top, int z_top, int x_bottom, int z_bottom, int powerRadius, float impactheight, int globalImpCenterX, int globalImpCenterZ, int patch_x, int patch_z); Vector *getNormals(); void loadEffect(); std::vector heightmap; std::vector originalHeightmap; int numVertsPerRow; int numVertsPerCol; float cellSpacing; float heightScale; int numVertices; int patchSize; int numberOfPatches; std::string texture0; std::string texture1; std::string texture2; std::string texture3; std::vector terrainPatches; Vector *normals; D3DMATERIAL9 *standardMats; std::vector Textures; //effect stuff: ID3DXEffect* TerrainEffect; //shader technique: D3DXHANDLE TexHandleTop; D3DXHANDLE TexHandleSlope; D3DXHANDLE TexHandleBottom; D3DXHANDLE AmbientHandle; D3DXHANDLE SunDirectionHandle; D3DXHANDLE ShaderTechHandle; };