Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using namespace std;
- class Terrain
- {
- public:
- struct InitInfo
- {
- wstring HeightmapFileName,
- LayerMapFileName0,
- LayerMapFileName1,
- LayerMapFileName2,
- LayerMapFileName3,
- LayerMapFileName4,
- BlendMapFileName;
- float HeightScale;
- float HeightOffset;
- UINT NumRows;
- UINT NumCols;
- float CellSpacing;
- };
- public:
- Terrain();
- ~Terrain();
- void Init(const InitInfo& info);
- float width()const;
- float depth()const;
- float getHeight(float x, float y)const;
- void SetDirectionToSun(const XMFLOAT3& v);
- void draw(CXMMATRIX world, Camera& cam);
- private:
- void BuildFX();
- void loadHeightMap();
- void Smooth();
- bool inBounds(UINT i, UINT j);
- float average(UINT i, UINT j);
- void BuildVertexBuffer();
- void BuildIndexBuffer();
- private:
- InitInfo mInfo;
- UINT mNumVertices;
- UINT mNumFaces;
- vector<float> mHeightmap;
- ID3DX11Effect* mFX;
- ID3D11Buffer* mVB;
- ID3D11Buffer* mIB;
- ID3D11ShaderResourceView* mLayer0;
- ID3D11ShaderResourceView* mLayer1;
- ID3D11ShaderResourceView* mLayer2;
- ID3D11ShaderResourceView* mLayer3;
- ID3D11ShaderResourceView* mLayer4;
- ID3D11ShaderResourceView* mBlendMap;
- ID3DX11EffectTechnique* mTech;
- ID3DX11EffectMatrixVariable* mfxWVPVar;
- ID3DX11EffectMatrixVariable* mfxWorldVar;
- ID3DX11EffectVectorVariable* mfxDirToSunVar;
- ID3DX11EffectShaderResourceVariable* mfxLayer0Var;
- ID3DX11EffectShaderResourceVariable* mfxLayer1Var;
- ID3DX11EffectShaderResourceVariable* mfxLayer2Var;
- ID3DX11EffectShaderResourceVariable* mfxLayer3Var;
- ID3DX11EffectShaderResourceVariable* mfxLayer4Var;
- ID3DX11EffectShaderResourceVariable* mfxBlendMapVar;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement