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 <dialogs/AnimatedBackdropDialog.h>
22 #include <dialogs/BackdropDialog.h>
23 #include <dialogs/ProgressDialog.h>
24 #include <GLEXT/GLCameraFrustum.h>
25 #include <graph/MainCamera.h>
26 #include <graph/Main2DCamera.h>
27 #include <graph/OptionsDisplay.h>
28 #include <engine/ActionController.h>
29 #include <engine/MainLoop.h>
30 #include <tankgraph/RenderTargets.h>
31 #include <landscape/Landscape.h>
32 #include <client/ScorchedClient.h>
33 #include <landscapedef/LandscapeDefinitions.h>
34 #include <landscapemap/LandscapeMaps.h>
36 AnimatedBackdropDialog
*AnimatedBackdropDialog::instance_
= 0;
38 AnimatedBackdropDialog
*AnimatedBackdropDialog::instance()
42 instance_
= new AnimatedBackdropDialog
;
47 AnimatedBackdropDialog::AnimatedBackdropDialog() :
48 GLWWindow("", 0.0f
, 0.0f
, 0.0f
, 0.0f
, 0,
49 "The backdrop dialog"),
53 windowLevel_
= 5000000;
56 AnimatedBackdropDialog::~AnimatedBackdropDialog()
60 void AnimatedBackdropDialog::init()
64 ProgressCounter progressCounter
;
65 ProgressDialog::instance()->changeTip();
66 progressCounter
.setUser(ProgressDialogSync::instance());
67 progressCounter
.setNewPercentage(0.0f
);
69 bool waterMove
= OptionsDisplay::instance()->getNoWaterMovement();
70 OptionsDisplay::instance()->getNoWaterMovementEntry().setValue(true);
72 if (!ScorchedClient::instance()->getLandscapes().readLandscapeDefinitions())
74 S3D::dialogExit("Landscape Definitions",
75 "Failed to parse landscape definitions");
78 LandscapeDefinition definition
= ScorchedClient::instance()->getLandscapes().getLandscapeDefn(
81 // Set the progress dialog nicities
82 LandscapeDefinitionsEntry
*landscapeDefinition
=
83 ScorchedClient::instance()->getLandscapes().getLandscapeByName(
84 definition
.getName());
86 // Generate new landscape
87 ScorchedClient::instance()->getLandscapeMaps().generateMaps(
88 ScorchedClient::instance()->getContext(),
92 // Calculate all the new landscape settings (graphics)
93 Landscape::instance()->generate(&progressCounter
);
95 // Make sure the landscape has been optimized
96 Landscape::instance()->reset(&progressCounter
);
98 OptionsDisplay::instance()->getNoWaterMovementEntry().setValue(waterMove
);
100 // Hack to get camera synched
102 ScorchedClient::instance()->getMainLoop().getTimer().getTimeDifference();
105 void AnimatedBackdropDialog::draw()
108 BackdropDialog::instance()->drawLogo();
109 BackdropDialog::instance()->drawFooter();
112 void AnimatedBackdropDialog::drawBackground()
116 MainCamera::instance()->draw(0);
118 GLCameraFrustum::instance()->draw(0);
119 Landscape::instance()->drawShadows();
120 Landscape::instance()->drawLand();
121 RenderTargets::instance()->render3D
.draw(0);
122 Landscape::instance()->drawWater();
123 Landscape::instance()->drawObjects();
125 // Return the viewport to the original
126 Main2DCamera::instance()->draw(0);
129 void AnimatedBackdropDialog::simulate(float frameTime
)
133 rotation_
+= frameTime
* 0.1f
;
135 MainCamera::instance()->simulate(0, frameTime
);
136 Landscape::instance()->simulate(frameTime
);
137 RenderTargets::instance()->render2D
.simulate(0, frameTime
);
138 RenderTargets::instance()->render3D
.simulate(0, frameTime
);
139 ScorchedClient::instance()->getActionController().simulate(0, frameTime
);
140 ScorchedClient::instance()->getParticleEngine().simulate(0, frameTime
);
142 MainCamera::instance()->getTarget().setCameraType(TargetCamera::CamFree
);
143 MainCamera::instance()->getCamera().movePosition(rotation_
, 1.3f
, 225.0f
);