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

ExampleExampleExampleExample
Namestringget/set节点的人类可读标识符
EntityEntityget/set附加到此节点的主要实体
EntitiesList<Entity>get附加到此节点的所有实体
ChildNodesList<Node>get场景层次结构中的子节点
ParentNodeNodeget层次结构中的父节点
TransformTransformget本地变换(平移、旋转、缩放)
GlobalTransformGlobalTransform获取已计算的世界空间变换
PropertiesPropertyCollection获取自定义属性

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");

另见

 中文