Light — Aspose.3D FOSS for .NET

命名空间: Aspose.ThreeD.Entities

Methods

Methods Light class 表示附加到场景节点的光源。它 extends Entity 并支持四种光类型:directional、point、spot 和 ambient。通过创建子节点并将实体附加到它上来将光放置在场景中 Light 实体到它上。.

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);

Methods

MethodsMethods
Light()创建一个默认名称的点光源 "Light",,白色,强度 1.0,,范围 1.0
Light(LightType type)创建具有默认名称的给定类型灯光 "Light"
Light(LightType type, string name)创建具名的给定类型灯光

Methods

MethodsMethodsMethodsMethods
TypeLightType获取灯光类型(POINT、SPOT、DIRECTIONAL 或 AMBIENT)。在构造时设置;之后为只读。.
ColorVector3获取/设置灯光的 RGB 颜色。默认值:: Vector3.One (白色)
Intensityfloat获取/设置亮度乘数。默认:: 1.0
Rangefloat获取/设置点光源和聚光灯的最大影响距离。默认:: 1.0

Methods

Methods返回类型Methods
GetBoundingBox()BoundingBox返回一个空的边界框(灯光没有几何范围)

LightType

LightType 是一个值类型类,具有四个公共静态实例::

MethodsMethods
LightType.POINT从空间中的一点向所有方向均匀发光
LightType.SPOT在节点面向的方向发出光锥
LightType.DIRECTIONAL发出平行光线,仿佛来自无限遥远的光源
LightType.AMBIENT添加均匀的环境光照;范围和方向不被使用

LightType 有一个属性::

MethodsMethodsMethodsMethods
Namestring获取光类型的显示名称("Point", "Spot", "Directional", "Ambient")

Methods

向场景中添加一个定向光和一个点光,并保存为 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");

另请参阅

 中文