00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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
00082 LandscapeDefinitionsEntry *landscapeDefinition =
00083 ScorchedClient::instance()->getLandscapes().getLandscapeByName(
00084 definition.getName());
00085
00086
00087 ScorchedClient::instance()->getLandscapeMaps().generateMaps(
00088 ScorchedClient::instance()->getContext(),
00089 definition,
00090 &progressCounter);
00091
00092
00093 Landscape::instance()->generate(&progressCounter);
00094
00095
00096 Landscape::instance()->reset(&progressCounter);
00097
00098 OptionsDisplay::instance()->getNoWaterMovementEntry().setValue(waterMove);
00099
00100
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
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 }