AnimatedBackdropDialog.cpp

Go to the documentation of this file.
00001 ////////////////////////////////////////////////////////////////////////////////
00002 //    Scorched3D (c) 2000-2009
00003 //
00004 //    This file is part of Scorched3D.
00005 //
00006 //    Scorched3D is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    Scorched3D is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with Scorched3D; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 ////////////////////////////////////////////////////////////////////////////////
00020 
00021 #include <dialogs/AnimatedBackdropDialog.h>
00022 #include <dialogs/BackdropDialog.h>
00023 #include <dialogs/ProgressDialog.h>
00024 #include <GLEXT/GLCameraFrustum.h>
00025 #include <graph/MainCamera.h>
00026 #include <graph/Main2DCamera.h>
00027 #include <graph/OptionsDisplay.h>
00028 #include <engine/ActionController.h>
00029 #include <engine/MainLoop.h>
00030 #include <tankgraph/RenderTargets.h>
00031 #include <landscape/Landscape.h>
00032 #include <client/ScorchedClient.h>
00033 #include <landscapedef/LandscapeDefinitions.h>
00034 #include <landscapemap/LandscapeMaps.h>
00035 
00036 AnimatedBackdropDialog *AnimatedBackdropDialog::instance_ = 0;
00037 
00038 AnimatedBackdropDialog *AnimatedBackdropDialog::instance()
00039 {
00040         if (!instance_)
00041         {
00042                 instance_ = new AnimatedBackdropDialog;
00043         }
00044         return instance_;
00045 }
00046 
00047 AnimatedBackdropDialog::AnimatedBackdropDialog() : 
00048         GLWWindow("", 0.0f, 0.0f, 0.0f, 0.0f, 0,
00049                 "The backdrop dialog"),
00050         rotation_(HALFPI),
00051         init_(false)
00052 {
00053         windowLevel_ = 5000000;
00054 }
00055 
00056 AnimatedBackdropDialog::~AnimatedBackdropDialog()
00057 {
00058 }
00059 
00060 void AnimatedBackdropDialog::init()
00061 {
00062         init_ = true;
00063 
00064         ProgressCounter progressCounter;
00065         ProgressDialog::instance()->changeTip();
00066         progressCounter.setUser(ProgressDialogSync::instance());
00067         progressCounter.setNewPercentage(0.0f);
00068 
00069         bool waterMove = OptionsDisplay::instance()->getNoWaterMovement();
00070         OptionsDisplay::instance()->getNoWaterMovementEntry().setValue(true);
00071 
00072         if (!ScorchedClient::instance()->getLandscapes().readLandscapeDefinitions())
00073         {
00074                 S3D::dialogExit("Landscape Definitions",
00075                         "Failed to parse landscape definitions");
00076         }
00077 
00078         LandscapeDefinition definition = ScorchedClient::instance()->getLandscapes().getLandscapeDefn(
00079                 "oldstyle");
00080 
00081         // Set the progress dialog nicities
00082         LandscapeDefinitionsEntry *landscapeDefinition =
00083                 ScorchedClient::instance()->getLandscapes().getLandscapeByName(
00084                         definition.getName());
00085 
00086         // Generate new landscape
00087         ScorchedClient::instance()->getLandscapeMaps().generateMaps(
00088                 ScorchedClient::instance()->getContext(),
00089                 definition,
00090                 &progressCounter);
00091 
00092         // Calculate all the new landscape settings (graphics)
00093         Landscape::instance()->generate(&progressCounter);
00094 
00095         // Make sure the landscape has been optimized
00096         Landscape::instance()->reset(&progressCounter);
00097 
00098         OptionsDisplay::instance()->getNoWaterMovementEntry().setValue(waterMove);
00099 
00100         // Hack to get camera synched
00101         simulate(5.0f);
00102         ScorchedClient::instance()->getMainLoop().getTimer().getTimeDifference();
00103 }
00104 
00105 void AnimatedBackdropDialog::draw()
00106 {
00107         drawBackground();
00108         BackdropDialog::instance()->drawLogo();
00109         BackdropDialog::instance()->drawFooter();
00110 }
00111 
00112 void AnimatedBackdropDialog::drawBackground()
00113 {
00114         if (!init_) init();
00115 
00116         MainCamera::instance()->draw(0);
00117 
00118         GLCameraFrustum::instance()->draw(0);
00119         Landscape::instance()->drawShadows();
00120         Landscape::instance()->drawLand();
00121         RenderTargets::instance()->render3D.draw(0);
00122         Landscape::instance()->drawWater();
00123         Landscape::instance()->drawObjects();
00124 
00125         // Return the viewport to the original
00126         Main2DCamera::instance()->draw(0);
00127 }
00128 
00129 void AnimatedBackdropDialog::simulate(float frameTime)
00130 {
00131         if (!init_) init();
00132 
00133         rotation_ += frameTime * 0.1f;
00134 
00135         MainCamera::instance()->simulate(0, frameTime);
00136         Landscape::instance()->simulate(frameTime);
00137         RenderTargets::instance()->render2D.simulate(0, frameTime);
00138         RenderTargets::instance()->render3D.simulate(0, frameTime);
00139         ScorchedClient::instance()->getActionController().simulate(0, frameTime);
00140         ScorchedClient::instance()->getParticleEngine().simulate(0, frameTime);
00141 
00142         MainCamera::instance()->getTarget().setCameraType(TargetCamera::CamFree);
00143         MainCamera::instance()->getCamera().movePosition(rotation_, 1.3f, 225.0f);
00144 }

Generated on Mon Feb 16 15:14:37 2009 for Scorched3D by  doxygen 1.5.3