A3DObject / SceneObject / CustomObject

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

Gói: com.aspose.threed (aspose-3d-foss 26.1.0)

Ba lớp này tạo thành nền tảng của hệ thống lớp Aspose.3D. Mỗi đối tượng công khai trong thư viện kế thừa từ A3DObject, cung cấp một tên và một bộ sưu tập thuộc tính động. SceneObject mở rộng A3DObject với việc theo dõi thành viên trong cảnh. CustomObject là một lớp con cụ thể nhẹ để lưu trữ siêu dữ liệu người dùng tùy ý.


A3DObject

Lớp cơ sở gốc cho tất cả các đối tượng được quản lý Aspose.3D. Mỗi đối tượng có tên trong thư viện – Node, Mesh, AnimationClip, Material, và cứ như vậy – kế thừa từ A3DObject.

import com.aspose.threed.A3DObject;

Example

ExampleExampleExampleExampleExample
nameStringgetName()setName(String)Tên có thể đọc được của đối tượng. Mặc định là một chuỗi rỗng.
propertiesPropertyCollectiongetProperties()Bộ sưu tập thuộc tính động được gắn vào đối tượng này. Duyệt qua nó hoặc sử dụng findProperty() để tra cứu theo tên.

Example

findProperty(String propertyName)

Tìm kiếm một thuộc tính có tên trong đối tượng PropertyCollection và trả về Property đối tượng, hoặc null nếu không tìm thấy.

ExampleExampleExample
propertyNameStringTên để tìm kiếm.

Trả về: Property hoặc 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)

Trả về giá trị hiện tại của thuộc tính có tên, hoặc null nếu thuộc tính không tồn tại.

ExampleExampleExample
propertyStringTên thuộc tính.

Trả về: Object

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

setProperty(String property, Object value)

Đặt giá trị cho một thuộc tính có tên. Tạo thuộc tính nếu nó chưa tồn tại.

ExampleExampleExample
propertyStringTên thuộc tính.
valueObjectGiá trị mới.

Trả về: void

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

removeProperty(String property)

Xóa một thuộc tính có tên khỏi bộ sưu tập.

ExampleExampleExample
propertyString hoặc PropertyTên thuộc tính hoặc Property đối tượng cần xóa.

Trả về: booleantrue nếu thuộc tính được tìm thấy và đã xóa.


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 với một tham chiếu tới chủ sở hữu Scene. Node, Entity, và các lớp liên quan kế thừa từ SceneObject.

import com.aspose.threed.SceneObject;

Example

A3DObject -> SceneObject

Thuộc tính bổ sung

ExampleExampleExampleExampleExample
sceneScenegetScene()setScene(Scene)Example Scene đối tượng này thuộc về, hoặc null nếu chưa được gắn kết.
import com.aspose.threed.Scene;

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

CustomObject

Một lớp con của bê tông nhẹ A3DObject chỉ mang một tên và một giá trị bất kỳ PropertyCollection. Sử dụng nó để đính kèm siêu dữ liệu dạng tự do vào một cảnh mà không cần tạo lớp con cho bất kỳ loại thực thể nào.

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

Xem thêm

 Tiếng Việt