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
| Example | Example | Example | Example | Example |
|---|---|---|---|---|
name | String | getName() | setName(String) | שם קריא לבני אדם של האובייקט. ברירת מחדל היא מחרוזת ריקה. |
properties | PropertyCollection | getProperties() | – | אוסף המאפיינים הדינמי המצורף לאובייקט זה. חזור עליו או השתמש findProperty() לחיפושים לפי שם. |
Example
findProperty(String propertyName)
חפש מאפיין בשם באובייקט של PropertyCollection והחזר את Property המופע, או null אם לא נמצא.
| Example | Example | Example |
|---|---|---|
propertyName | String | השם לחיפוש. |
מחזיר: 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 אם המאפיין אינו קיים.
| Example | Example | Example |
|---|---|---|
property | String | שם המאפיין. |
מחזיר: Object
Object val = node.getProperty("name");
System.out.println(val); // "origin"setProperty(String property, Object value)
מגדיר את הערך של נכס בעל שם. יוצר את הנכס אם הוא עדיין לא קיים.
| Example | Example | Example |
|---|---|---|
property | String | שם המאפיין. |
value | Object | ערך חדש. |
מחזיר: void
node.setProperty("layer", 3);
System.out.println(node.getProperty("layer")); // 3removeProperty(String property)
הסר מאפיין בעל שם מהאוסף.
| Example | Example | Example |
|---|---|---|
property | String או Property | שם המאפיין או Property מופע להסרה. |
מחזיר: boolean – true אם המאפיין נמצא והוסר.
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
מאפיין נוסף
| Example | Example | Example | Example | Example |
|---|---|---|---|---|
scene | Scene | getScene() | 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); // trueCustomObject
תת‑מחלקה של בטון קל משקל 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