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 คอนสตรัคเตอร์เริ่มต้นโหนดพร้อมชื่อที่เป็นตัวเลือก.

MethodsMethodsMethods
nameStringชื่อที่เป็นตัวเลือกสำหรับโหนด

Methods

คุณลักษณะทั้งหมดของโหนดจะถูกเข้าถึงผ่านเมธอด getter/setter.

MethodsMethodsMethodsMethodsMethods
nameStringgetName()setName(String)ตัวระบุที่อ่านได้โดยมนุษย์สำหรับโหนด
entityEntitygetEntity()setEntity(Entity)เอนทิตีหลักที่แนบกับโหนดนี้ (เช่น,., Mesh, Camera). ทางลัดสำหรับองค์ประกอบแรกของ getEntities().
entitiesList<Entity>getEntities()เอนทิตีทั้งหมดที่แนบกับโหนดนี้ (อ่านอย่างเดียว)
materialMaterialgetMaterial()setMaterial(Material)วัสดุหลักที่กำหนดให้กับโหนดนี้
materialsList<Material>getMaterials()วัสดุทั้งหมดที่กำหนดให้กับโหนดนี้ (อ่านอย่างเดียว)
childNodesList<Node>getChildNodes()รายการของโหนดลูก
parentNodeNodegetParentNode()setParentNode(Node)โหนดพาเรนท์โดยตรงในลำดับชั้นของฉาก (getParentNodes() ไม่พร้อมใช้งานบน Node)
visiblebooleangetVisible()setVisible(boolean)Methods false, โหนดและส่วนย่อยของมันถูกซ่อน
excludedbooleangetExcluded()setExcluded(boolean)Methods true, โหนดนี้ถูกยกเว้นจากการเรนเดอร์
transformTransformgetTransform()การแปลงท้องถิ่น (การย้ายตำแหน่ง, การหมุน, การสเกล)
globalTransformGlobalTransformgetGlobalTransform()เมทริกซ์การแปลงในอวกาศโลก
assetInfoAssetInfogetAssetInfo()setAssetInfo(AssetInfo)เมตาดาต้าแอสเซ็ตที่แนบกับโหนดนี้, หากมี
propertiesPropertyCollectiongetProperties()คุณสมบัติกำหนดเองที่แนบกับโหนดนี้

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());
    }
}

ดูเพิ่มเติม

 ภาษาไทย