Light — Aspose.3D FOSS for .NET
เนมสเปซ: Aspose.ThreeD.Entities
Methods
Methods Light คลาสแสดงถึงแหล่งกำเนิดแสงที่แนบกับโหนดฉาก. มันสืบทอดจาก 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() | สร้าง point light ด้วยชื่อเริ่มต้น "Light", สีขาว, ความเข้ม 1.0, ระยะ 1.0 |
Light(LightType type) | สร้างแสงประเภทที่กำหนดด้วยชื่อเริ่มต้น "Light" |
Light(LightType type, string name) | สร้างแสงที่มีชื่อตามประเภทที่ระบุ |
Methods
| Methods | Methods | Methods | Methods |
|---|---|---|---|
Type | LightType | get | ประเภทของแสง (POINT, SPOT, DIRECTIONAL หรือ AMBIENT) ตั้งค่าเมื่อสร้าง; ไม่สามารถแก้ไขได้หลังจากนั้น. |
Color | Vector3 | get/set | สี RGB ของแสง ค่าเริ่มต้น: Vector3.One (ขาว) |
Intensity | float | get/set | ตัวคูณความสว่าง ค่าเริ่มต้น: 1.0 |
Range | float | รับ/ตั้งค่า | ระยะสูงสุดของอิทธิพลสำหรับไฟจุดและไฟสปอต ค่าเริ่มต้น: 1.0 |
Methods
| Methods | ประเภทการคืนค่า | Methods |
|---|---|---|
GetBoundingBox() | BoundingBox | คืนกล่องขอบเขตเปล่า (ไฟไม่มีขนาดเชิงเรขาคณิต) |
LightType
LightType เป็นคลาสประเภทค่า (value-type) ที่มีสี่อินสแตนซ์สาธารณะแบบ static:
| 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");