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
| Methods | Methods |
|---|---|
Light() | 创建一个默认名称的点光源 "Light",,白色,强度 1.0,,范围 1.0 |
Light(LightType type) | 创建具有默认名称的给定类型灯光 "Light" |
Light(LightType type, string name) | 创建具名的给定类型灯光 |
Methods
| Methods | Methods | Methods | Methods |
|---|---|---|---|
Type | LightType | 获取 | 灯光类型(POINT、SPOT、DIRECTIONAL 或 AMBIENT)。在构造时设置;之后为只读。. |
Color | Vector3 | 获取/设置 | 灯光的 RGB 颜色。默认值:: Vector3.One (白色) |
Intensity | float | 获取/设置 | 亮度乘数。默认:: 1.0 |
Range | float | 获取/设置 | 点光源和聚光灯的最大影响距离。默认:: 1.0 |
Methods
| Methods | 返回类型 | Methods |
|---|---|---|
GetBoundingBox() | BoundingBox | 返回一个空的边界框(灯光没有几何范围) |
LightType
LightType 是一个值类型类,具有四个公共静态实例::
| Methods | Methods |
|---|---|
LightType.POINT | 从空间中的一点向所有方向均匀发光 |
LightType.SPOT | 在节点面向的方向发出光锥 |
LightType.DIRECTIONAL | 发出平行光线,仿佛来自无限遥远的光源 |
LightType.AMBIENT | 添加均匀的环境光照;范围和方向不被使用 |
LightType 有一个属性::
| Methods | Methods | Methods | Methods |
|---|---|---|---|
Name | string | 获取 | 光类型的显示名称("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");