节点参考
Node Reference is a node that refers to a .node file in the project directory, which is obtained by exporting a node from the world. Node Reference是一个指向项目目录中的.node文件的节点,该文件由从world导出获得。
The .node file usually contains a pre-fabricated node (or a hierarchy of nodes) with links to all materials and properties and configured physical bodies that are required for its rendering and behaviour. All changes made for the Node Reference content via UnigineEditor are saved into this file..node文件通常包含一个预制的节点(或节点的层次结构),其中链接到其呈现和行为所需的所有材质和属性以及配置的物理主体。通过UnigineEditor对Node Reference内容所做的所有更改都保存到这个文件中。
Node References should be used if a lot of identical objects are placed in the world: unlike regular nodes, Node Reference are loaded into the world faster because of the internal cache usage.如果在世界中放置了许多相同的对象,则应该使用Node References:与常规节点不同,Node Reference加载到世界中更快,因为内部缓存的使用。
Using Node Reference enables to avoid manual editing each identical object if you need to make the same changes in all of them. You can simply add several Node References that point to one .node file and then edit only one Node Reference in order to update them all. Such approach enables to hold to integrity of instanced objects, especially if they are complex and sophisticated.如果需要对所有对象进行相同的更改,使用Node Reference可以避免手动编辑每个相同的对象。 您可以简单地添加几个Node References,指向一个.node文件,然后只编辑一个Node Reference,以便更新它们全部。 这种方法能够保持实例对象的完整性,特别是如果它们是复杂和复杂的。
For example, the Node Reference can be used to add identical vehicles, characters, or buildings that should have the same look and behaviour and be updated at once, if necessary.例如,Node Reference可用于添加具有相同外观和行为的相同车辆、角色或建筑,并在必要时立即更新。
Node References support nesting, i.e. a Node Reference can include other Node References which is helpful for implementing complex instancing solutions.Node References支持嵌套,即Node Reference可以包含其他Node References,这有助于实现复杂的实例化解决方案。
Watch the following tutorial to learn the important things about Node Reference:观看下面的教程,了解关于Node Reference的重要事情:
Important Notes重要的笔记#
Referencing Content Outside引用外部内容#
A Node Reference should be thought of as a container for a self-sufficient hierarchy of nodes. When designing your world in UnigineEditor, avoid referencing nodes that are stored in a Node Reference directly from the outside (e.g. when manipulating nodes via Tracker, creating physical joints, specifying nodes in component parameters or the target node of a Player Persecutor) as such references will be lost as soon as the world is reloaded.Node Reference应该被认为是一个容器,用于存放自给自足的节点层次结构。当在UnigineEditor中设计您的世界时,避免直接从外部引用存储在Node Reference中的节点(例如,当通过 Tracker操作节点时,创建物理关节,指定组件参数或目标节点的Player tor),因为这样的引用将在世界重新加载时丢失。
Transformations转换#
The transformation of a Node Reference is not affected by the transformation of the nodes stored by it. Thus, logic-driven and physics-driven nodes inside a Node Reference will make no influence on its direct children.Node Reference的转换不受其存储的节点的转换的影响。因此,Node Reference中的逻辑驱动和物理驱动节点不会对其直接子节点产生影响。
In the following example, the moving grouped Node_1 and Node_2 nodes (e.g. driven by physics) contained by a Node Reference will not modify the transformation of the Node Reference and, therefore, the DirectChild node will not be affected as well.在下面的例子中,由Node Reference包含的移动分组 Node_1和Node_2节点(例如,由物理驱动)将不会修改Node Reference的转换,因此,DirectChild节点也不会受到影响。
So, it is recommended to enclose all interconnected nodes in a single Node Reference to ensure logical and hierarchical integrity.因此,建议将所有相互连接的节点封装在一个Node Reference中,以确保逻辑和层次的完整性。
See Also另请参阅#
- The Instancing Nodes article to learn more about using Node References to create identical objects.请参阅Instancing Nodes文章,了解有关使用Node References创建相同对象的更多信息。
- The NodeReference class to edit Node References via APINodeReference类编辑Node References通过API
- The Randomizer plugin to work with multiple Node ReferencesRandomizer插件使用多个Node References
- Node References: Must-Knows demonstrating the specifics of Node Reference节点引用:这 Node Reference展示的细节
Creating a Node Reference创建节点参考#
There are two ways to create a Node Reference via UnigineEditor:有两种方法通过UnigineEditor创建Node Reference:
-
Create a Node Reference from a previously created .node asset. In this case, you should export a node into a .node file first.创建一个节点引用从一个以前创建的.node资源。在这种情况下,您应该先出口节点到.node文件。
- Convert a node with all its child nodes present in the nodes hierarchy list into a Node Reference. In this case, the source node will change its type to a Node Reference.将节点及其在节点层次结构列表中的所有子节点转换为Node Reference。在本例中,源节点将其类型更改为Node Reference。
By Using a Node Asset通过节点资源使用#
- Export a node into a .node file or import the desired node file to the project. 将节点导出到.node文件或import所需的node文件到项目中。
-
Add the Node Reference to the world by either of the following ways:添加Node Reference世界通过以下方式:
On the Menu bar, click Create -> Node -> Reference and select the desired .node asset in the window that opens:在菜单栏上,单击Create -> Node -> Reference,并在打开的窗口中选择所需的.node资源:
It is not recommended to select a geometry container (.fbx, .dae, .gtlf, etc.) as the changes made to its node runtime will not be saved when reimporting the asset.不建议选择几何容器>- Drag the .node asset from the Asset Browser window.将 .node 资源从Asset Browser窗口拖拽。
You can repeat Step 2 in order to add the required number of Node References. Or you can simply clone the added node.您可以重复步骤2以添加所需数量的Node References。或者您可以简单地克隆>
By Converting an Existing Node通过将现有的节点#
- Select a node in the World Nodes Hierarchy window (or directly in the scene).在World Nodes Hierarchy窗口中选择一个节点(或直接在现场 )。
On the Menu bar, click Edit -> Convert to NodeReference (or press Ctrl+Shift+G).在菜单栏上单击“Edit -> Convert to NodeReference”(或按“Ctrl+Shift+G”)。
As a result, a new .node asset is created at the current folder and the source node is converted into the Node Reference:因此,创建一个新的.node资源在当前文件夹,源节点转换为Node Reference:
Source node to be converted需要转换的源节点
|
Converted node转换节点
|
You can also clone the converted node in order to get the required number of Node References.您也可以 clone转换的节点,以获得所需的Node References的数目。
Source nodes to be converted需要转换的源节点
|
Nodes grouped under a Dummy Node to which Node Reference refers分组在节点引用引用的Dummy Node下的节点
|
Editing a Node Reference编辑节点参考#
In the Reference section of the Node tab, you can change the asset of the source node or open the ReferenceNode Editor used to edit the source node: 在Node标签的Reference部分,您可以更改源节点的资源或打开用于编辑源节点的ReferenceNode Editor:
To edit the source node, to which the Node Reference points:编辑的源节点,Node Reference点:
- Select the Node Reference in the World Nodes Hierarchy window.在World Nodes Hierarchy窗口中选择Node Reference。
Click Edit in the Node tab of the Parameters window.单击Parameters窗口的Node选项卡中的Edit。
The source node becomes available in the World Nodes Hierarchy window as a child of the Node Reference and can be edited via the Parameters window.源节点可用在World Nodes Hierarchy窗口作为一个孩子节点的引用,并可以通过编辑Parameters窗口。
World Nodes Hierarchy window: source node in the edit modeWorld Nodes Hierarchy窗口:编辑模式下的源节点Edit the source node. For example, you can change the material applied to it:编辑源节点。例如,您可以更改应用到它的材质:
Node References with the red material applied节点引用的红色材质的应用Node References with the changed material带有已更改内容的节点引用You can also reorganize hierarchy and replace the source nodes, but keep note that only the first child will be saved in the Node Reference as Node Reference can contain only one root node.您还可以重新组织层次结构并替换源节点,但请注意只有第一个子节点将保存在Node Reference中作为Node Reference 只能包含一个根节点。
-
After all changes are made, select the parent node in the World Nodes Hierarchy window and click Apply to save changes to the source node or Cancel changes to keep nodes unchanged.所有更改完成后,在World Nodes Hierarchy窗口中选择父节点并单击Apply将更改保存到源节点或取消更改以保持节点不变。
Reference section in the Node tab of the parent Node ReferenceReference节Node选项卡的父节点参考
It is also possible to quick-replace the source node with another one stored in the same folder. To do that, select a Node Reference in the World Nodes Hierarchy window or the Viewport, hold Shift and use the mouse wheel or Page Up and Page Down buttons.也可以将源节点快速替换为存储在同一文件夹中的另一个节点。为此,在World Nodes Hierarchy窗口或Viewport中选择一个Node Reference,按住Shift并使用鼠标滚轮或Page Up和Page Down按钮。
Baking Light and Shadows for a Node Reference烘烤光和阴影的Node Reference#
Instances of a Node Reference may be illuminated differently. Thus, when light is baked for each of them, they will have individual lightmaps and depth textures (shadow maps). If you modify the Node Reference (change its hierarchy, replace the referenced asset, etc), these textures will be rebaked automatically after the Apply button is clicked. In code, the textures are updated by using the corresponding method.节点引用的实例可能以不同的方式显示。因此,当光被烘烤时,它们将有单独的光贴图和深度纹理(阴影贴图)。如果您修改节点引用(改变它的层次结构,替换被引用的资源等),这些纹理将在 Apply 按钮被点击后自动重新生成。在代码中,纹理通过使用相应的方法更新。
However, modifying (resetting) the path to the Node Reference's baked texture will affect all instances of the Node Reference, and automatic replacement of the unique baked texture for each individual Node Reference won't be available anymore. (You will have to replace baked textures manually for each instance.)然而,修改(重置)到Node Reference的烘焙纹理的路径将影响Node Reference的所有实例,并且为每个单独的Node Reference自动替换唯一的烘焙纹理将不再可用。(您必须为每个实例手动替换烘焙纹理。)