1 ////////////////////////////////////////////////////////////////////////////////
2 // Scorched3D (c) 2000-2009
4 // This file is part of Scorched3D.
6 // Scorched3D is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
11 // Scorched3D is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with Scorched3D; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 ////////////////////////////////////////////////////////////////////////////////
21 #include <placement/PlacementShadowDefinition.h>
22 #include <landscapemap/LandscapeMaps.h>
23 #include <landscapemap/DeformLandscape.h>
24 #include <common/Defines.h>
25 #include <engine/ScorchedContext.h>
26 #include <image/ImageStore.h>
28 PlacementShadowDefinition::PlacementShadowDefinition() :
29 drawShadow_(true), flattenArea_(0)
33 PlacementShadowDefinition::~PlacementShadowDefinition()
37 bool PlacementShadowDefinition::readXML(XMLNode
*node
, const char *base
)
39 node
->getNamedChild("drawshadow", drawShadow_
, false);
40 node
->getNamedChild("flattenarea", flattenArea_
, false);
42 XMLNode
*groundMap
= 0;
43 if (node
->getNamedChild("groundmap", groundMap
, false))
45 if (!groundMap_
.initFromNode(base
, groundMap
)) return false;
51 void PlacementShadowDefinition::updateLandscapeHeight(
52 ScorchedContext
&context
,
53 FixedVector
&position
, FixedVector
&size
)
55 if (flattenArea_
!= 0)
57 fixed areaSize
= flattenArea_
;
60 areaSize
= MAX(size
[0], size
[1])/2 + 1;
63 DeformLandscape::flattenArea(context
, position
, false, areaSize
);
69 #include <GLEXT/GLImageModifier.h>
70 void PlacementShadowDefinition::updateLandscapeTexture(
72 ScorchedContext
&context
,
73 FixedVector
&position
, FixedVector
&size
)
75 if (groundMap_
.imageValid())
77 Image
*image
= ImageStore::instance()->loadImage(groundMap_
);
78 ImageModifier::addBitmapToLandscape(
81 position
[0].asFloat(),
82 position
[1].asFloat(),
86 if (drawShadow_
&& useShadows
)
88 ImageModifier::addCircleToLandscape(
90 position
[0].asFloat(),
91 position
[1].asFloat(),
92 MAX(size
[0], size
[1]).asFloat(), 1.0f
);