Node — Aspose.3D FOSS for Java
Methods
Methods Node class rappresenta un elemento nominato nel Aspose.3D scene graph. Ogni nodo può contenere uno Entity (come ad esempio un Mesh o Camera).
import com.aspose.threed.Scene;
import com.aspose.threed.Node;
Scene scene = new Scene();
// Access the root node via getter
Node root = scene.getRootNode();
// Create a child node
Node child = root.createChildNode("my_node");
// Iterate child nodes via getter
for (Node node : root.getChildNodes()) {
System.out.println(node.getName());
}Methods
Methods Node Il costruttore inizializza un nodo con un nome opzionale.
| Methods | Methods | Methods |
|---|---|---|
name | String | Nome opzionale per il nodo |
Methods
Tutti gli attributi del nodo sono accessibili tramite metodi getter/setter.
| Methods | Methods | Methods | Methods | Methods |
|---|---|---|---|---|
name | String | getName() | setName(String) | Identificatore leggibile dall’uomo per il nodo |
entity | Entity | getEntity() | setEntity(Entity) | L’entità primaria collegata a questo nodo (e.g., Mesh, Camera). Scorciatoia per il primo elemento di getEntities(). |
entities | List<Entity> | getEntities() | – | Tutte le entità collegate a questo nodo (sola lettura) |
material | Material | getMaterial() | setMaterial(Material) | Il materiale primario assegnato a questo nodo |
materials | List<Material> | getMaterials() | – | Tutti i materiali assegnati a questo nodo (sola lettura) |
childNodes | List<Node> | getChildNodes() | – | Elenco dei nodi figli |
parentNode | Node | getParentNode() | setParentNode(Node) | Nodo genitore immediato nella gerarchia della scena (getParentNodes() non è disponibile su Node) |
visible | boolean | getVisible() | setVisible(boolean) | Methods false, il nodo e il suo sottoalbero sono nascosti |
excluded | boolean | getExcluded() | setExcluded(boolean) | Methods true, questo nodo è escluso dal rendering |
transform | Transform | getTransform() | – | Trasformazione locale (traslazione, rotazione, scala) |
globalTransform | GlobalTransform | getGlobalTransform() | – | Matrice di trasformazione nello spazio mondiale |
assetInfo | AssetInfo | getAssetInfo() | setAssetInfo(AssetInfo) | Metadati dell’asset allegati a questo nodo, se presenti |
properties | PropertyCollection | getProperties() | – | Proprietà personalizzate collegate a questo nodo |
Methods
| Methods | Tipo di ritorno | Methods |
|---|---|---|
createChildNode(String name) | Node | Crea e collega un nuovo nodo figlio con il nome fornito |
createChildNode(String name, Entity entity) | Node | Crea un nodo figlio e gli assegna un’entità |
addChildNode(Node node) | void | Aggiunge un nodo esistente come figlio di questo nodo |
getChild(String name) | Node | Trova un nodo figlio diretto per nome |
addEntity(Entity entity) | void | Collega un’entità aggiuntiva a questo nodo |
merge(Node node) | void | Unisce i figli e le entità di un altro nodo in questo nodo |
evaluateGlobalTransform(boolean withGeometricTransform) | Matrix4 | Restituisce la matrice di trasformazione nello spazio mondiale; passa true per includere gli offset geometrici |
getBoundingBox() | BoundingBox | Stub in questa edizione — restituisce sempre un sentinel BoundingBox (min = Double.MAX_VALUE, max = Double.MIN_VALUE). Nessuna computazione geometrica viene eseguita. |
getProperty(String name) | Object | Ottiene il valore di una proprietà per nome |
findProperty(String name) | Property | Trova una proprietà per nome |
Methods
Crea una scena, collega una mesh a un nodo e attraversa il grafo della scena:
import com.aspose.threed.Scene;
import com.aspose.threed.Node;
import com.aspose.threed.*;
Scene scene = new Scene();
Mesh mesh = new Mesh();
mesh.getControlPoints().add(new Vector4(0, 0, 0, 1));
mesh.getControlPoints().add(new Vector4(1, 0, 0, 1));
mesh.getControlPoints().add(new Vector4(0.5, 1, 0, 1));
mesh.createPolygon(0, 1, 2);
// Attach mesh to a child node
Node node = scene.getRootNode().createChildNode("triangle", mesh);
// Traverse child nodes using getter
for (Node child : scene.getRootNode().getChildNodes()) {
Entity entity = child.getEntity();
if (entity != null) {
System.out.println("Node '" + child.getName() + "': " + entity.getClass().getSimpleName());
System.out.println(" Excluded: " + child.getExcluded());
}
}