Node — Aspose.3D FOSS for Java
Methods
Methods Node คลาสแสดงถึงองค์ประกอบที่มีชื่อใน Aspose.3D scene graph. แต่ละโหนดสามารถถือหนึ่ง Entity (เช่น a Mesh หรือ Camera), รักษาความสัมพันธ์แบบพ่อแม่-ลูกกับโหนดอื่น ๆ และบรรทุกการแปลงแบบโลคัล โหนดเป็นวิธีหลักในการจัดระเบียบวัตถุ 3D ในโครงสร้างลำดับชั้นของฉาก.
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 คอนสตรัคเตอร์เริ่มต้นโหนดพร้อมชื่อที่เป็นตัวเลือก.
| Methods | Methods | Methods |
|---|---|---|
name | String | ชื่อที่เป็นตัวเลือกสำหรับโหนด |
Methods
คุณลักษณะทั้งหมดของโหนดจะถูกเข้าถึงผ่านเมธอด getter/setter.
| Methods | Methods | Methods | Methods | Methods |
|---|---|---|---|---|
name | String | getName() | setName(String) | ตัวระบุที่อ่านได้โดยมนุษย์สำหรับโหนด |
entity | Entity | getEntity() | setEntity(Entity) | เอนทิตีหลักที่แนบกับโหนดนี้ (เช่น,., Mesh, Camera). ทางลัดสำหรับองค์ประกอบแรกของ getEntities(). |
entities | List<Entity> | getEntities() | – | เอนทิตีทั้งหมดที่แนบกับโหนดนี้ (อ่านอย่างเดียว) |
material | Material | getMaterial() | setMaterial(Material) | วัสดุหลักที่กำหนดให้กับโหนดนี้ |
materials | List<Material> | getMaterials() | – | วัสดุทั้งหมดที่กำหนดให้กับโหนดนี้ (อ่านอย่างเดียว) |
childNodes | List<Node> | getChildNodes() | – | รายการของโหนดลูก |
parentNode | Node | getParentNode() | setParentNode(Node) | โหนดพาเรนท์โดยตรงในลำดับชั้นของฉาก (getParentNodes() ไม่พร้อมใช้งานบน Node) |
visible | boolean | getVisible() | setVisible(boolean) | Methods false, โหนดและส่วนย่อยของมันถูกซ่อน |
excluded | boolean | getExcluded() | setExcluded(boolean) | Methods true, โหนดนี้ถูกยกเว้นจากการเรนเดอร์ |
transform | Transform | getTransform() | – | การแปลงท้องถิ่น (การย้ายตำแหน่ง, การหมุน, การสเกล) |
globalTransform | GlobalTransform | getGlobalTransform() | – | เมทริกซ์การแปลงในอวกาศโลก |
assetInfo | AssetInfo | getAssetInfo() | setAssetInfo(AssetInfo) | เมตาดาต้าแอสเซ็ตที่แนบกับโหนดนี้, หากมี |
properties | PropertyCollection | getProperties() | – | คุณสมบัติกำหนดเองที่แนบกับโหนดนี้ |
Methods
| Methods | ประเภทการคืนค่า | Methods |
|---|---|---|
createChildNode(String name) | Node | สร้างและแนบโหนดลูกใหม่ที่มีชื่อที่ระบุ |
createChildNode(String name, Entity entity) | Node | สร้างโหนดลูกและกำหนดเอนทิตีให้กับมัน |
addChildNode(Node node) | void | เพิ่มโหนดที่มีอยู่เป็นลูกของโหนดนี้ |
getChild(String name) | Node | ค้นหาโหนดลูกโดยตรงตามชื่อ |
addEntity(Entity entity) | void | แนบเอนทิตีเพิ่มเติมกับโหนดนี้ |
merge(Node node) | void | รวมโหนดลูกและเอนทิตีของโหนดอื่นเข้ากับโหนดนี้ |
evaluateGlobalTransform(boolean withGeometricTransform) | Matrix4 | คืนค่าเมทริกซ์การแปลงในระบบพิกัดโลก; ส่ง true เพื่อรวมการชดเชยเชิงเรขาคณิต |
getBoundingBox() | BoundingBox | โค้ดจำลองในรุ่นนี้ — เสมอคืนค่า sentinel BoundingBox (min = Double.MAX_VALUE, max = Double.MIN_VALUE) ไม่ได้ทำการคำนวณเรขาคณิต. |
getProperty(String name) | Object | ดึงค่าคุณสมบัติตามชื่อ |
findProperty(String name) | Property | ค้นหาคุณสมบัติตามชื่อ |
Methods
สร้างฉาก, แนบเมชไปยังโหนด, และเดินทางผ่านกราฟฉาก:
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());
}
}