Light — Aspose.3D FOSS for .NET

Namespace: Aspose.ThreeD.Entities

Overview

The Light class represents a light source attached to a scene node. It extends Entity and supports four light types: directional, point, spot, and ambient. A light is placed in the scene by creating a child node and attaching the Light entity to it.

using Aspose.ThreeD;
using Aspose.ThreeD.Entities;
using Aspose.ThreeD.Utilities;

var scene = new Scene();

// Add a point light to the scene
var light = new Light(LightType.POINT, "SunLight");
light.Color = new Vector3(1.0f, 0.95f, 0.8f);
light.Intensity = 2.0f;
light.Range = 10.0f;

scene.RootNode.CreateChildNode("sun", light);

Constructors

ConstructorDescription
Light()Creates a point light with default name "Light", white color, intensity 1.0, range 1.0
Light(LightType type)Creates a light of the given type with default name "Light"
Light(LightType type, string name)Creates a named light of the given type

Properties

NameTypeAccessDescription
TypeLightTypegetThe light type (POINT, SPOT, DIRECTIONAL, or AMBIENT). Set at construction; read-only after.
ColorVector3get/setRGB colour of the light. Default: Vector3.One (white)
Intensityfloatget/setBrightness multiplier. Default: 1.0
Rangefloatget/setMaximum distance of influence for point and spot lights. Default: 1.0

Methods

MethodReturn TypeDescription
GetBoundingBox()BoundingBoxReturns an empty bounding box (lights have no geometric extent)

LightType

LightType is a value-type class with four public static instances:

InstanceDescription
LightType.POINTEmits light equally in all directions from a point in space
LightType.SPOTEmits a cone of light in the direction the node is facing
LightType.DIRECTIONALEmits parallel light rays as if from an infinitely distant source
LightType.AMBIENTAdds uniform ambient illumination; range and direction are not used

LightType has one property:

NameTypeAccessDescription
NamestringgetThe display name of the light type ("Point", "Spot", "Directional", "Ambient")

Example

Add a directional and a point light to a scene and save to FBX:

using Aspose.ThreeD;
using Aspose.ThreeD.Entities;
using Aspose.ThreeD.Utilities;

var scene = new Scene();

// Directional light — positioned and oriented via the node Transform
var dirLight = new Light(LightType.DIRECTIONAL, "Sun");
dirLight.Color = new Vector3(1.0f, 1.0f, 0.9f);
dirLight.Intensity = 1.5f;
scene.RootNode.CreateChildNode("dirLight", dirLight);

// Point light with limited range
var pointLight = new Light(LightType.POINT, "Lamp");
pointLight.Color = new Vector3(1.0f, 0.6f, 0.3f);
pointLight.Intensity = 3.0f;
pointLight.Range = 5.0f;
scene.RootNode.CreateChildNode("lamp", pointLight);

scene.Save("lit_scene.fbx");

See Also