This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
基础
专业(SIM)
UnigineEditor
界面概述
资源工作流程
版本控制
设置和首选项
项目开发
调整节点参数
Setting Up Materials
设置属性
照明
Sandworm
使用编辑器工具执行特定任务
如何擴展編輯器功能
嵌入式节点类型
Nodes
Objects
Effects
Decals
光源
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
使用范例
C++
C#
UnigineScript
统一的Unigine着色器语言 UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
材质和着色器
Rebuilding the Engine Tools
GUI
双精度坐标
应用程序接口
Animations-Related Classes
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
VR-Related Classes
创建内容
内容优化
材质
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

Unigine::NodeExtern Class

Header: #include <UnigineNodes.h>
Inherits from: Node

NodeExtern is a custom user-defined node created via API. The NodeExtern class is a wrapper for implementation of a custom node class inherited from the NodeExternBase class.

A NodeExtern node is created when the engine loads an instance of the custom node class. It can also be created directly by using the class constructor with a custom node class ID as an argument. In both cases, the NodeExtern node wraps the custom node class inherited from the NodeExternBase.

A custom user-defined node is created as follows:

Notice
The custom user-defined node can be implemented on the C++ side only. So you should implement the custom node class in C++ and then use it on the C++ or UnigineScript side.
  1. Inherit a custom node class from NodeExternBase:
    Source code (C++)
    #include <UnigineNodes.h>
    
    using namespace Unigine;
    
    // inherit a custom class from NodeExternBase
    class MyNode : public NodeExternBase
    {
    };
  2. Implement logic of the custom node and register the class via NodeExternBase::addClassID():
    Notice
    The custom node class isn't a node, as the NodeExternBase class isn't inherited from the Node class.
    Source code (C++)
    #include <UnigineNodes.h>
    #include <UnigineEngine.h>
    #include "AppSystemLogic.h"
    #include "AppWorldLogic.h"
    #include "AppEditorLogic.h"
    
    using namespace Unigine;
    
    // inherit a custom class from NodeExternBase
    class MyNode : public NodeExternBase
    {
    public:
    
    	// constructors
    	MyNode(){}
    	MyNode(void *node) : NodeExternBase(node){}
    	// destructor
    	virtual ~MyNode(){}
    
    	// unique class ID
    	virtual int getClassID() {return 1;}
    
    	// set world transformation of the node
    	void setWorldTransform(const Math::Mat4 &transform) {getNode()->setWorldTransform(transform);}
    
    	// other methods
    	// ...
    };
    
    int main(int argc,char *argv[]) {
    
    	// register the MyNode class
    	NodeExternBase::addClassID<MyNode>(1);
    
    	Unigine::EnginePtr engine(argc,argv);
    
    	AppSystemLogic system_logic;
    	AppWorldLogic world_logic;
    	AppEditorLogic editor_logic;
    
    	engine->main(&system_logic,&world_logic,&editor_logic);
    
    	return 0;
    }
    If required, the custom node class can be exported to UnigineScript.
  3. Create a custom node in one of the following ways:
    Source code (C++)
    // create a MyNode pointer directly: a NodeExtern node will be created as well
    MyNode *my_node_0 = new MyNode();
    // obtain the NodeExtern node
    my_node_0->getNodeExtern();
    
    // create a NodeExtern instance by MyNode's class ID
    NodeExternPtr my_node_1 = NodeExtern::create(1);
    // obtain the MyNode pointer if required
    MyNode *my_node_2 = (MyNode*)my_node_1->getNodeExtern();
    If the class has been exported to UnigineScript, you can perform the same on the UnigineScript side:
    Source code (UnigineScript)
    // create a MyNode pointer directly: a NodeExtern node will be created as well
    MyNode my_node_0 = new MyNode();
    // obtain the NodeExtern node
    my_node_0.getNodeExtern();
    
    // create a NodeExtern instance by MyNode's class ID
    NodeExtern my_node_1 = new NodeExtern(1);
    // obtain MyNode if required
    MyNode my_node_2 = class_cast("MyNode", node.getNodeExtern());

See Also#

  • The NodeExternBase class for the complete usage example of the NodeExtern and NodeExternBase classes.
  • A C++ API sample <UnigineSDK>/source/samples/Api/Nodes/NodeExtern

NodeExtern Class

Members


static NodeExternPtr create ( int class_id ) #

Constructor. Creates a custom user-defined node. An instance of the custom node class will be created as well.

Arguments

  • int class_id - Unique class ID.

int getClassID ( ) #

Returns the class ID of the node.

Return value

Class ID if the node exists; otherwise, 0.

NodeExternBase * getNodeExtern ( ) #

Returns the pointer to the custom node class.
Source code (C++)
// create a NodeExtern instance by MyNode's class ID
NodeExternPtr my_node_1 = NodeExtern::create(1);
// get the MyNode pointer
MyNode *my_node_2 = (MyNode*)my_node_1->getNodeExtern();

Return value

Pointer to the custom node class.

static int type ( ) #

Returns the type of the node.

Return value

NodeExtern type identifier.
Last update: 2024-04-19
Build: ()