A3DObject / SceneObject / CustomObject

A3DObject, SceneObject, CustomObject — Aspose.3D FOSS for Java

แพคเกจ: com.aspose.threed (aspose-3d-foss 26.1.0)

คลาสสามคลาสนี้เป็นฐานของลำดับชั้นคลาส Aspose.3D ทุกวัตถุสาธารณะในไลบรารีสืบทอดจาก A3DObject, ซึ่งให้ชื่อและคอลเลกชันของคุณสมบัติดินามิก. SceneObject extends A3DObject พร้อมการติดตามการเป็นสมาชิกของฉาก. CustomObject เป็นคลาสย่อย lightweight ของ Concrete สำหรับจัดเก็บเมตาดาต้าผู้ใช้แบบ任意.


A3DObject

คลาสฐานรากสำหรับวัตถุที่จัดการโดย Aspose.3D ทั้งหมด. ทุกวัตถุที่มีชื่อในไลบรารี – Node, Mesh, AnimationClip, Material, และต่อไป – สืบทอดจาก A3DObject.

import com.aspose.threed.A3DObject;

Example

ExampleExampleExampleExampleExample
nameStringgetName()setName(String)ชื่อของวัตถุที่มนุษย์อ่านได้. ค่าเริ่มต้นเป็นสตริงว่าง.
propertiesPropertyCollectiongetProperties()คอลเลกชันคุณสมบัติแบบไดนามิกที่แนบกับอ็อบเจ็กต์นี้. วนซ้ำหรือใช้ findProperty() สำหรับการค้นหาตามชื่อ.

Example

findProperty(String propertyName)

ค้นหาคุณสมบัติตามชื่อในอ็อบเจ็กต์ของนี้ PropertyCollection และคืนค่า Property อินสแตนซ์, หรือ null หากไม่พบ.

ExampleExampleExample
propertyNameStringชื่อที่ต้องการค้นหา.

คืนค่า: Property หรือ null

import com.aspose.threed.Scene;

Scene scene = new Scene();
Node node = scene.getRootNode().createChildNode("origin");
Property prop = node.findProperty("name");
if (prop != null) {
    System.out.println(prop.getValue());   // "origin"
}

getProperty(String property)

คืนค่าปัจจุบันของคุณสมบัติที่มีชื่อ, หรือ null หากคุณสมบัตินั้นไม่มีอยู่.

ExampleExampleExample
propertyStringชื่อคุณสมบัติ.

คืนค่า: Object

Object val = node.getProperty("name");
System.out.println(val);   // "origin"

setProperty(String property, Object value)

ตั้งค่าของ property ที่มีชื่อ. สร้าง property หากยังไม่มีอยู่.

ExampleExampleExample
propertyStringชื่อคุณสมบัติ.
valueObjectค่ใหม่.

คืนค่า: void

node.setProperty("layer", 3);
System.out.println(node.getProperty("layer"));   // 3

removeProperty(String property)

ลบคุณสมบัติที่ระบุชื่อออกจากคอลเลกชัน.

ExampleExampleExample
propertyString หรือ Propertyชื่อคุณสมบัติหรือ Property อินสแตนซ์ที่จะลบ.

คืนค่า: booleantrue ถ้าพบและลบคุณสมบัติแล้ว.


Example

import com.aspose.threed.Scene;
import com.aspose.threed.Node;
import com.aspose.threed.Property;

Scene scene = new Scene();
Node node = scene.getRootNode().createChildNode("my_node");

// Set and retrieve a custom property
node.setProperty("export_lod", 2);
System.out.println(node.getProperty("export_lod"));   // 2

// Enumerate all properties
for (Property prop : node.getProperties()) {
    System.out.println("  " + prop.getName() + " = " + prop.getValue());
}

// Find and inspect a specific property
Property p = node.findProperty("name");
if (p != null) {
    System.out.println(p.getValueType());   // java.lang.String
}

SceneObject

Example A3DObject พร้อมอ้างอิงถึงเจ้าของ Scene. Node, Entity, และคลาสที่เกี่ยวข้องสืบทอดจาก SceneObject.

import com.aspose.threed.SceneObject;

Example

A3DObject -> SceneObject

คุณสมบัติเพิ่มเติม

ExampleExampleExampleExampleExample
sceneScenegetScene()setScene(Scene)Example Scene ออบเจ็กต์นี้เป็นของ, หรือ null หากยังไม่ได้เชื่อมต่อ.
import com.aspose.threed.Scene;

Scene scene = new Scene();
Node node = scene.getRootNode().createChildNode("child");
System.out.println(node.getScene() == scene);   // true

CustomObject

คลาสย่อยของคอนกรีตเบา A3DObject ที่บรรจุเพียงชื่อและค่าตามอำเภอใจ PropertyCollection. ใช้มันเพื่อแนบ free-form metadata ไปยังฉากโดยไม่ต้องสร้างซับคลาสของ entity type ใดๆ.

import com.aspose.threed.CustomObject;

Example

A3DObject -> CustomObject

Example

CustomObject()
CustomObject(String name)

Example

import com.aspose.threed.CustomObject;
import com.aspose.threed.Scene;

// Attach pipeline metadata to a scene as a custom object
CustomObject meta = new CustomObject("render_settings");
meta.setProperty("max_bounces", 8);
meta.setProperty("use_denoiser", true);

Scene scene = new Scene();
scene.getRootNode().setProperty("render_meta", meta.getName());
System.out.println(meta.getProperty("max_bounces"));   // 8

ดูเพิ่มเติม

 ภาษาไทย