1
0
forked from 0ad/0ad

implement atlas feature request

(http://www.wildfiregames.com/forum/index.php?showtopic=11018)

This was SVN commit r5117.
This commit is contained in:
janwas 2007-05-29 22:47:26 +00:00
parent cba876b246
commit f35fe2f781
6 changed files with 28 additions and 0 deletions

View File

@ -134,3 +134,14 @@ void CVector3D::Normalize ()
Y *= scale;
Z *= scale;
}
//-----------------------------------------------------------------------------
float MaxComponent(const CVector3D& v)
{
float max = -FLT_MAX;
for(int i = 0; i < 3; i++)
max = std::max(max, v[i]);
return max;
}

View File

@ -64,4 +64,6 @@ class CVector3D
const float* GetFloatArray() const { return &X; }
};
extern float MaxComponent(const CVector3D& v);
#endif

View File

@ -268,6 +268,7 @@ ActorViewer::ActorViewer(wxWindow* parent)
m_EnvironmentSettings.sunelevation = 45 * M_PI/180;
m_EnvironmentSettings.sunrotation = 315 * M_PI/180;
m_EnvironmentSettings.sunoverbrightness = 1.0f;
m_EnvironmentSettings.suncolour = Colour(255, 255, 255);
m_EnvironmentSettings.terraincolour = Colour(164, 164, 164);
m_EnvironmentSettings.unitcolour = Colour(164, 164, 164);

View File

@ -206,6 +206,7 @@ EnvironmentSidebar::EnvironmentSidebar(wxWindow* sidebarContainer, wxWindow* bot
sunSizer->Add(new VariableSliderBox(this, _("Sun rotation"), g_EnvironmentSettings.sunrotation, -M_PI, M_PI), wxSizerFlags().Expand());
sunSizer->Add(new VariableSliderBox(this, _("Sun elevation"), g_EnvironmentSettings.sunelevation, -M_PI/2, M_PI/2), wxSizerFlags().Expand());
sunSizer->Add(new VariableSliderBox(this, _("Sun overbrightness"), g_EnvironmentSettings.sunoverbrightness, 1.0f, 3.0f), wxSizerFlags().Expand());
m_MainSizer->Add(new LightControl(this, wxSize(150, 150), g_EnvironmentSettings));
m_MainSizer->Add(m_SkyList = new VariableListBox(this, _("Sky set"), g_EnvironmentSettings.skyset));

View File

@ -42,6 +42,13 @@ sEnvironmentSettings GetSettings()
// RGBColor (CVector3D) colours
#define COLOUR(A, B) A = Colour((int)(B.X*255), (int)(B.Y*255), (int)(B.Z*255))
s.sunoverbrightness = MaxComponent(g_LightEnv.m_SunColor);
// clamp color to [0..1] before packing into u8 triplet
if(s.sunoverbrightness > 1.0f)
g_LightEnv.m_SunColor *= 1.0/s.sunoverbrightness; // (there's no operator/=)
// no component was above 1.0, so reset scale factor (don't want to darken)
else
s.sunoverbrightness = 1.0f;
COLOUR(s.suncolour, g_LightEnv.m_SunColor);
COLOUR(s.terraincolour, g_LightEnv.m_TerrainAmbientColor);
COLOUR(s.unitcolour, g_LightEnv.m_UnitsAmbientColor);
@ -75,6 +82,7 @@ void SetSettings(const sEnvironmentSettings& s)
#define COLOUR(A, B) B = RGBColor(A->r/255.f, A->g/255.f, A->b/255.f)
COLOUR(s.suncolour, g_LightEnv.m_SunColor);
g_LightEnv.m_SunColor *= s.sunoverbrightness;
COLOUR(s.terraincolour, g_LightEnv.m_TerrainAmbientColor);
COLOUR(s.unitcolour, g_LightEnv.m_UnitsAmbientColor);
#undef COLOUR

View File

@ -264,6 +264,11 @@ struct sEnvironmentSettings
Shareable<float> sunrotation; // range -pi..+pi
Shareable<float> sunelevation; // range -pi/2 .. +pi/2
// emulate 'HDR' by allowing overly bright suncolour. this is
// multiplied on to suncolour after converting to float
// (struct Colour stores as normal u8, 0..255)
Shareable<float> sunoverbrightness; // range 1..3
Shareable<std::wstring> skyset;
Shareable<Colour> suncolour;