This page has been translated automatically.
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Landscape Tool
Using Editor Tools for Specific Tasks
FAQ
编程
Fundamentals
Setting Up Development Environment
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
应用程序接口
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
CIGI Client Plugin
Rendering-Related Classes
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

Unigine::NodeTrigger Class

Header: #include <UnigineNodes.h>
Inherits: Node
Read More

NodeTrigger Class

Members


static NodeTriggerPtr create ( )

Constructor. Creates a new trigger node.

Ptr<NodeTrigger> cast( const Ptr<Node> & node )

Casts a NodeTrigger out of the Node instance.

Arguments

  • const Ptr<Node> & node - Pointer to Node.

Return value

Pointer to NodeTrigger.

void * addEnabledCallback( Unigine::CallbackBase1< Ptr<NodeTrigger> > * func )

Sets a pointer to a callback to be fired when the trigger node is enabled. The callback function must receive a NodeTrigger as its first argument. In addition, it can also take 2 arguments of any type.
Source code (C++)
// implement the enabled callback
void AppWorldLogic::enabled_callback(NodeTriggerPtr trigger){
	Log::message("The enabled flag is %d\n", trigger->isEnabled());
}

NodeTriggerPtr trigger;

int AppWorldLogic::init() {

	// create a trigger node
	trigger = NodeTrigger::create();
	
	// add the enabled callback to be fired when the node is enabled/disabled
	trigger->addEnabledCallback(MakeCallback(this, &AppWorldLogic::enabled_callback));
	
	return 1;
}

Arguments

  • Unigine::CallbackBase1< Ptr<NodeTrigger> > * func - Callback pointer.

Return value

ID of the last added enabled callback, if the callback was added successfully; otherwise, nullptr. This ID can be used to remove this callback when necessary.

bool removeEnabledCallback( void * id )

Removes the specified callback from the list of enabled callbacks.

Arguments

  • void * id - Enabled callback ID obtained when adding it.

Return value

True if the enabled callback with the given ID was removed successfully; otherwise false.

void clearEnabledCallbacks( )

Clears all added enabled callbacks.

void setEnabledCallbackName( const char * name )

Sets a callback function to be fired when the trigger node is enabled. The callback function must be implemented in the world script (on the UnigineScript side). The callback function can take no arguments, a Node or a NodeTrigger.
Notice
The method allows for setting a callback with 0 or 1 argument only. To set the callback with additional arguments, use setEnabledCallback().
On UnigineScript side:
Source code (UnigineScript)
// implement the enabled callback
void enabled_callback(Node node) {
	log.message("The enabled flag is %d\n", node.isEnabled());
}
On C++ side:
Source code (C++)
NodeTriggerPtr trigger;

int AppWorldLogic::init() {

	// create a trigger node
	trigger = NodeTrigger::create();
	
	// set the enabled callback to be fired when the node is enabled/disabled
	trigger->setEnabledCallbackName("enabled_callback");
	
	return 1;
}

Arguments

  • const char * name - Name of the callback function implemented in the world script (UnigineScript side).

const char * getEnabledCallbackName( )

Returns the name of callback function to be fired on enabling the trigger node. This callback function is set via setEnabledCallbackName().

Return value

Name of the callback function implemented in the world script (UnigineScript side).

void * addPositionCallback( Unigine::CallbackBase1< Ptr<NodeTrigger> > * func )

Adds a pointer to a callback to be fired when the trigger node position has changed. The callback function must receive a NodeTrigger as its first argument. In addition, it can also take 2 arguments of any type.
Source code (C++)
// implement the position callback
void AppWorldLogic::position_callback(NodeTriggerPtr trigger){
	Log::message("A new position of the node is (%f %f %f)\n", trigger->getWorldPosition().x, trigger->getWorldPosition().y, trigger->getWorldPosition().z);
}

NodeTriggerPtr trigger;

int AppWorldLogic::init() {

	// create a trigger node
	trigger = NodeTrigger::create();
	
	// add the position callback to be fired when the node position is changed
	trigger->addPositionCallback(MakeCallback(this, &AppWorldLogic::position_callback));
	
	return 1;
}

Arguments

  • Unigine::CallbackBase1< Ptr<NodeTrigger> > * func - Callback pointer.

Return value

ID of the last added position callback, if the callback was added successfully; otherwise, nullptr. This ID can be used to remove this callback when necessary.

bool removePositionCallback( void * id )

Removes the specified callback from the list of position callbacks.

Arguments

  • void * id - Position callback ID obtained when adding it.

Return value

True if the position callback with the given ID was removed successfully; otherwise false.

void clearPositionCallbacks( )

Clears all added position callbacks.

void setPositionCallbackName( const char * name )

Sets a callback function to be fired when the trigger node position has changed. The callback function must be implemented in the world script (on the UnigineScript side). The callback function can take no arguments, a Node or a NodeTrigger.
Notice
The method allows for setting a callback with 0 or 1 argument only. To set the callback with additional arguments, use setPositionCallback().
On UnigineScript side:
Source code (UnigineScript)
// implement the position callback
void position_callback(Node node) {
	log.message("A new position of the node is %s\n", typeinfo(node.getWorldPosition()));
}
On C++ side:
Source code (C++)
NodeTriggerPtr trigger;

int AppWorldLogic::init() {

	// create a trigger node
	trigger = NodeTrigger::create();
	
	// set the position callback to be fired when the node position is changed
	trigger->setPositionCallbackName("position_callback");
	
	return 1;
}

Arguments

  • const char * name - Name of the callback function implemented in the world script (UnigineScript side).

const char * getPositionCallbackName( )

Returns the name of callback function to be fired on changing the trigger node position. This function is set by using the setPositionCallbackName() function.

Return value

Name of the callback function implemented in the world script (UnigineScript side).

int type( )

Returns the type of the node.

Return value

NodeTrigger type identifier.
Last update: 2018-12-27
Build: ()