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

ראה גם

 עברית