OK, here we go. Lots of PROPOSED changes. I will be submitting these proposed changes in several sequential posts here.
First, the biggest change has to do with moving ambient light management off of the SkyLight ant into CaelumSystem. The reason is that when there is a sun and a moon, BOTH are setting ambient light levels -- without regard to the other.
As a result, calls to the sun or moon to manage ambient light no longer exist (in these proposals), but must be made to CaelumSystem.
These changes all came about as I was trying to get better control over shadows and ambient light settings.
SKYLIGHT.H
in the Attributes "protected" section
Code: Select all
// begin commenting out by trilobite 5-5-08
// NOTE: ambient light management has been moved to CaelumSystem
/// If true then this class also manages ambient lighting.
// bool mManageAmbientLight;
// end commenting out by trilobite
// begin added by trilobite 5-5-08
/** Factor to establish minimum sunlight/moonlight light levels.
* In "setMainLightColour(...)," this factor is used to compare against the sum of the R G and B channels
* of the main light colour. If this sum is less than mSkyLightShutoffMinimum,
* then this Skylight is set to invisible -- which eliminates its influence
* in the scene.
*/
Ogre::Real mSkyLightShutoffMinimum;
// end adds by trilobite
in Methods "public:"
Code: Select all
// begin commenting out by trilobite 5-5-08
// NOTE: ambient light management has been shifted to CaelumSystem
// There, it manages transitions between bright/dark/sunny/moony ambient regimes.
// This new system replaces the existing method in which each skylight (sun and moon)
// independently sets scene ambient light -- without regard to each other.
// /// This can make this class manage the ambient light of the scene.
// void setManageAmbientLight (bool manage);
//
// /// If the class is managing the scene's ambient light.
// bool isManagingAmbientLight () const;
//
// end commenting out by trilobite
and
Code: Select all
// begin added by trilobite 5-5-08
/** Sets an initial value with which to compare the main light's current
* diffuse colour composite (r+g+b). In setMainLightColour(...), if
* the composite value is < this shutoff minimum, then the light is
* set to invisible -- removing its influence on the scene.
*/
void setInitialSkyLightShutoffMinimum(const Ogre::Real rMinimum);
/** gets the initial skylight shutoff minimum value
*/
Ogre::Real getInitialSkyLightShutoffMinimum();
// end add by trilobite
SKYLIGHT.CPP in BaseSkyLight::BaseSkyLight (...) constructor
Code: Select all
// begin commenting out by trilobite 5-5-08
// mManageAmbientLight = false;
// end commenting out by trilobite
// begin add by trilobite 5-5-08
mSkyLightShutoffMinimum = 0.09;
// end adds by trilobite
a new void BaseSkyLight::setMainLightColour (...)
Code: Select all
/* commented out by trilobite 5-5-08
void BaseSkyLight::setMainLightColour (const Ogre::ColourValue &colour) {
// Set light colours.
mMainLight->setDiffuseColour (colour * mDiffuseMultiplier);
mMainLight->setSpecularColour (colour * mSpecularMultiplier);
if (isManagingAmbientLight()) {
mScene->setAmbientLight(colour * mAmbientMultiplier);
}
}
*/
// end commented out by trilobite
// revised by trilobite 5-5-08
void BaseSkyLight::setMainLightColour (const Ogre::ColourValue &colour)
{
// first, set light colours.
mMainLight->setDiffuseColour (colour * mDiffuseMultiplier);
mMainLight->setSpecularColour (colour * mSpecularMultiplier);
// second, adjust ambient light settings if necessary
// get numbers we can use for testing ambient light intensity
// get a composite light intensity value
Ogre::ColourValue tempColour(colour);
Ogre::Real rColourSum = tempColour.r + tempColour.g + tempColour.b;
// avoid divide-by-zero errors
if (rColourSum <= 0.0)
{
tempColour.r = tempColour.g = tempColour.b = 0.001;
rColourSum = tempColour.r + tempColour.g + tempColour.b;
}
// third, shutoff this light if really dim
// update to find the ultimate minimum value for this skylight
if (rColourSum < (mSkyLightShutoffMinimum))
mSkyLightShutoffMinimum = rColourSum;
// turn this light off if it is within 10 percent of its minimum
if (rColourSum < (mSkyLightShutoffMinimum * 1.10))
mMainLight->setVisible(false);
else
mMainLight->setVisible(true);
}
// end revised by trilobite
commenting out two functions
Code: Select all
// begin comment out by trilobite 5-5-08
// NOTE: ambient light management has moved to CaelumSystem
// void BaseSkyLight::setManageAmbientLight (bool manage) {
// mManageAmbientLight = manage;
// }
//
//bool BaseSkyLight::isManagingAmbientLight () const {
// return mManageAmbientLight;
//}
// end comment out by trilobite
added two new functions
Code: Select all
// begin added by trilobite 5-5-08
void BaseSkyLight::setInitialSkyLightShutoffMinimum(const Ogre::Real rMinimum)
{
mSkyLightShutoffMinimum = rMinimum;
}
Ogre::Real BaseSkyLight::getInitialSkyLightShutoffMinimum()
{
return mSkyLightShutoffMinimum;
}
// end add by trilobite
}
More to follow... CaelumSystem and Starfield