SetAttenuation() public method

Sets the attenuation parameters of the light in a single call.
public SetAttenuation ( float range, float constant, float linear, float quadratic ) : void
range float
constant float
linear float
quadratic float
return void
        protected void GenerateScene()
        {
            ((Axiom.SceneManagers.Multiverse.SceneManager)sceneManager).SetWorldParams(terrainGenerator, new LODSpec());
            sceneManager.LoadWorldGeometry("");

            AmbientLightColor = new ColorEx(0.5f, 0.5f, 0.5f);

            // set up directional light
            directionalLight = sceneManager.CreateLight("MainLight");
            directionalLight.Type = LightType.Directional;
            directionalLight.SetAttenuation(1000 * OneMeter, 1, 0, 0);

            DirectionalDiffuseColor = ColorEx.White;
            DirectionalSpecularColor = ColorEx.White;

            PositionLight();

            // create and position the scene node used to display the loaded model
            modelNode = sceneManager.RootSceneNode.CreateChildSceneNode();
            modelNode.Position = modelBase;

            helperNode = sceneManager.RootSceneNode.CreateChildSceneNode();
            helperNode.Position = modelBase;

            Axiom.SceneManagers.Multiverse.TerrainManager.Instance.ShowOcean = false;
            // Set our DisplayTerrain property to the current value.
            // This will set the desired SceneManager properties.
            this.DisplayTerrain = displayTerrain;
            //particleNode = scene.RootSceneNode.CreateChildSceneNode();
            //particleNode.Position = new Vector3(0 * oneMeter, 50 * oneMeter, 0 * oneMeter);

            //ParticleSystem ps = ParticleSystemManager.Instance.CreateSystem("foo", "PEExamples/ringOfFire");
            //particleNode.AttachObject(ps);
            //particleNode.ScaleFactor = new Vector3(1000f, 1000f, 1000f);
            //ps.ShowBoundingBox = true;

            return;
        }
Ejemplo n.º 2
0
 public override void SetValue(Vector4 val)
 {
     light.SetAttenuation(val.x, val.y, val.z, val.w);
 }
Ejemplo n.º 3
0
		protected override MovableObject _createInstance( string name, NamedParameterList param )
		{
			Light light = new Light( name );

			if ( param != null )
			{
				// Setting the light type first before any property specific to a certain light type
				if ( param.ContainsKey( "type" ) )
				{
					switch ( param[ "type" ].ToString() )
					{
						case "point":
							light.Type = LightType.Point;
							break;
						case "directional":
							light.Type = LightType.Directional;
							break;
						case "spot":
						case "spotlight":
							light.Type = LightType.Spotlight;
							break;
						default:
							throw new AxiomException( "Invalid light type '" + param[ "type" ] + "'." );
					}
				}

				// Common properties
				if ( param.ContainsKey( "position" ) )
				{
					light.Position = Vector3.Parse( param[ "position" ].ToString() );
				}

				if ( param.ContainsKey( "direction" ) )
				{
					light.Direction = Vector3.Parse( param[ "direction" ].ToString() );
				}

				if ( param.ContainsKey( "diffuseColour" ) )
				{
					light.Diffuse = ColorEx.Parse_0_255_String( param[ "diffuseColour" ].ToString() );
				}

				if ( param.ContainsKey( "specularColour" ) )
				{
					light.Specular = ColorEx.Parse_0_255_String( param[ "specularColour" ].ToString() );
				}

				if ( param.ContainsKey( "attenuation" ) )
				{
					Vector4 attenuation = Vector4.Parse( param[ "attenuation" ].ToString() );
					light.SetAttenuation( attenuation.x, attenuation.y, attenuation.z, attenuation.w );
				}

				if ( param.ContainsKey( "castShadows" ) )
				{
					light.CastShadows = Convert.ToBoolean( param[ "castShadows" ].ToString() );
				}

				if ( param.ContainsKey( "visible" ) )
				{
					light.CastShadows = Convert.ToBoolean( param[ "visible" ].ToString() );
				}
				// TODO: Add PowerScale Property to Light
				if ( param.ContainsKey( "powerScale" ) )
				{
					light.PowerScale = (float)Convert.ToDouble( param[ "powerScale" ].ToString() );
				}
				// TODO: Add ShadowFarDistance to Light
				if ( param.ContainsKey( "shadowFarDistance" ) )
				{
					light.ShadowFarDistance = (float)Convert.ToDouble( param[ "shadowFarDistance" ].ToString() );
				}

				// Spotlight properties
				if ( param.ContainsKey( "spotlightInner" ) )
				{
					light.SpotlightInnerAngle = (float)Convert.ToDouble( param[ "spotlightInner" ].ToString() );
				}

				if ( param.ContainsKey( "spotlightOuter" ) )
				{
					light.SpotlightOuterAngle = (float)Convert.ToDouble( param[ "spotlightOuter" ].ToString() );
				}

				if ( param.ContainsKey( "spotlightFalloff" ) )
				{
					light.SpotlightFalloff = (float)Convert.ToDouble( param[ "spotlightFalloff" ].ToString() );
				}
			}

			return light;
		}
Ejemplo n.º 4
0
 public void AddToScene()
 {
     if (!foundOffset)
     {
         terrainOffset = position.y - app.GetTerrainHeight(Position.x, Position.z);
         foundOffset = true;
     }
     if (app.DisplayPointLightMarker)
     {
         this.DisplayPointLightMarker();
         if (displayObject.Entity.Mesh.TriangleIntersector == null)
             displayObject.Entity.Mesh.CreateTriangleIntersector();
     }
     string uniqueName = WorldEditor.GetUniqueName(ObjectType, name);
     pLight = this.scene.CreateLight(uniqueName);
     pLight.Type = Axiom.Graphics.LightType.Point;
     pLight.Position = position;
     pLight.Specular = specular;
     pLight.Diffuse = diffuse;
     pLight.IsVisible = true;
     pLight.SetAttenuation(attenuationRange, attenuationConstant, attenuationLinear, attenuationQuadratic);
     inScene = true;
     if (app.DisplayPointLightCircles)
     {
         UpdateShowCircles();
     }
 }