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

MethodsMethods
Light()สร้าง point light ด้วยชื่อเริ่มต้น "Light", สีขาว, ความเข้ม 1.0, ระยะ 1.0
Light(LightType type)สร้างแสงประเภทที่กำหนดด้วยชื่อเริ่มต้น "Light"
Light(LightType type, string name)สร้างแสงที่มีชื่อตามประเภทที่ระบุ

Methods

MethodsMethodsMethodsMethods
TypeLightTypegetประเภทของแสง (POINT, SPOT, DIRECTIONAL หรือ AMBIENT) ตั้งค่าเมื่อสร้าง; ไม่สามารถแก้ไขได้หลังจากนั้น.
ColorVector3get/setสี RGB ของแสง ค่าเริ่มต้น: Vector3.One (ขาว)
Intensityfloatget/setตัวคูณความสว่าง ค่าเริ่มต้น: 1.0
Rangefloatรับ/ตั้งค่าระยะสูงสุดของอิทธิพลสำหรับไฟจุดและไฟสปอต ค่าเริ่มต้น: 1.0

Methods

Methodsประเภทการคืนค่าMethods
GetBoundingBox()BoundingBoxคืนกล่องขอบเขตเปล่า (ไฟไม่มีขนาดเชิงเรขาคณิต)

LightType

LightType เป็นคลาสประเภทค่า (value-type) ที่มีสี่อินสแตนซ์สาธารณะแบบ static:

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

ดูเพิ่มเติม

 ภาษาไทย