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"
27 #include "egMaterial.h"
28 #include "egTextures.h"
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
55 struct IslandNodeTpl
: public SceneNodeTpl
57 PMaterialResource matRes
;
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
73 static ShaderCombination debugViewShader
;
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
);
95 IslandNode(const IslandNodeTpl
&islandTpl
);
97 void createIndexBuffers();
98 void createVertexBuffers();
99 void createExtension();
101 PMaterialResource materialRes
;
107 BoundingBox localBBox
;
108 uint32 indexBuffer
[5];
109 uint32 terrainpatches
[TILE_COUNT
];
110 float *vertexdata
[TILE_COUNT
];
111 uint32 extensionvertices
;
112 uint32 extensionindices
;