private void SetLighting( string mode )
{
// Clear Current Lights and start over
// TODO: Add ClearLights
//this.scene.ClearLights();
lightSet.Clear();
// Local Variable declarations
string[] modeList = new string[] { "Ambient", "SunLight", "Colors" }; // add "Motion"
Light l;
scene.AmbientLight = new ColorEx( 0.05f, 0.05f, 0.05f ); // default is low ambient light
// Set next Light Mode
if ( mode == "next" )
{
lightModeIndex = ( ++lightModeIndex ) % modeList.Length;
}
lightMode = modeList[ lightModeIndex % modeList.Length ];
switch ( lightMode )
{
case "SunLight":
scene.RemoveAllLights();
// Add Sun - Up and to the Left
for ( int i = 0; i < 3; i++ )
{
l = AddLight( "DirLight" + i.ToString(), new Vector3( -PLANE_SIZE / 2f, PLANE_SIZE / 2f, PLANE_SIZE / 2f ), new ColorEx( 1f, 1f, 1f, 1f ), LightType.Directional );
l.Direction = new Vector3( 1f, -0.5f, 0f );
l.SetAttenuation( 10000f, 0, 0, 0 );
}
scene.AmbientLight = ColorEx.White; // default is low ambient light
break;
case "Colors":
float lightScale = 1f;
float lightDist = PLANE_SIZE; // / lightScale;
float lightHeight = 300f / lightScale;
lightNode.ScaleBy( new Vector3( lightScale, lightScale, lightScale ) );
// Create a Light
AddLight( "Lt1", new Vector3( lightDist, lightHeight, lightDist ), ColorEx.Red, LightType.Point );
AddLight( "Lt2", new Vector3( lightDist, lightHeight, 0 ), ColorEx.Purple, LightType.Point );
AddLight( "Lt3", new Vector3( 0, lightHeight, lightDist ), ColorEx.Blue, LightType.Point );
AddLight( "Lt4", new Vector3( 0, lightHeight, 0 ), ColorEx.DarkOrange, LightType.Point );
// Center Spotlight showing down on center of WaterMesh
l = AddLight( "LtMid", new Vector3( 1500f, 1000f, 1500f ), ColorEx.Red, LightType.Spotlight );
l.Direction = -1 * Vector3.UnitY;
l.SetSpotlightRange( 60f, 70f, 90f );
// Add Light to OgreHead coming out his forehead
// TODO/BUG: Must alter Light name to avoid Axiom Exception. Can't re-attach same light object to HeadNode
string ltName = "LtHead" + RAND.NextDouble().ToString();
l = scene.CreateLight( ltName );
l.Position = new Vector3( 0, 20f, 0 );
l.Type = LightType.Spotlight;
l.SetSpotlightRange( 40f, 20f, 20f );
l.Diffuse = ColorEx.Yellow;
l.SetAttenuation( 1000000f, 0f, 0, 0.0000001f ); // Make lights go a long way
l.Direction = new Vector3( 0, -0.1f, 1f );
headNode.AttachObject( l );
break;
case "Motion":
//l.SetAttenuation(5000f, 0f, 0f, 0f);
//SceneNode lightNode = scene.RootSceneNode.CreateChildSceneNode();
//lightNode.Lights.Add(l);
break;
default: // "Ambient" mode
scene.AmbientLight = ColorEx.LightGray; // set Ambient Light
break;
}
}