5 * Copyright (C) 2009 Mathias Gottschlag, Nicolas Schulz, Volker Wiendl
7 * This file is part of OpenStranded
9 * OpenStranded is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
14 * OpenStranded is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with OpenStranded. If not, see <http://www.gnu.org/licenses/>.
23 #include "eal/horde3d/extensions/island.hh"
24 #include "egModules.h"
34 Modules::sceneMan().registerType(SNT_IslandNode
, "Island",
35 IslandNode::parsingFunc
, IslandNode::factoryFunc
, IslandNode::renderFunc
);
37 // Upload default shader used for debug view
38 Modules::renderer().uploadShader(vsIslandDebugView
,
39 fsIslandDebugView
, IslandNode::debugViewShader
);
45 std::string
safeStr(const char *str
)
47 if (str
!= 0x0) return str
;
51 void installExtensions()
58 NodeHandle
addIslandNode(NodeHandle parent
, const char *name
, int sizeX
, int sizeZ
, ResHandle materialRes
)
60 SceneNode
*parentNode
= Modules::sceneMan().resolveNodeHandle( parent
);
61 if( parentNode
== 0x0 ) return 0;
63 Resource
*matRes
= Modules::resMan().resolveResHandle( materialRes
);
64 if( matRes
== 0x0 || matRes
->getType() != ResourceTypes::Material
) return 0;
66 Modules::log().writeInfo( "Adding Island node '%s'", safeStr( name
).c_str() );
68 IslandNodeTpl
tpl(safeStr(name
), (MaterialResource
*)matRes
, sizeX
, sizeZ
);
69 SceneNode
*sn
= Modules::sceneMan().findType(SNT_IslandNode
)->factoryFunc(tpl
);
70 return Modules::sceneMan().addNode(sn
, *parentNode
);
73 void setSize(NodeHandle island
, int sizeX
, int sizeZ
)
77 float *getData(NodeHandle island
)
79 SceneNode
*sn
= Modules::sceneMan().resolveNodeHandle( island
);
80 if( sn
!= 0x0 && sn
->getType() == SNT_IslandNode
)
81 return ((IslandNode
*)sn
)->getHeightData();
85 void invalidate(NodeHandle island
, int x
, int z
, int sizeX
, int sizeZ
)
87 SceneNode
*sn
= Modules::sceneMan().resolveNodeHandle( island
);
88 if( sn
!= 0x0 && sn
->getType() == SNT_IslandNode
)
89 ((IslandNode
*)sn
)->updateVertices(x
, z
, sizeX
, sizeZ
);