From e33e19d0587146859d48a134ec9fd94e7b7ba5cd Mon Sep 17 00:00:00 2001 From: "FWoltermann@gmail.com" Date: Thu, 8 Dec 2011 14:53:40 +0000 Subject: Initial upload --- Stars45/ShipSolid.cpp | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 Stars45/ShipSolid.cpp (limited to 'Stars45/ShipSolid.cpp') 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); +} + + -- cgit v1.1