Node — Aspose.3D FOSS for .NET
Example
Example Node class 表示 Aspose.3D 场景图中的命名元素。每个节点可以容纳一个 Entity (例如一个 Mesh, Camera,,或 Light),维护与其他节点的父子关系,并携带本地变换。节点是组织场景层次结构中 3D 对象的主要方式。.
using Aspose.ThreeD;
var scene = new Scene();
// Access the root node
Node root = scene.RootNode;
// Create a child node
Node child = root.CreateChildNode("my_node");
// Iterate child nodes
foreach (var node in root.ChildNodes)
{
Console.WriteLine(node.Name);
}Example
| Example | Example | Example | Example |
|---|---|---|---|
Name | string | get/set | 节点的人类可读标识符 |
Entity | Entity | get/set | 附加到此节点的主要实体 |
Entities | List<Entity> | get | 附加到此节点的所有实体 |
ChildNodes | List<Node> | get | 场景层次结构中的子节点 |
ParentNode | Node | get | 层次结构中的父节点 |
Transform | Transform | get | 本地变换(平移、旋转、缩放) |
GlobalTransform | GlobalTransform | 获取 | 已计算的世界空间变换 |
Properties | PropertyCollection | 获取 | 自定义属性 |
Example
| Example | 返回类型 | Example |
|---|---|---|
CreateChildNode(string name) | Node | 使用给定名称创建一个新的子节点 |
CreateChildNode(string name, Entity entity) | Node | 创建一个带有附加实体的子节点 |
Example
using Aspose.ThreeD;
using Aspose.ThreeD.Entities;
var scene = new Scene();
// Build a hierarchy with entities
var parent = scene.RootNode.CreateChildNode("Parent");
parent.Transform.Translation = new FVector3(10, 0, 0);
var box = new Box(2, 2, 2);
var child = parent.CreateChildNode("BoxChild", box);
child.Transform.Translation = new FVector3(5, 0, 0);
scene.Save("hierarchy.gltf");