summaryrefslogtreecommitdiffhomepage
path: root/Stars45/ShipSolid.cpp
diff options
context:
space:
mode:
authorFWoltermann@gmail.com <FWoltermann@gmail.com@076cb2c4-205e-83fd-5cf3-1be9aa105544>2011-12-08 14:53:40 +0000
committerFWoltermann@gmail.com <FWoltermann@gmail.com@076cb2c4-205e-83fd-5cf3-1be9aa105544>2011-12-08 14:53:40 +0000
commite33e19d0587146859d48a134ec9fd94e7b7ba5cd (patch)
tree69d048c8801858d2756ab3a487090a7a1b74bf14 /Stars45/ShipSolid.cpp
downloadstarshatter-e33e19d0587146859d48a134ec9fd94e7b7ba5cd.zip
starshatter-e33e19d0587146859d48a134ec9fd94e7b7ba5cd.tar.gz
starshatter-e33e19d0587146859d48a134ec9fd94e7b7ba5cd.tar.bz2
Initial upload
Diffstat (limited to 'Stars45/ShipSolid.cpp')
-rw-r--r--Stars45/ShipSolid.cpp96
1 files changed, 96 insertions, 0 deletions
diff --git a/Stars45/ShipSolid.cpp b/Stars45/ShipSolid.cpp
new file mode 100644
index 0000000..8691d21
--- /dev/null
+++ b/Stars45/ShipSolid.cpp
@@ -0,0 +1,96 @@
+/* Project Starshatter 4.5
+ Destroyer Studios LLC
+ Copyright © 1997-2004. All Rights Reserved.
+
+ SUBSYSTEM: Stars.exe
+ FILE: ShipSolid.cpp
+ AUTHOR: John DiCamillo
+
+
+ OVERVIEW
+ ========
+*/
+
+#include "MemDebug.h"
+#include "ShipSolid.h"
+#include "Ship.h"
+#include "Sim.h"
+#include "StarSystem.h"
+#include "TerrainRegion.h"
+
+#include "Game.h"
+#include "Skin.h"
+
+// +--------------------------------------------------------------------+
+
+ShipSolid::ShipSolid(Ship* s)
+ : ship(s), skin(0), in_soup(false)
+{
+}
+
+// +--------------------------------------------------------------------+
+
+ShipSolid::~ShipSolid()
+{
+}
+
+// +--------------------------------------------------------------------+
+
+void
+ShipSolid::TranslateBy(const Point& ref)
+{
+ true_eye_point = ref;
+ Solid::TranslateBy(ref);
+}
+
+// +--------------------------------------------------------------------+
+
+void
+ShipSolid::Render(Video* video, DWORD flags)
+{
+ if (hidden || !visible || !video || Depth() > 5e6)
+ return;
+
+ const Skin* s = 0;
+
+ if (ship)
+ s = ship->GetSkin();
+ else
+ s = skin;
+
+ if (s)
+ s->ApplyTo(model);
+
+ bool fog = false;
+
+ if (ship && ship->IsAirborne()) {
+ fog = true;
+
+ TerrainRegion* rgn = (TerrainRegion*) ship->GetRegion()->GetOrbitalRegion();
+ double visibility = rgn->GetWeather().Visibility();
+ FLOAT fog_density = (FLOAT) (rgn->FogDensity() * 2.5e-5 * 1/visibility);
+ Color fog_color = rgn->FogColor();
+
+ // Use BLACK fog on secondary lighting pass
+ // This will effectively "filter out" the highlights
+ // with distance...
+
+ if (flags & Graphic::RENDER_ADD_LIGHT)
+ fog_color = Color::Black;
+
+ video->SetRenderState(Video::FOG_ENABLE, true);
+ video->SetRenderState(Video::FOG_COLOR, fog_color.Value());
+ video->SetRenderState(Video::FOG_DENSITY, *((DWORD*) &fog_density));
+ }
+
+ if (!fog) video->SetRenderState(Video::FOG_ENABLE, false);
+
+ Solid::Render(video, flags);
+
+ if (fog) video->SetRenderState(Video::FOG_ENABLE, false);
+
+ if (s)
+ s->Restore(model);
+}
+
+