A3DObject / SceneObject / CustomObject

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

Paketti: com.aspose.threed (aspose-3d-foss 26.1.0)

Nämä kolme luokkaa muodostavat Aspose.3D-luokkahierarkian perustan. Jokainen kirjastoissa oleva julkinen olio perii A3DObject, joka tarjoaa nimen ja dynaamisen ominaisuuskokoelman. SceneObject laajentaa A3DObject scene-jäsenyyden seurannalla. CustomObject on kevyt konkreettinen alaluokka, joka tallentaa mielivaltaista käyttäjän metadataa.


A3DObject

Juuriperusluokka kaikille Aspose.3D hallinnoiduille objekteille. Jokainen nimetty objekti kirjastossa – Node, Mesh, AnimationClip, Material, ja niin edelleen – perii A3DObject.

import com.aspose.threed.A3DObject;

Example

ExampleExampleExampleExampleExample
nameStringgetName()setName(String)Ihmisluettava nimi objektista. Oletuksena tyhjä merkkijono.
propertiesPropertyCollectiongetProperties()Dynaaminen ominaisuuskokoelma, joka on liitetty tähän objektiin. Käy se läpi tai käytä findProperty() nimettyihin hakuun.

Example

findProperty(String propertyName)

Etsi nimetty ominaisuus tämän objektin PropertyCollection ja palauta Property instanssi, tai null jos ei löydy.

ExampleExampleExample
propertyNameStringHaettava nimi.

Palauttaa: Property tai 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)

Palauta annetun ominaisuuden nykyinen arvo, tai null jos ominaisuutta ei ole olemassa.

ExampleExampleExample
propertyStringOminaisuuden nimi.

Palauttaa: Object

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

setProperty(String property, Object value)

Aseta nimettyyn ominaisuuteen arvo. Luo ominaisuus, jos sitä ei vielä ole olemassa.

ExampleExampleExample
propertyStringOminaisuuden nimi.
valueObjectUusi arvo.

Palauttaa: void

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

removeProperty(String property)

Poista nimetty ominaisuus kokoelmasta.

ExampleExampleExample
propertyString tai PropertyOminaisuuden nimi tai Property poistettava instanssi.

Palauttaa: booleantrue jos ominaisuus löytyi ja poistettiin.


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 viitteellä omistavaan Scene. Node, Entity, ja siihen liittyvät luokat perivät SceneObject.

import com.aspose.threed.SceneObject;

Example

A3DObject -> SceneObject

Lisäominaisuus

ExampleExampleExampleExampleExample
sceneScenegetScene()setScene(Scene)Example Scene tähän objektiin, johon se kuuluu, tai null jos ei ole vielä liitetty.
import com.aspose.threed.Scene;

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

CustomObject

Kevytbetonin alaluokka A3DObject joka kantaa vain nimen ja mielivaltaisen PropertyCollection. Käytä sitä liittääksesi vapaamuotoista metadataa kohtaukseen ilman aliluokittelematta mitään entiteettityyppiä.

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

Katso myös

 Suomi