A3DObject / SceneObject / CustomObject

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

Пакет: com.aspose.threed (aspose-3d-foss 26.1.0)

Ці три класи утворюють основу ієрархії класів Aspose.3D. Кожен публічний об’єкт у бібліотеці успадковується від A3DObject, який надає ім’я та динамічну колекцію властивостей. SceneObject розширює A3DObject з відстеженням членства у сцені. CustomObject є легковаговим конкретним підкласом для зберігання довільних метаданих користувача.


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)

Встановлює значення іменованої властивості. Створює властивість, якщо вона ще не існує.

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. Використовуйте його, щоб прикріпити вільно-формовані метадані до сцени без підкласування будь-якого типу сутності.

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

Див. також

 Українська