Skip to content
Browse files

Merge branch 'intro-cleanup'

  • Loading branch information...
2 parents ee851d7 + 7d866e6 commit f67c7fe974803033b807921d735168b9c863c3a5 @robn robn committed
Showing with 225 additions and 92 deletions.
  1. +1 −0 Changelog.txt
  2. +32 −0 src/Cutscene.h
  3. +70 −0 src/Intro.cpp
  4. +21 −0 src/Intro.h
  5. +5 −0 src/Makefile.am
  6. +9 −92 src/Pi.cpp
  7. +52 −0 src/Tombstone.cpp
  8. +15 −0 src/Tombstone.h
  9. +5 −0 win32/vc2010/pioneer.vcxproj
  10. +15 −0 win32/vc2010/pioneer.vcxproj.filters
View
1 Changelog.txt
@@ -44,6 +44,7 @@ Alpha 27
* Removed duplication in key bindings code (#1545)
* New view (DeathView) to deal with display after the player dies (#1543, #1540)
* Simplified terrain thread locking (#1495)
+ * Moved intro and tombstone out to their own cutscene classes (#1559)
Alpha 26
View
32 src/Cutscene.h
@@ -0,0 +1,32 @@
+// Copyright © 2008-2012 Pioneer Developers. See AUTHORS.txt for details
+// Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
+
+#ifndef _CUTSCENE_H
+#define _CUTSCENE_H
+
+#include "libs.h"
+#include "LmrModel.h"
+#include "graphics/Renderer.h"
+#include "graphics/Light.h"
+
+class Cutscene {
+public:
+ Cutscene(Graphics::Renderer *r, int width, int height)
+ : m_aspectRatio(float(width)/float(height))
+ , m_renderer(r)
+ {
+ }
+ virtual ~Cutscene() {}
+
+ virtual void Draw(float time) = 0;
+
+protected:
+ Color m_ambientColor;
+ float m_aspectRatio;
+ Graphics::Renderer *m_renderer;
+ LmrModel *m_model;
+ LmrObjParams m_modelParams;
+ std::vector<Graphics::Light> m_lights;
+};
+
+#endif
View
70 src/Intro.cpp
@@ -0,0 +1,70 @@
+// Copyright © 2008-2012 Pioneer Developers. See AUTHORS.txt for details
+// Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
+
+#include "Intro.h"
+#include "Lang.h"
+#include "Ship.h"
+#include "graphics/Renderer.h"
+
+Intro::Intro(Graphics::Renderer *r, int width, int height)
+: Cutscene(r, width, height)
+{
+ m_background.Reset(new Background::Container(r, UNIVERSE_SEED));
+ m_ambientColor = Color(0.1f, 0.1f, 0.1f, 1.f);
+
+ const Color lc(1.f, 1.f, 1.f, 0.f);
+ m_lights.push_back(Graphics::Light(Graphics::Light::LIGHT_DIRECTIONAL, vector3f(0.f, 1.f, 1.f), lc, lc, lc));
+
+ m_model = LmrLookupModelByName("lanner_ub");
+
+ // Model parameters
+ LmrObjParams params = {
+ "ShipAnimation", // animation namespace
+ 0.0, // time
+ { }, // animation stages
+ { 0.0, 1.0 }, // animation positions
+ Lang::PIONEER, // label
+ 0, // equipment
+ Ship::FLYING, // flightState
+ { 0.0f, 0.0f, -1.0f }, { 0.0f, 0.0f, 0.0f }, // rear thrusters active
+ { // pColor[3]
+ { { .2f, .2f, .5f, 1.0f }, { 1, 1, 1 }, { 0, 0, 0 }, 100.0 },
+ { { 0.5f, 0.5f, 0.5f, 1.0f }, { 0, 0, 0 }, { 0, 0, 0 }, 0 },
+ { { 0.8f, 0.8f, 0.8f, 1.0f }, { 0, 0, 0 }, { 0, 0, 0 }, 0 } },
+ };
+ m_modelParams = params;
+
+ // Some equipment (in case the model can show them)
+ m_equipment.Add(Equip::ECM_ADVANCED, 1);
+ m_equipment.Add(Equip::HYPERCLOUD_ANALYZER, 1);
+ m_equipment.Add(Equip::ATMOSPHERIC_SHIELDING, 1);
+ m_equipment.Add(Equip::FUEL_SCOOP, 1);
+ m_equipment.Add(Equip::SCANNER, 1);
+ m_equipment.Add(Equip::RADAR_MAPPER, 1);
+ m_equipment.Add(Equip::MISSILE_NAVAL, 4);
+ m_modelParams.equipment = &m_equipment;
+}
+
+void Intro::Draw(float _time)
+{
+ m_renderer->SetPerspectiveProjection(75, m_aspectRatio, 1.f, 10000.f);
+ m_renderer->SetTransform(matrix4x4f::Identity());
+
+ // XXX all this stuff will be gone when intro uses a Camera
+ // rotate background by time, and a bit extra Z so it's not so flat
+ matrix4x4d brot = matrix4x4d::RotateXMatrix(-0.25*_time) * matrix4x4d::RotateZMatrix(0.6);
+ m_background->Draw(m_renderer, brot);
+
+ glPushAttrib(GL_ALL_ATTRIB_BITS);
+
+ const Color oldSceneAmbientColor = m_renderer->GetAmbientColor();
+ m_renderer->SetAmbientColor(m_ambientColor);
+ m_renderer->SetLights(m_lights.size(), &m_lights[0]);
+
+ matrix4x4f rot = matrix4x4f::RotateYMatrix(_time) * matrix4x4f::RotateZMatrix(0.6f*_time) *
+ matrix4x4f::RotateXMatrix(_time*0.7f);
+ rot[14] = -80.0;
+ m_model->Render(rot, &m_modelParams);
+ glPopAttrib();
+ m_renderer->SetAmbientColor(oldSceneAmbientColor);
+}
View
21 src/Intro.h
@@ -0,0 +1,21 @@
+// Copyright © 2008-2012 Pioneer Developers. See AUTHORS.txt for details
+// Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
+
+#ifndef _INTRO_H
+#define _INTRO_H
+
+#include "Cutscene.h"
+#include "Background.h"
+#include "EquipSet.h"
+
+class Intro : public Cutscene {
+public:
+ Intro(Graphics::Renderer *r, int width, int height);
+ virtual void Draw(float time);
+
+private:
+ EquipSet m_equipment;
+ ScopedPtr<Background::Container> m_background;
+};
+
+#endif
View
5 src/Makefile.am 100644 → 100755
@@ -29,6 +29,7 @@ noinst_HEADERS = \
CityOnPlanet.h \
Color.h \
CommodityTradeWidget.h \
+ Cutscene.h \
CRC32.h \
DeadVideoLink.h \
DeathView.h \
@@ -52,6 +53,7 @@ noinst_HEADERS = \
HyperspaceCloud.h \
InfoView.h \
IniConfig.h \
+ Intro.h \
GameConfig.h \
KeyBindings.h \
Lang.h \
@@ -146,6 +148,7 @@ noinst_HEADERS = \
SystemInfoView.h \
SystemView.h \
TerrainBody.h \
+ Tombstone.h \
VideoLink.h \
View.h \
WorldView.h \
@@ -194,6 +197,7 @@ pioneer_SOURCES = \
HyperspaceCloud.cpp \
InfoView.cpp \
IniConfig.cpp \
+ Intro.cpp \
GameConfig.cpp \
KeyBindings.cpp \
Lang.cpp \
@@ -279,6 +283,7 @@ pioneer_SOURCES = \
SystemInfoView.cpp \
SystemView.cpp \
TerrainBody.cpp \
+ Tombstone.cpp \
View.cpp \
WorldView.cpp \
WorldViewCamera.cpp \
View
101 src/Pi.cpp
@@ -4,7 +4,6 @@
#include "Pi.h"
#include "libs.h"
#include "AmbientSounds.h"
-#include "Background.h"
#include "CargoBody.h"
#include "CityOnPlanet.h"
#include "FileSystem.h"
@@ -15,6 +14,7 @@
#include "GameMenuView.h"
#include "GeoSphere.h"
#include "InfoView.h"
+#include "Intro.h"
#include "Lang.h"
#include "LmrModel.h"
#include "LuaManager.h"
@@ -70,6 +70,7 @@
#include "StringF.h"
#include "SystemInfoView.h"
#include "SystemView.h"
+#include "Tombstone.h"
#include "WorldView.h"
#include "DeathView.h"
#include "galaxy/CustomSystem.h"
@@ -679,98 +680,16 @@ void Pi::HandleEvents()
}
}
-static void draw_intro(Background::Container *background, float _time)
-{
- LmrObjParams params = {
- "ShipAnimation", // animation namespace
- 0.0, // time
- { }, // animation stages
- { 0.0, 1.0 }, // animation positions
- Lang::PIONEER, // label
- 0, // equipment
- Ship::FLYING, // flightState
- { 0.0f, 0.0f, -1.0f }, { 0.0f, 0.0f, 0.0f }, // thrust
- { // pColor[3]
- { { .2f, .2f, .5f, 1.0f }, { 1, 1, 1 }, { 0, 0, 0 }, 100.0 },
- { { 0.5f, 0.5f, 0.5f, 1.0f }, { 0, 0, 0 }, { 0, 0, 0 }, 0 },
- { { 0.8f, 0.8f, 0.8f, 1.0f }, { 0, 0, 0 }, { 0, 0, 0 }, 0 } },
- };
- EquipSet equipment;
- // The finest parts that money can buy!
- params.equipment = &equipment;
- equipment.Add(Equip::ECM_ADVANCED, 1);
- equipment.Add(Equip::HYPERCLOUD_ANALYZER, 1);
- equipment.Add(Equip::ATMOSPHERIC_SHIELDING, 1);
- equipment.Add(Equip::FUEL_SCOOP, 1);
- equipment.Add(Equip::SCANNER, 1);
- equipment.Add(Equip::RADAR_MAPPER, 1);
- equipment.Add(Equip::MISSILE_NAVAL, 4);
-
- // XXX all this stuff will be gone when intro uses a Camera
- // rotate background by time, and a bit extra Z so it's not so flat
- matrix4x4d brot = matrix4x4d::RotateXMatrix(-0.25*_time) * matrix4x4d::RotateZMatrix(0.6);
- background->Draw(Pi::renderer, brot);
-
- glPushAttrib(GL_ALL_ATTRIB_BITS);
-
- const Color oldSceneAmbientColor = Pi::renderer->GetAmbientColor();
- Pi::renderer->SetAmbientColor(Color(0.1f, 0.1f, 0.1f, 1.f));
-
- const Color lc(1.f, 1.f, 1.f, 0.f);
- const Graphics::Light light(Graphics::Light::LIGHT_DIRECTIONAL, vector3f(0.f, 1.f, 1.f), lc, lc, lc);
- Pi::renderer->SetLights(1, &light);
-
- matrix4x4f rot = matrix4x4f::RotateYMatrix(_time) * matrix4x4f::RotateZMatrix(0.6f*_time) *
- matrix4x4f::RotateXMatrix(_time*0.7f);
- rot[14] = -80.0;
- LmrLookupModelByName("lanner_ub")->Render(rot, &params);
- glPopAttrib();
- Pi::renderer->SetAmbientColor(oldSceneAmbientColor);
-}
-
-static void draw_tombstone(float _time)
-{
- LmrObjParams params = {
- 0, // animation namespace
- 0.0, // time
- {}, // animation stages
- {}, // animation positions
- Lang::TOMBSTONE_EPITAPH, // label
- 0, // equipment
- 0, // flightState
- { 0.0f, 0.0f, 1.0f }, { 0.0f, 0.0f, 0.0f },
- { // pColor[3]
- { { 1.0f, 1.0f, 1.0f, 1.0f }, { 0, 0, 0 }, { 0, 0, 0 }, 0 },
- { { 0.8f, 0.6f, 0.5f, 1.0f }, { 0, 0, 0 }, { 0, 0, 0 }, 0 },
- { { 0.5f, 0.5f, 0.5f, 1.0f }, { 0, 0, 0 }, { 0, 0, 0 }, 0 } },
- };
- glPushAttrib(GL_ALL_ATTRIB_BITS);
-
- const Color oldSceneAmbientColor = Pi::renderer->GetAmbientColor();
- Pi::renderer->SetAmbientColor(Color(0.1f, 0.1f, 0.1f, 1.f));
-
- const Color lc(1.f, 1.f, 1.f, 0.f);
- const Graphics::Light light(Graphics::Light::LIGHT_DIRECTIONAL, vector3f(0.f, 1.f, 1.f), lc, lc, lc);
- Pi::renderer->SetLights(1, &light);
-
- matrix4x4f rot = matrix4x4f::RotateYMatrix(_time*2);
- rot[14] = -std::max(150.0f - 30.0f*_time, 30.0f);
- LmrLookupModelByName("tombstone")->Render(rot, &params);
- glPopAttrib();
- Pi::renderer->SetAmbientColor(oldSceneAmbientColor);
-}
-
void Pi::TombStoneLoop()
{
+ ScopedPtr<Tombstone> tombstone(new Tombstone(Pi::renderer, GetScrWidth(), GetScrHeight()));
Uint32 last_time = SDL_GetTicks();
float _time = 0;
do {
- Pi::renderer->BeginFrame();
- Pi::renderer->SetPerspectiveProjection(75, Pi::GetScrAspect(), 1.f, 10000.f);
- Pi::renderer->SetTransform(matrix4x4f::Identity());
Pi::HandleEvents();
Pi::SetMouseGrab(false);
- draw_tombstone(_time);
+ Pi::renderer->BeginFrame();
+ tombstone->Draw(_time);
Pi::renderer->EndFrame();
Gui::Draw();
Pi::renderer->SwapBuffers();
@@ -954,7 +873,7 @@ void Pi::HandleMenuKey(int n)
void Pi::Start()
{
- Background::Container *background = new Background::Container(Pi::renderer, UNIVERSE_SEED);
+ Intro *intro = new Intro(Pi::renderer, GetScrWidth(), GetScrHeight());
menu = new Gui::Fixed(float(Gui::Screen::GetWidth()), float(Gui::Screen::GetHeight()));
Gui::Screen::AddBaseWidget(menu, 0, 0);
@@ -1026,11 +945,9 @@ void Pi::Start()
while (!menuDone) {
Pi::HandleEvents();
- Pi::renderer->BeginFrame();
- Pi::renderer->SetPerspectiveProjection(75, Pi::GetScrAspect(), 1.f, 10000.f);
- Pi::renderer->SetTransform(matrix4x4f::Identity());
Pi::SetMouseGrab(false);
- draw_intro(background, _time);
+ Pi::renderer->BeginFrame();
+ intro->Draw(_time);
Pi::renderer->EndFrame();
Gui::Draw();
Pi::renderer->SwapBuffers();
@@ -1043,7 +960,7 @@ void Pi::Start()
Gui::Screen::RemoveBaseWidget(menu);
delete menu;
- delete background;
+ delete intro;
// game is set by HandleMenuKey if any game-starting option (start or
// load) is selected
View
52 src/Tombstone.cpp
@@ -0,0 +1,52 @@
+// Copyright © 2008-2012 Pioneer Developers. See AUTHORS.txt for details
+// Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
+
+#include "Tombstone.h"
+#include "Lang.h"
+#include "graphics/Renderer.h"
+
+Tombstone::Tombstone(Graphics::Renderer *r, int width, int height)
+: Cutscene(r, width, height)
+{
+ m_ambientColor = Color(0.1f, 0.1f, 0.1f, 1.f);
+
+ const Color lc(1.f, 1.f, 1.f, 0.f);
+ m_lights.push_back(Graphics::Light(Graphics::Light::LIGHT_DIRECTIONAL, vector3f(0.f, 1.f, 1.f), lc, lc, lc));
+
+ m_model = LmrLookupModelByName("tombstone");
+
+ // Model parameters
+ LmrObjParams params = {
+ 0, // animation namespace
+ 0.0, // time
+ {}, // animation stages
+ {}, // animation positions
+ Lang::TOMBSTONE_EPITAPH, // label
+ 0, // equipment
+ 0, // flightState
+ { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f },
+ { // pColor[3]
+ { { 1.0f, 1.0f, 1.0f, 1.0f }, { 0, 0, 0 }, { 0, 0, 0 }, 0 },
+ { { 0.8f, 0.6f, 0.5f, 1.0f }, { 0, 0, 0 }, { 0, 0, 0 }, 0 },
+ { { 0.5f, 0.5f, 0.5f, 1.0f }, { 0, 0, 0 }, { 0, 0, 0 }, 0 } },
+ };
+ m_modelParams = params;
+}
+
+void Tombstone::Draw(float _time)
+{
+ m_renderer->SetPerspectiveProjection(75, m_aspectRatio, 1.f, 10000.f);
+ m_renderer->SetTransform(matrix4x4f::Identity());
+
+ glPushAttrib(GL_ALL_ATTRIB_BITS);
+
+ const Color oldSceneAmbientColor = m_renderer->GetAmbientColor();
+ m_renderer->SetAmbientColor(m_ambientColor);
+ m_renderer->SetLights(m_lights.size(), &m_lights[0]);
+
+ matrix4x4f rot = matrix4x4f::RotateYMatrix(_time*2);
+ rot[14] = -std::max(150.0f - 30.0f*_time, 30.0f);
+ m_model->Render(rot, &m_modelParams);
+ glPopAttrib();
+ m_renderer->SetAmbientColor(oldSceneAmbientColor);
+}
View
15 src/Tombstone.h
@@ -0,0 +1,15 @@
+// Copyright © 2008-2012 Pioneer Developers. See AUTHORS.txt for details
+// Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
+
+#ifndef _TOMBSTONE_H
+#define _TOMBSTONE_H
+
+#include "Cutscene.h"
+
+class Tombstone : public Cutscene {
+public:
+ Tombstone(Graphics::Renderer *r, int width, int height);
+ virtual void Draw(float time);
+};
+
+#endif
View
5 win32/vc2010/pioneer.vcxproj
@@ -132,6 +132,7 @@
<ClCompile Include="..\..\src\HyperspaceCloud.cpp" />
<ClCompile Include="..\..\src\InfoView.cpp" />
<ClCompile Include="..\..\src\IniConfig.cpp" />
+ <ClCompile Include="..\..\src\Intro.cpp" />
<ClCompile Include="..\..\src\KeyBindings.cpp" />
<ClCompile Include="..\..\src\Lang.cpp" />
<ClCompile Include="..\..\src\LmrModel.cpp" />
@@ -229,6 +230,7 @@
<ClCompile Include="..\..\src\SystemInfoView.cpp" />
<ClCompile Include="..\..\src\SystemView.cpp" />
<ClCompile Include="..\..\src\TerrainBody.cpp" />
+ <ClCompile Include="..\..\src\Tombstone.cpp" />
<ClCompile Include="..\..\src\utils.cpp" />
<ClCompile Include="..\..\src\View.cpp" />
<ClCompile Include="..\..\src\win32\FileSystemWin32.cpp" />
@@ -259,6 +261,7 @@
<ClInclude Include="..\..\src\Color.h" />
<ClInclude Include="..\..\src\CommodityTradeWidget.h" />
<ClInclude Include="..\..\src\CRC32.h" />
+ <ClInclude Include="..\..\src\Cutscene.h" />
<ClInclude Include="..\..\src\DeadVideoLink.h" />
<ClInclude Include="..\..\src\DeathView.h" />
<ClInclude Include="..\..\src\DeleteEmitter.h" />
@@ -284,6 +287,7 @@
<ClInclude Include="..\..\src\HyperspaceCloud.h" />
<ClInclude Include="..\..\src\InfoView.h" />
<ClInclude Include="..\..\src\IniConfig.h" />
+ <ClInclude Include="..\..\src\Intro.h" />
<ClInclude Include="..\..\src\KeyBindings.h" />
<ClInclude Include="..\..\src\libs.h" />
<ClInclude Include="..\..\src\LmrModel.h" />
@@ -380,6 +384,7 @@
<ClInclude Include="..\..\src\SystemInfoView.h" />
<ClInclude Include="..\..\src\SystemView.h" />
<ClInclude Include="..\..\src\TerrainBody.h" />
+ <ClInclude Include="..\..\src\Tombstone.h" />
<ClInclude Include="..\..\src\utils.h" />
<ClInclude Include="..\..\contrib\vcacheopt\vcacheopt.h" />
<ClInclude Include="..\..\src\vector2.h" />
View
15 win32/vc2010/pioneer.vcxproj.filters
@@ -399,6 +399,12 @@
<ClCompile Include="..\..\src\LuaDev.cpp">
<Filter>src</Filter>
</ClCompile>
+ <ClCompile Include="..\..\src\Intro.cpp">
+ <Filter>src</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\Tombstone.cpp">
+ <Filter>src</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\src\Aabb.h">
@@ -845,6 +851,15 @@
<ClInclude Include="..\..\src\LuaDev.h">
<Filter>src</Filter>
</ClInclude>
+ <ClInclude Include="..\..\src\Intro.h">
+ <Filter>src</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\Tombstone.h">
+ <Filter>src</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\Cutscene.h">
+ <Filter>src</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\src\Makefile.am">

0 comments on commit f67c7fe

Please sign in to comment.
Something went wrong with that request. Please try again.