Added Horde3D terrain (still untextured).
[openstranded.git] / src / eal / horde3d / extensions / island.hh
blob5ce16735000ae4c4bd76e6bda65e6a7d7d0958da
1 /*
2 * Island scene node for Horde3D
4 * Copyright (C) 2009 Mathias Gottschlag, Nicolas Schulz, Volker Wiendl
6 * This file is part of OpenStranded
8 * OpenStranded is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
13 * OpenStranded is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with OpenStranded. If not, see <http://www.gnu.org/licenses/>.
22 #ifndef STRANDED_HORDE3DISLAND_HH
23 #define STRANDED_HORDE3DISLAND_HH
25 #include "egPrerequisites.h"
26 #include "utMath.h"
27 #include "egMaterial.h"
28 #include "egTextures.h"
29 #include "egScene.h"
31 namespace eal
33 namespace horde3d
35 extern const char *vsIslandDebugView;
36 extern const char *fsIslandDebugView;
38 static const int EDGE_TILES = 16;
39 static const int TILE_SIZE = 32;
40 static const int TILE_COUNT = 256;
42 static const int SNT_IslandNode = 300;
43 struct IslandNodeParams
45 enum List
47 MaterialRes = 10000,
48 MeshQuality,
49 SizeX,
50 SizeZ,
51 HeightData
55 struct IslandNodeTpl : public SceneNodeTpl
57 PMaterialResource matRes;
58 int sizeX;
59 int sizeZ;
60 float meshQuality;
61 float *heightdata;
63 IslandNodeTpl(const std::string &name, MaterialResource *matRes, int sizeX, int sizeZ) :
64 SceneNodeTpl(SNT_IslandNode, name), matRes(matRes), sizeX(sizeX), sizeZ(sizeZ),
65 meshQuality(50.0f), heightdata(0)
70 class IslandNode : public SceneNode
72 public:
73 static ShaderCombination debugViewShader;
75 ~IslandNode();
77 static SceneNodeTpl *parsingFunc(std::map< std::string, std::string > &attribs);
78 static SceneNode *factoryFunc(const SceneNodeTpl &nodeTpl);
79 static void renderFunc(const std::string &shaderContext, const std::string &theClass, bool debugView,
80 const Frustum *frust1, const Frustum *frust2, RenderingOrder::List order, int occSet);
82 bool canAttach(SceneNode &parent);
83 int getParami(int param);
84 bool setParami(int param, int value);
85 float getParamf(int param);
86 bool setParamf(int param, float value);
88 BoundingBox *getLocalBBox() { return &localBBox; }
90 float *getHeightData();
91 float getHeight(int x, int z);
92 void updateVertices(int x, int y, int width, int height);
94 private:
95 IslandNode(const IslandNodeTpl &islandTpl);
97 void createIndexBuffers();
98 void createVertexBuffers();
99 void createExtension();
101 PMaterialResource materialRes;
102 int sizeX;
103 int sizeZ;
104 float meshQuality;
105 float *heightdata;
107 BoundingBox localBBox;
108 uint32 indexBuffer[5];
109 uint32 terrainpatches[TILE_COUNT];
110 float *vertexdata[TILE_COUNT];
111 uint32 extensionvertices;
112 uint32 extensionindices;
117 #endif