Unigine::World Class
Header: | #include <UnigineWorld.h> |
This class provides functionality for the world script. It contains methods required for loading the world with all its nodes, managing a spatial tree and handling nodes collisions and intersections.
Loading of nodes on demand is managed via the AsyncQueue Class.
See also#
- AsyncQueue Class to manage loading nodes and other resources on demand.
- The Intersections article demonstrating how to use intersection-related functions
World Class
枚举
MOVING_IMMOVABLE_NODES_MODE#
Members
void setUnpackNodeReferences ( bool references ) #
Arguments
- bool references - Set true to enable automatic unpacking of Node References at run time; false - to disable it.
bool isUnpackNodeReferences() const#
Return value
true if automatic unpacking of Node References at run time is enabled; otherwise false.void setAutoReloadNodeReferences ( bool references ) #
Arguments
- bool references - Set true to enable automatic reloading of Node References; false - to disable it.
bool isAutoReloadNodeReferences() const#
Return value
true if automatic reloading of Node References is enabled; otherwise false.void setUpdateGridSize ( float size ) #
Arguments
- float size - The grid size, in units. The default value is 1000 units.
float getUpdateGridSize() const#
Return value
Current grid size, in units. The default value is 1000 units.void setDistance ( float distance ) #
Arguments
- float distance - The distance at which (and farther) nothing will be rendered or simulated, in units.
float getDistance() const#
Return value
Current distance at which (and farther) nothing will be rendered or simulated, in units.void setBudget ( float budget ) #
Arguments
- float budget - The budget value in seconds. The default value is 1/60.
float getBudget() const#
Return value
Current budget value in seconds. The default value is 1/60.bool isLoaded() const#
Return value
true if the world is fully loaded; otherwise false.void setScriptName ( const char * name ) #
Arguments
- const char * name - The name of the world script *.usc file.
const char * getScriptName() const#
Return value
Current name of the world script *.usc file.void setPath ( const char * path ) #
Arguments
- const char * path - The path to the *.world-file where the world is stored.
const char * getPath() const#
Return value
Current path to the *.world-file where the world is stored.void setScriptExecute ( bool execute ) #
Arguments
- bool execute - Set true to enable a logic script associated with the world is to be loaded with it; false - to disable it.
bool isScriptExecute() const#
Return value
true if a logic script associated with the world is to be loaded with it; otherwise false.void setPhysicsSettings ( const char * settings ) #
Arguments
- const char * settings - The name of the *.physics file containing default physics settings used by the World.
const char * getPhysicsSettings() const#
Return value
Current name of the *.physics file containing default physics settings used by the World.void setSoundSettings ( const char * settings ) #
Arguments
- const char * settings - The name of the *.sound file containing default sound settings used by the World.
const char * getSoundSettings() const#
Return value
Current name of the *.sound file containing default sound settings used by the World.void setRenderSettings ( const char * settings ) #
Arguments
- const char * settings - The name of the *.render file containing default render settings used by the World.
const char * getRenderSettings() const#
Return value
Current name of the *.render file containing default render settings used by the World.const char * getLoadWorldRequestPath() const#
Return value
Current path to the world to be loaded.bool isLoadWorldRequested() const#
Return value
true if another world is going to be loaded in the next frame; otherwise false.void setMovingImmovableNodeMode ( World::MOVING_IMMOVABLE_NODES_MODE mode ) #
- At run-time for procedural generation of levels. This may cause some freezing but won't affect performance much. Upon completion of the generation process you should enable warnings again.
- On world initialization, this will change world loading time but won't affect overall performance.
Arguments
- World::MOVING_IMMOVABLE_NODES_MODE mode - The handling mode for attempts to move nodes having the Immovable flag enabled. One of the following values:
World::MOVING_IMMOVABLE_NODES_MODE getMovingImmovableNodeMode() const#
- At run-time for procedural generation of levels. This may cause some freezing but won't affect performance much. Upon completion of the generation process you should enable warnings again.
- On world initialization, this will change world loading time but won't affect overall performance.
Return value
Current handling mode for attempts to move nodes having the Immovable flag enabled. One of the following values:- 0 - movement of nodes having the Immovable flag is prohibited.
- 1 - movement of nodes having the Immovable flag is accompanied by a warning in the Console. (by default)
- 2 - movement of nodes having the Immovable flag is allowed (no warnings displayed).
void setAsyncLoadNodeReferences ( bool references ) #
Arguments
- bool references - Set true to enable asynchronous loading of Node References; false - to disable it.
bool isAsyncLoadNodeReferences() const#
Return value
true if asynchronous loading of Node References is enabled; otherwise false.static Event<const Ptr<Node> &> getEventNodeRemoved() const#
Usage Example
// implement the NodeRemoved event handler
void noderemoved_event_handler(const Ptr<Node> & node)
{
Log::message("\Handling NodeRemoved event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections noderemoved_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
World::getEventNodeRemoved().connect(noderemoved_event_connections, noderemoved_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
World::getEventNodeRemoved().connect(noderemoved_event_connections, [](const Ptr<Node> & node) {
Log::message("\Handling NodeRemoved event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
noderemoved_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection noderemoved_event_connection;
// subscribe to the NodeRemoved event with a handler function keeping the connection
World::getEventNodeRemoved().connect(noderemoved_event_connection, noderemoved_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
noderemoved_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
noderemoved_event_connection.setEnabled(true);
// ...
// remove subscription to the NodeRemoved event via the connection
noderemoved_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A NodeRemoved event handler implemented as a class member
void event_handler(const Ptr<Node> & node)
{
Log::message("\Handling NodeRemoved event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
World::getEventNodeRemoved().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. Subscribe to an event saving a particular connection ID
// and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// instance of the EventConnections class to manage event connections
EventConnections e_connections;
// define a particular connection ID to be used to unsubscribe later
EventConnectionId noderemoved_handler_id;
// subscribe to the NodeRemoved event with a lambda handler function and keeping connection ID
noderemoved_handler_id = World::getEventNodeRemoved().connect(e_connections, [](const Ptr<Node> & node) {
Log::message("\Handling NodeRemoved event (lambda).\n");
}
);
// remove the subscription later using the ID
World::getEventNodeRemoved().disconnect(noderemoved_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 5. Ignoring all NodeRemoved events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
World::getEventNodeRemoved().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
World::getEventNodeRemoved().setEnabled(true);
Return value
Event reference.static Event<const Ptr<Node> &> getEventNodeAdded() const#
Usage Example
// implement the NodeAdded event handler
void nodeadded_event_handler(const Ptr<Node> & node)
{
Log::message("\Handling NodeAdded event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections nodeadded_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
World::getEventNodeAdded().connect(nodeadded_event_connections, nodeadded_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
World::getEventNodeAdded().connect(nodeadded_event_connections, [](const Ptr<Node> & node) {
Log::message("\Handling NodeAdded event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
nodeadded_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection nodeadded_event_connection;
// subscribe to the NodeAdded event with a handler function keeping the connection
World::getEventNodeAdded().connect(nodeadded_event_connection, nodeadded_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
nodeadded_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
nodeadded_event_connection.setEnabled(true);
// ...
// remove subscription to the NodeAdded event via the connection
nodeadded_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A NodeAdded event handler implemented as a class member
void event_handler(const Ptr<Node> & node)
{
Log::message("\Handling NodeAdded event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
World::getEventNodeAdded().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. Subscribe to an event saving a particular connection ID
// and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// instance of the EventConnections class to manage event connections
EventConnections e_connections;
// define a particular connection ID to be used to unsubscribe later
EventConnectionId nodeadded_handler_id;
// subscribe to the NodeAdded event with a lambda handler function and keeping connection ID
nodeadded_handler_id = World::getEventNodeAdded().connect(e_connections, [](const Ptr<Node> & node) {
Log::message("\Handling NodeAdded event (lambda).\n");
}
);
// remove the subscription later using the ID
World::getEventNodeAdded().disconnect(nodeadded_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 5. Ignoring all NodeAdded events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
World::getEventNodeAdded().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
World::getEventNodeAdded().setEnabled(true);
Return value
Event reference.static Event<> getEventPostWorldShutdown() const#
Usage Example
// implement the PostWorldShutdown event handler
void postworldshutdown_event_handler()
{
Log::message("\Handling PostWorldShutdown event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections postworldshutdown_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
World::getEventPostWorldShutdown().connect(postworldshutdown_event_connections, postworldshutdown_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
World::getEventPostWorldShutdown().connect(postworldshutdown_event_connections, []() {
Log::message("\Handling PostWorldShutdown event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
postworldshutdown_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection postworldshutdown_event_connection;
// subscribe to the PostWorldShutdown event with a handler function keeping the connection
World::getEventPostWorldShutdown().connect(postworldshutdown_event_connection, postworldshutdown_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
postworldshutdown_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
postworldshutdown_event_connection.setEnabled(true);
// ...
// remove subscription to the PostWorldShutdown event via the connection
postworldshutdown_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A PostWorldShutdown event handler implemented as a class member
void event_handler()
{
Log::message("\Handling PostWorldShutdown event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
World::getEventPostWorldShutdown().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. Subscribe to an event saving a particular connection ID
// and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// instance of the EventConnections class to manage event connections
EventConnections e_connections;
// define a particular connection ID to be used to unsubscribe later
EventConnectionId postworldshutdown_handler_id;
// subscribe to the PostWorldShutdown event with a lambda handler function and keeping connection ID
postworldshutdown_handler_id = World::getEventPostWorldShutdown().connect(e_connections, []() {
Log::message("\Handling PostWorldShutdown event (lambda).\n");
}
);
// remove the subscription later using the ID
World::getEventPostWorldShutdown().disconnect(postworldshutdown_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 5. Ignoring all PostWorldShutdown events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
World::getEventPostWorldShutdown().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
World::getEventPostWorldShutdown().setEnabled(true);
Return value
Event reference.static Event<> getEventPreWorldShutdown() const#
Usage Example
// implement the PreWorldShutdown event handler
void preworldshutdown_event_handler()
{
Log::message("\Handling PreWorldShutdown event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections preworldshutdown_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
World::getEventPreWorldShutdown().connect(preworldshutdown_event_connections, preworldshutdown_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
World::getEventPreWorldShutdown().connect(preworldshutdown_event_connections, []() {
Log::message("\Handling PreWorldShutdown event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
preworldshutdown_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection preworldshutdown_event_connection;
// subscribe to the PreWorldShutdown event with a handler function keeping the connection
World::getEventPreWorldShutdown().connect(preworldshutdown_event_connection, preworldshutdown_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
preworldshutdown_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
preworldshutdown_event_connection.setEnabled(true);
// ...
// remove subscription to the PreWorldShutdown event via the connection
preworldshutdown_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A PreWorldShutdown event handler implemented as a class member
void event_handler()
{
Log::message("\Handling PreWorldShutdown event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
World::getEventPreWorldShutdown().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. Subscribe to an event saving a particular connection ID
// and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// instance of the EventConnections class to manage event connections
EventConnections e_connections;
// define a particular connection ID to be used to unsubscribe later
EventConnectionId preworldshutdown_handler_id;
// subscribe to the PreWorldShutdown event with a lambda handler function and keeping connection ID
preworldshutdown_handler_id = World::getEventPreWorldShutdown().connect(e_connections, []() {
Log::message("\Handling PreWorldShutdown event (lambda).\n");
}
);
// remove the subscription later using the ID
World::getEventPreWorldShutdown().disconnect(preworldshutdown_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 5. Ignoring all PreWorldShutdown events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
World::getEventPreWorldShutdown().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
World::getEventPreWorldShutdown().setEnabled(true);
Return value
Event reference.static Event<> getEventPostWorldInit() const#
Usage Example
// implement the PostWorldInit event handler
void postworldinit_event_handler()
{
Log::message("\Handling PostWorldInit event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections postworldinit_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
World::getEventPostWorldInit().connect(postworldinit_event_connections, postworldinit_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
World::getEventPostWorldInit().connect(postworldinit_event_connections, []() {
Log::message("\Handling PostWorldInit event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
postworldinit_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection postworldinit_event_connection;
// subscribe to the PostWorldInit event with a handler function keeping the connection
World::getEventPostWorldInit().connect(postworldinit_event_connection, postworldinit_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
postworldinit_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
postworldinit_event_connection.setEnabled(true);
// ...
// remove subscription to the PostWorldInit event via the connection
postworldinit_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A PostWorldInit event handler implemented as a class member
void event_handler()
{
Log::message("\Handling PostWorldInit event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
World::getEventPostWorldInit().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. Subscribe to an event saving a particular connection ID
// and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// instance of the EventConnections class to manage event connections
EventConnections e_connections;
// define a particular connection ID to be used to unsubscribe later
EventConnectionId postworldinit_handler_id;
// subscribe to the PostWorldInit event with a lambda handler function and keeping connection ID
postworldinit_handler_id = World::getEventPostWorldInit().connect(e_connections, []() {
Log::message("\Handling PostWorldInit event (lambda).\n");
}
);
// remove the subscription later using the ID
World::getEventPostWorldInit().disconnect(postworldinit_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 5. Ignoring all PostWorldInit events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
World::getEventPostWorldInit().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
World::getEventPostWorldInit().setEnabled(true);
Return value
Event reference.static Event<> getEventPreWorldInit() const#
Usage Example
// implement the PreWorldInit event handler
void preworldinit_event_handler()
{
Log::message("\Handling PreWorldInit event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections preworldinit_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
World::getEventPreWorldInit().connect(preworldinit_event_connections, preworldinit_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
World::getEventPreWorldInit().connect(preworldinit_event_connections, []() {
Log::message("\Handling PreWorldInit event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
preworldinit_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection preworldinit_event_connection;
// subscribe to the PreWorldInit event with a handler function keeping the connection
World::getEventPreWorldInit().connect(preworldinit_event_connection, preworldinit_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
preworldinit_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
preworldinit_event_connection.setEnabled(true);
// ...
// remove subscription to the PreWorldInit event via the connection
preworldinit_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A PreWorldInit event handler implemented as a class member
void event_handler()
{
Log::message("\Handling PreWorldInit event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
World::getEventPreWorldInit().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. Subscribe to an event saving a particular connection ID
// and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// instance of the EventConnections class to manage event connections
EventConnections e_connections;
// define a particular connection ID to be used to unsubscribe later
EventConnectionId preworldinit_handler_id;
// subscribe to the PreWorldInit event with a lambda handler function and keeping connection ID
preworldinit_handler_id = World::getEventPreWorldInit().connect(e_connections, []() {
Log::message("\Handling PreWorldInit event (lambda).\n");
}
);
// remove the subscription later using the ID
World::getEventPreWorldInit().disconnect(preworldinit_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 5. Ignoring all PreWorldInit events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
World::getEventPreWorldInit().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
World::getEventPreWorldInit().setEnabled(true);
Return value
Event reference.static Event<const char *, const Ptr<Node> &> getEventPostNodeSave() const#
Usage Example
// implement the PostNodeSave event handler
void postnodesave_event_handler(const char * world_file_path, const Ptr<Node> & node)
{
Log::message("\Handling PostNodeSave event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections postnodesave_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
World::getEventPostNodeSave().connect(postnodesave_event_connections, postnodesave_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
World::getEventPostNodeSave().connect(postnodesave_event_connections, [](const char * world_file_path, const Ptr<Node> & node) {
Log::message("\Handling PostNodeSave event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
postnodesave_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection postnodesave_event_connection;
// subscribe to the PostNodeSave event with a handler function keeping the connection
World::getEventPostNodeSave().connect(postnodesave_event_connection, postnodesave_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
postnodesave_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
postnodesave_event_connection.setEnabled(true);
// ...
// remove subscription to the PostNodeSave event via the connection
postnodesave_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A PostNodeSave event handler implemented as a class member
void event_handler(const char * world_file_path, const Ptr<Node> & node)
{
Log::message("\Handling PostNodeSave event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
World::getEventPostNodeSave().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. Subscribe to an event saving a particular connection ID
// and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// instance of the EventConnections class to manage event connections
EventConnections e_connections;
// define a particular connection ID to be used to unsubscribe later
EventConnectionId postnodesave_handler_id;
// subscribe to the PostNodeSave event with a lambda handler function and keeping connection ID
postnodesave_handler_id = World::getEventPostNodeSave().connect(e_connections, [](const char * world_file_path, const Ptr<Node> & node) {
Log::message("\Handling PostNodeSave event (lambda).\n");
}
);
// remove the subscription later using the ID
World::getEventPostNodeSave().disconnect(postnodesave_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 5. Ignoring all PostNodeSave events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
World::getEventPostNodeSave().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
World::getEventPostNodeSave().setEnabled(true);
Return value
Event reference.static Event<const char *, const Ptr<Node> &> getEventPreNodeSave() const#
Usage Example
// implement the PreNodeSave event handler
void prenodesave_event_handler(const char * world_file_path, const Ptr<Node> & node)
{
Log::message("\Handling PreNodeSave event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections prenodesave_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
World::getEventPreNodeSave().connect(prenodesave_event_connections, prenodesave_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
World::getEventPreNodeSave().connect(prenodesave_event_connections, [](const char * world_file_path, const Ptr<Node> & node) {
Log::message("\Handling PreNodeSave event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
prenodesave_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection prenodesave_event_connection;
// subscribe to the PreNodeSave event with a handler function keeping the connection
World::getEventPreNodeSave().connect(prenodesave_event_connection, prenodesave_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
prenodesave_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
prenodesave_event_connection.setEnabled(true);
// ...
// remove subscription to the PreNodeSave event via the connection
prenodesave_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A PreNodeSave event handler implemented as a class member
void event_handler(const char * world_file_path, const Ptr<Node> & node)
{
Log::message("\Handling PreNodeSave event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
World::getEventPreNodeSave().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. Subscribe to an event saving a particular connection ID
// and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// instance of the EventConnections class to manage event connections
EventConnections e_connections;
// define a particular connection ID to be used to unsubscribe later
EventConnectionId prenodesave_handler_id;
// subscribe to the PreNodeSave event with a lambda handler function and keeping connection ID
prenodesave_handler_id = World::getEventPreNodeSave().connect(e_connections, [](const char * world_file_path, const Ptr<Node> & node) {
Log::message("\Handling PreNodeSave event (lambda).\n");
}
);
// remove the subscription later using the ID
World::getEventPreNodeSave().disconnect(prenodesave_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 5. Ignoring all PreNodeSave events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
World::getEventPreNodeSave().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
World::getEventPreNodeSave().setEnabled(true);
Return value
Event reference.static Event<const char *> getEventPostWorldClear() const#
Usage Example
// implement the PostWorldClear event handler
void postworldclear_event_handler(const char * world_file_path)
{
Log::message("\Handling PostWorldClear event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections postworldclear_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
World::getEventPostWorldClear().connect(postworldclear_event_connections, postworldclear_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
World::getEventPostWorldClear().connect(postworldclear_event_connections, [](const char * world_file_path) {
Log::message("\Handling PostWorldClear event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
postworldclear_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection postworldclear_event_connection;
// subscribe to the PostWorldClear event with a handler function keeping the connection
World::getEventPostWorldClear().connect(postworldclear_event_connection, postworldclear_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
postworldclear_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
postworldclear_event_connection.setEnabled(true);
// ...
// remove subscription to the PostWorldClear event via the connection
postworldclear_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A PostWorldClear event handler implemented as a class member
void event_handler(const char * world_file_path)
{
Log::message("\Handling PostWorldClear event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
World::getEventPostWorldClear().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. Subscribe to an event saving a particular connection ID
// and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// instance of the EventConnections class to manage event connections
EventConnections e_connections;
// define a particular connection ID to be used to unsubscribe later
EventConnectionId postworldclear_handler_id;
// subscribe to the PostWorldClear event with a lambda handler function and keeping connection ID
postworldclear_handler_id = World::getEventPostWorldClear().connect(e_connections, [](const char * world_file_path) {
Log::message("\Handling PostWorldClear event (lambda).\n");
}
);
// remove the subscription later using the ID
World::getEventPostWorldClear().disconnect(postworldclear_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 5. Ignoring all PostWorldClear events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
World::getEventPostWorldClear().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
World::getEventPostWorldClear().setEnabled(true);
Return value
Event reference.static Event<const char *> getEventPreWorldClear() const#
Usage Example
// implement the PreWorldClear event handler
void preworldclear_event_handler(const char * world_file_path)
{
Log::message("\Handling PreWorldClear event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections preworldclear_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
World::getEventPreWorldClear().connect(preworldclear_event_connections, preworldclear_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
World::getEventPreWorldClear().connect(preworldclear_event_connections, [](const char * world_file_path) {
Log::message("\Handling PreWorldClear event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
preworldclear_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection preworldclear_event_connection;
// subscribe to the PreWorldClear event with a handler function keeping the connection
World::getEventPreWorldClear().connect(preworldclear_event_connection, preworldclear_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
preworldclear_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
preworldclear_event_connection.setEnabled(true);
// ...
// remove subscription to the PreWorldClear event via the connection
preworldclear_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A PreWorldClear event handler implemented as a class member
void event_handler(const char * world_file_path)
{
Log::message("\Handling PreWorldClear event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
World::getEventPreWorldClear().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. Subscribe to an event saving a particular connection ID
// and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// instance of the EventConnections class to manage event connections
EventConnections e_connections;
// define a particular connection ID to be used to unsubscribe later
EventConnectionId preworldclear_handler_id;
// subscribe to the PreWorldClear event with a lambda handler function and keeping connection ID
preworldclear_handler_id = World::getEventPreWorldClear().connect(e_connections, [](const char * world_file_path) {
Log::message("\Handling PreWorldClear event (lambda).\n");
}
);
// remove the subscription later using the ID
World::getEventPreWorldClear().disconnect(preworldclear_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 5. Ignoring all PreWorldClear events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
World::getEventPreWorldClear().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
World::getEventPreWorldClear().setEnabled(true);
Return value
Event reference.static Event<const char *> getEventPostWorldSave() const#
Usage Example
// implement the PostWorldSave event handler
void postworldsave_event_handler(const char * world_file_path)
{
Log::message("\Handling PostWorldSave event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections postworldsave_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
World::getEventPostWorldSave().connect(postworldsave_event_connections, postworldsave_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
World::getEventPostWorldSave().connect(postworldsave_event_connections, [](const char * world_file_path) {
Log::message("\Handling PostWorldSave event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
postworldsave_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection postworldsave_event_connection;
// subscribe to the PostWorldSave event with a handler function keeping the connection
World::getEventPostWorldSave().connect(postworldsave_event_connection, postworldsave_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
postworldsave_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
postworldsave_event_connection.setEnabled(true);
// ...
// remove subscription to the PostWorldSave event via the connection
postworldsave_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A PostWorldSave event handler implemented as a class member
void event_handler(const char * world_file_path)
{
Log::message("\Handling PostWorldSave event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
World::getEventPostWorldSave().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. Subscribe to an event saving a particular connection ID
// and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// instance of the EventConnections class to manage event connections
EventConnections e_connections;
// define a particular connection ID to be used to unsubscribe later
EventConnectionId postworldsave_handler_id;
// subscribe to the PostWorldSave event with a lambda handler function and keeping connection ID
postworldsave_handler_id = World::getEventPostWorldSave().connect(e_connections, [](const char * world_file_path) {
Log::message("\Handling PostWorldSave event (lambda).\n");
}
);
// remove the subscription later using the ID
World::getEventPostWorldSave().disconnect(postworldsave_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 5. Ignoring all PostWorldSave events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
World::getEventPostWorldSave().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
World::getEventPostWorldSave().setEnabled(true);
Return value
Event reference.static Event<const char *> getEventPreWorldSave() const#
Usage Example
// implement the PreWorldSave event handler
void preworldsave_event_handler(const char * world_file_path)
{
Log::message("\Handling PreWorldSave event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections preworldsave_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
World::getEventPreWorldSave().connect(preworldsave_event_connections, preworldsave_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
World::getEventPreWorldSave().connect(preworldsave_event_connections, [](const char * world_file_path) {
Log::message("\Handling PreWorldSave event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
preworldsave_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection preworldsave_event_connection;
// subscribe to the PreWorldSave event with a handler function keeping the connection
World::getEventPreWorldSave().connect(preworldsave_event_connection, preworldsave_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
preworldsave_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
preworldsave_event_connection.setEnabled(true);
// ...
// remove subscription to the PreWorldSave event via the connection
preworldsave_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A PreWorldSave event handler implemented as a class member
void event_handler(const char * world_file_path)
{
Log::message("\Handling PreWorldSave event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
World::getEventPreWorldSave().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. Subscribe to an event saving a particular connection ID
// and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// instance of the EventConnections class to manage event connections
EventConnections e_connections;
// define a particular connection ID to be used to unsubscribe later
EventConnectionId preworldsave_handler_id;
// subscribe to the PreWorldSave event with a lambda handler function and keeping connection ID
preworldsave_handler_id = World::getEventPreWorldSave().connect(e_connections, [](const char * world_file_path) {
Log::message("\Handling PreWorldSave event (lambda).\n");
}
);
// remove the subscription later using the ID
World::getEventPreWorldSave().disconnect(preworldsave_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 5. Ignoring all PreWorldSave events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
World::getEventPreWorldSave().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
World::getEventPreWorldSave().setEnabled(true);
Return value
Event reference.static Event<const char *> getEventPostWorldLoad() const#
Usage Example
// implement the PostWorldLoad event handler
void postworldload_event_handler(const char * world_file_path)
{
Log::message("\Handling PostWorldLoad event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections postworldload_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
World::getEventPostWorldLoad().connect(postworldload_event_connections, postworldload_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
World::getEventPostWorldLoad().connect(postworldload_event_connections, [](const char * world_file_path) {
Log::message("\Handling PostWorldLoad event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
postworldload_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection postworldload_event_connection;
// subscribe to the PostWorldLoad event with a handler function keeping the connection
World::getEventPostWorldLoad().connect(postworldload_event_connection, postworldload_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
postworldload_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
postworldload_event_connection.setEnabled(true);
// ...
// remove subscription to the PostWorldLoad event via the connection
postworldload_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A PostWorldLoad event handler implemented as a class member
void event_handler(const char * world_file_path)
{
Log::message("\Handling PostWorldLoad event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
World::getEventPostWorldLoad().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. Subscribe to an event saving a particular connection ID
// and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// instance of the EventConnections class to manage event connections
EventConnections e_connections;
// define a particular connection ID to be used to unsubscribe later
EventConnectionId postworldload_handler_id;
// subscribe to the PostWorldLoad event with a lambda handler function and keeping connection ID
postworldload_handler_id = World::getEventPostWorldLoad().connect(e_connections, [](const char * world_file_path) {
Log::message("\Handling PostWorldLoad event (lambda).\n");
}
);
// remove the subscription later using the ID
World::getEventPostWorldLoad().disconnect(postworldload_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 5. Ignoring all PostWorldLoad events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
World::getEventPostWorldLoad().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
World::getEventPostWorldLoad().setEnabled(true);
Return value
Event reference.static Event<const char *> getEventPreWorldLoad() const#
Usage Example
// implement the PreWorldLoad event handler
void preworldload_event_handler(const char * world_file_path)
{
Log::message("\Handling PreWorldLoad event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an instance of the EventConnections
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections preworldload_event_connections;
// link to this instance when subscribing to an event (subscription to various events can be linked)
World::getEventPreWorldLoad().connect(preworldload_event_connections, preworldload_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
World::getEventPreWorldLoad().connect(preworldload_event_connections, [](const char * world_file_path) {
Log::message("\Handling PreWorldLoad event (lambda).\n");
}
);
// ...
// later all of these linked subscriptions can be removed with a single line
preworldload_event_connections.disconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via an instance of the EventConnection
// class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnection class
EventConnection preworldload_event_connection;
// subscribe to the PreWorldLoad event with a handler function keeping the connection
World::getEventPreWorldLoad().connect(preworldload_event_connection, preworldload_event_handler);
// ...
// you can temporarily disable a particular event connection to perform certain actions
preworldload_event_connection.setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
preworldload_event_connection.setEnabled(true);
// ...
// remove subscription to the PreWorldLoad event via the connection
preworldload_event_connection.disconnect();
//////////////////////////////////////////////////////////////////////////////
// 3. You can add EventConnection/EventConnections instance as a member of the
// class that handles the event. In this case all linked subscriptions will be
// automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////
// Class handling the event
class SomeClass
{
public:
// instance of the EventConnections class as a class member
EventConnections e_connections;
// A PreWorldLoad event handler implemented as a class member
void event_handler(const char * world_file_path)
{
Log::message("\Handling PreWorldLoad event\n");
// ...
}
};
SomeClass *sc = new SomeClass();
// ...
// specify a class instance in case a handler method belongs to some class
World::getEventPreWorldLoad().connect(sc->e_connections, sc, &SomeClass::event_handler);
// ...
// handler class instance is deleted with all its subscriptions removed automatically
delete sc;
//////////////////////////////////////////////////////////////////////////////
// 4. Subscribe to an event saving a particular connection ID
// and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// instance of the EventConnections class to manage event connections
EventConnections e_connections;
// define a particular connection ID to be used to unsubscribe later
EventConnectionId preworldload_handler_id;
// subscribe to the PreWorldLoad event with a lambda handler function and keeping connection ID
preworldload_handler_id = World::getEventPreWorldLoad().connect(e_connections, [](const char * world_file_path) {
Log::message("\Handling PreWorldLoad event (lambda).\n");
}
);
// remove the subscription later using the ID
World::getEventPreWorldLoad().disconnect(preworldload_handler_id);
//////////////////////////////////////////////////////////////////////////////
// 5. Ignoring all PreWorldLoad events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
World::getEventPreWorldLoad().setEnabled(false);
// ... actions to be performed
// and enable it back when necessary
World::getEventPreWorldLoad().setEnabled(true);
Return value
Event reference.bool getCollision ( const Math::WorldBoundBox & bb, Vector<Ptr<Object>> & OUT_objects ) #
Searches for all collider objects within a given bounding box.Arguments
- const Math::WorldBoundBox & bb - Bounding box.
- Vector<Ptr<Object>> & OUT_objects - Array with collider objects' smart pointers.This output buffer is to be filled by the Engine as a result of executing the method.
Return value
1 if collider objects are found; otherwise, 0.bool getCollision ( const Math::WorldBoundSphere & bs, Vector<Ptr<Object>> & OUT_objects ) #
Searches for all collider objects within a given bounding sphere.Arguments
- const Math::WorldBoundSphere & bs - Bounding sphere.
- Vector<Ptr<Object>> & OUT_objects - Array with collider objects' smart pointers.This output buffer is to be filled by the Engine as a result of executing the method.
Return value
1 if collider objects are found; otherwise, 0.bool getCollision ( const Math::WorldBoundFrustum & bf, Vector<Ptr<Object>> & OUT_objects ) #
Searches for all collider objects within a given bounding frustum.Arguments
- const Math::WorldBoundFrustum & bf - Bounding frustum.
- Vector<Ptr<Object>> & OUT_objects - Array with collider objects' smart pointers.This output buffer is to be filled by the Engine as a result of executing the method.
Return value
1 if collider objects are found; otherwise, 0.bool getCollision ( const Math::Vec3 & p0, const Math::Vec3 & p1, Vector<Ptr<Object>> & OUT_objects ) #
Performs tracing from the p0 point to the p1 point to find all collider objects intersected by the line. This function detects intersection with surfaces (polygons) of mesh and terrain objects.
Collisions with the surface can be found only if the following conditions are fulfilled:
- The surface is enabled.
- Per-surface Collision flag is enabled.
- The surface has a material assigned.
Arguments
- const Math::Vec3 & p0 - The start point coordinates.
- const Math::Vec3 & p1 - The end point coordinates.
- Vector<Ptr<Object>> & OUT_objects - Array with collider objects' smart pointers.This output buffer is to be filled by the Engine as a result of executing the method.
Return value
1 if collider objects are found; otherwise, 0.void setData ( const char * name, const char * data ) #
Sets user data associated with the world with the specified key. In the *.world file, the data is set in the data tag with the specified key.Arguments
- const char * name - String containing a key identifying user data to be stored in the *.world file.
The "editor_data" key is reserved for the UnigineEditor.
- const char * data - New user data.
const char * getData ( const char * name ) #
Returns user string data associated with the world by the specified key. This string is written directly into the data tag of the *.world file with the specified key.Arguments
- const char * name - String containing a key identifying user data stored in the *.world file.
The "editor_data" key is reserved for the UnigineEditor.
Return value
User string data.Ptr<Object> getIntersection ( const Math::Vec3 & p0, const Math::Vec3 & p1, int mask ) #
Performs tracing from the p0 point to the p1 point to find the first object intersected by the line. This function detects intersection with surfaces (polygons) of meshes. An intersection can be found only if an object has a matching intersection mask.
Intersections with the surface can be found only if the following conditions are fulfilled:
- The surface is enabled.
- Per-surface Intersection flag is enabled.
- The surface has a material assigned.
Arguments
- const Math::Vec3 & p0 - Line start point coordinates.
- const Math::Vec3 & p1 - Line end point coordinates.
- int mask - Intersection mask. If 0 is passed, the function will return NULL.
Return value
Pointer to the first intersected object.Ptr<Object> getIntersection ( const Math::Vec3 & p0, const Math::Vec3 & p1, int mask, const Vector<Ptr<Node>> & exclude ) #
Performs tracing from the p0 point to the p1 point to find the first object intersected by the line (except for the ones passed in the exclude list). This function detects intersection with surfaces (polygons) of meshes. An intersection can be found only if an object has a matching intersection mask.
Intersections with the surface can be found only if the following conditions are fulfilled:
- The surface is enabled.
- Per-surface Intersection flag is enabled.
- The surface has a material assigned.
Arguments
- const Math::Vec3 & p0 - Line start point coordinates.
- const Math::Vec3 & p1 - Line end point coordinates.
- int mask - Intersection mask. If 0 is passed, the function will return NULL.
- const Vector<Ptr<Node>> & exclude - List of nodes to be ignored when searching for intersection by the traced line.
Return value
The first intersected object found at the line (except for the ones passed in the exclude list); otherwise, NULL pointer.Ptr<Object> getIntersection ( const Math::Vec3 & p0, const Math::Vec3 & p1, int mask, const Ptr<WorldIntersection> & intersection ) #
Performs tracing from the p0 point to the p1 point to find the first object intersecting the line. This function detects intersection with surfaces (polygons) of meshes. An intersection can be found only if an object is matching the intersection mask.
Intersections with the surface can be found only if the following conditions are fulfilled:
- The surface is enabled.
- Per-surface Intersection flag is enabled.
- The surface has a material assigned.
Arguments
- const Math::Vec3 & p0 - Coordinates of the line start point.
- const Math::Vec3 & p1 - Coordinates of the line end point.
- int mask - Intersection mask. If 0 is passed, the function will return NULL.
- const Ptr<WorldIntersection> & intersection - Pointer to the WorldIntersection object to be filled.
Return value
Pointer to the first intersected object.Ptr<Object> getIntersection ( const Math::Vec3 & p0, const Math::Vec3 & p1, int mask, const Ptr<WorldIntersectionNormal> & intersection ) #
Performs tracing from the p0 point to the p1 point to find the first object intersecting the line. This function detects intersection with surfaces (polygons) of meshes. An intersection can be found only if an object is matching the intersection mask.
Intersections with the surface can be found only if the following conditions are fulfilled:
- The surface is enabled.
- Per-surface Intersection flag is enabled.
- The surface has a material assigned.
Arguments
- const Math::Vec3 & p0 - Coordinates of the line start point.
- const Math::Vec3 & p1 - Coordinates of the line end point.
- int mask - Intersection mask. If 0 is passed, the function will return NULL.
- const Ptr<WorldIntersectionNormal> & intersection - Pointer to the WorldIntersectionNormal object to be filled.
Return value
Pointer to the first intersected object.Ptr<Object> getIntersection ( const Math::Vec3 & p0, const Math::Vec3 & p1, int mask, const Ptr<WorldIntersectionTexCoord> & intersection ) #
Performs tracing from the p0 point to the p1 point to find the first object intersecting the line. This function detects intersection with surfaces (polygons) of meshes. An intersection can be found only if an object is matching the intersection mask.
Intersections with the surface can be found only if the following conditions are fulfilled:
- The surface is enabled.
- Per-surface Intersection flag is enabled.
- The surface has a material assigned.
Arguments
- const Math::Vec3 & p0 - Coordinates of the line start point.
- const Math::Vec3 & p1 - Coordinates of the line end point.
- int mask - Intersection mask. If 0 is passed, the function will return NULL.
- const Ptr<WorldIntersectionTexCoord> & intersection - Pointer to the WorldIntersectionTexCoord object to be filled.
Return value
Pointer to the first intersected object.Ptr<Object> getIntersection ( const Math::Vec3 & p0, const Math::Vec3 & p1, int mask, const Vector<Ptr<Node>> & exclude, const Ptr<WorldIntersection> & intersection ) #
Performs tracing from the p0 point to the p1 point to find the first object intersecting the line. This function detects intersection with surfaces (polygons) of meshes. An intersection can be found only if an object is matching the intersection mask.
Intersections with the surface can be found only if the following conditions are fulfilled:
- The surface is enabled.
- Per-surface Intersection flag is enabled.
- The surface has a material assigned.
Arguments
- const Math::Vec3 & p0 - Coordinates of the line start point.
- const Math::Vec3 & p1 - Coordinates of the line end point.
- int mask - Intersection mask. If 0 is passed, the function will return NULL.
- const Vector<Ptr<Node>> & exclude - The list of nodes to be excluded.
- const Ptr<WorldIntersection> & intersection - Pointer to the WorldIntersection object to be filled.
Return value
Pointer to the first intersected object.Ptr<Object> getIntersection ( const Math::Vec3 & p0, const Math::Vec3 & p1, int mask, const Vector<Ptr<Node>> & exclude, const Ptr<WorldIntersectionNormal> & intersection ) #
Performs tracing from the p0 point to the p1 point to find the first object intersecting the line. This function detects intersection with surfaces (polygons) of meshes. An intersection can be found only if an object is matching the intersection mask.
Intersections with the surface can be found only if the following conditions are fulfilled:
- The surface is enabled.
- Per-surface Intersection flag is enabled.
- The surface has a material assigned.
Arguments
- const Math::Vec3 & p0 - Coordinates of the line start point.
- const Math::Vec3 & p1 - Coordinates of the line end point.
- int mask - Intersection mask. If 0 is passed, the function will return NULL.
- const Vector<Ptr<Node>> & exclude - The list of nodes to be excluded.
- const Ptr<WorldIntersectionNormal> & intersection - Pointer to the WorldIntersectionNormal object to be filled.
Return value
Pointer to the first intersected object.Ptr<Object> getIntersection ( const Math::Vec3 & p0, const Math::Vec3 & p1, int mask, const Vector<Ptr<Node>> & exclude, const Ptr<WorldIntersectionTexCoord> & intersection ) #
Performs tracing from the p0 point to the p1 point to find the first object intersected by the line. This function detects intersection with surfaces (polygons) of meshes. An intersection can be found only if an object is matching the intersection mask.
Intersections with the surface can be found only if the following conditions are fulfilled:
- The surface is enabled.
- Per-surface Intersection flag is enabled.
- The surface has a material assigned.
Arguments
- const Math::Vec3 & p0 - Coordinates of the line start point.
- const Math::Vec3 & p1 - Coordinates of the line end point.
- int mask - Intersection mask. If 0 is passed, the function will return NULL.
- const Vector<Ptr<Node>> & exclude - The list of nodes to be excluded.
- const Ptr<WorldIntersectionTexCoord> & intersection - Pointer to the WorldIntersectionTexCoord object to be filled.
Return value
Pointer to the first intersected object.bool getIntersection ( const Math::Vec3 & p0, const Math::Vec3 & p1, Vector<Ptr<Object>> & OUT_objects, bool check_surface_flags = true ) #
Performs tracing from the p0 point to the p1 point to find objects intersected by the line. This function detects intersection with objects' bounds.
Arguments
- const Math::Vec3 & p0 - Coordinates of the line start point.
- const Math::Vec3 & p1 - Coordinates of the line end point.
- Vector<Ptr<Object>> & OUT_objects - Array of intersected objects' smart pointers.This output buffer is to be filled by the Engine as a result of executing the method.
- bool check_surface_flags - true if surfaceIntersection flags are to be taken into account when checking for intersections with objects; otherwise, false. When set to true objects with surface Intersection flags disabled (default setting) will be ignored as non-intersectable.
Return value
true if intersections are found; otherwise, false.bool getIntersection ( const Math::WorldBoundBox & bb, Vector<Ptr<Object>> & OUT_objects ) #
Searches for intersections with objects that are found in a given bounding box.
Arguments
- const Math::WorldBoundBox & bb - Bounding box where intersection search will be performed.
- Vector<Ptr<Object>> & OUT_objects - Array of intersected objects' smart pointers.This output buffer is to be filled by the Engine as a result of executing the method.
Return value
true if intersections are found; otherwise, false.bool getIntersection ( const Math::WorldBoundBox & bb, Vector<Ptr<Node>> & OUT_nodes ) #
Searches for intersections with nodes that are found in a given bounding box.
Arguments
- const Math::WorldBoundBox & bb - Bounding box where intersection search will be performed.
- Vector<Ptr<Node>> & OUT_nodes - Array of intersected nodes' smart pointers.This output buffer is to be filled by the Engine as a result of executing the method.
Return value
true if intersections are found; otherwise, false.bool getIntersection ( const Math::WorldBoundBox & bb, Node::TYPE type, Vector<Ptr<Node>> & OUT_nodes ) #
Searches for intersections with specified type of nodes that are found in a given bounding box.
Arguments
- const Math::WorldBoundBox & bb - Bounding box where intersection search will be performed.
- Node::TYPE type - Node type filter. Only the nodes of the specified type will be checked.
- Vector<Ptr<Node>> & OUT_nodes - Array of intersected nodes' smart pointers.This output buffer is to be filled by the Engine as a result of executing the method.
Return value
true if intersections are found; otherwise, false.bool getIntersection ( const Math::WorldBoundSphere & bs, Vector<Ptr<Object>> & OUT_objects ) #
Searches for intersections with objects that are found in a given bounding sphere.
Arguments
- const Math::WorldBoundSphere & bs - Bounding sphere where intersection search will be performed.
- Vector<Ptr<Object>> & OUT_objects - Array of intersected objects' smart pointers.This output buffer is to be filled by the Engine as a result of executing the method.
Return value
true if intersections are found; otherwise, false.bool getIntersection ( const Math::WorldBoundSphere & bs, Vector<Ptr<Node>> & OUT_nodes ) #
Searches for intersections with nodes that are found in a given bounding sphere.
Arguments
- const Math::WorldBoundSphere & bs - Bounding sphere where intersection search will be performed.
- Vector<Ptr<Node>> & OUT_nodes - Array of intersected nodes' smart pointers.This output buffer is to be filled by the Engine as a result of executing the method.
Return value
true if intersections are found; otherwise, false.bool getIntersection ( const Math::WorldBoundSphere & bs, Node::TYPE type, Vector<Ptr<Node>> & OUT_nodes ) #
Searches for intersections with nodes of the specified type that are found in a given bounding sphere.
Arguments
- const Math::WorldBoundSphere & bs - Bounding sphere where intersection search will be performed.
- Node::TYPE type - Node type filter. Only the nodes of the specified type will be checked.
- Vector<Ptr<Node>> & OUT_nodes - Array of intersected nodes' smart pointers.This output buffer is to be filled by the Engine as a result of executing the method.
Return value
true if intersections are found; otherwise, false.bool getIntersection ( const Math::WorldBoundFrustum & bf, Vector<Ptr<Object>> & OUT_objects ) #
Searches for intersections with Objects that are found in a given bounding frustum. This method catches all objects independent of their visibility (i.e., if an object is disabled, any of its LODs are disabled, or it is out of the visibility distance range, but is located within the bounding frustum, the intersection shall be detected). To check for intersections while taking into account the visibility aspect, use getVisibleIntersection(). Check the usage example applying this method.
Arguments
- const Math::WorldBoundFrustum & bf - Bounding frustum where intersection search will be performed.
- Vector<Ptr<Object>> & OUT_objects - Array of intersected objects' smart pointers.This output buffer is to be filled by the Engine as a result of executing the method.
Return value
true if intersections are found; otherwise, false.bool getIntersection ( const Math::WorldBoundFrustum & bf, Node::TYPE type, Vector<Ptr<Node>> & OUT_nodes ) #
Searches for intersections with nodes of the specified type that are found in a given bounding frustum. This method catches all nodes of the specified type independent of their visibility (i.e., if an object is disabled, any of its LODs are disabled, or it is out of the visibility distance range, but is located within the bounding frustum, the intersection shall be detected). To check for intersections while taking into account the visibility aspect, use getVisibleIntersection().
Arguments
- const Math::WorldBoundFrustum & bf - Bounding frustum where intersection search will be performed.
- Node::TYPE type - Node type filter. Only the nodes of the specified type will be checked.
- Vector<Ptr<Node>> & OUT_nodes - Array of intersected nodes' smart pointers.This output buffer is to be filled by the Engine as a result of executing the method.
Return value
true if intersections are found; otherwise, false.bool getIntersection ( const Math::WorldBoundFrustum & bf, Vector<Ptr<Node>> & OUT_nodes ) #
Searches for intersections with nodes of the specified type that are found in a given bounding frustum. This method catches all nodes independent of their visibility (i.e., if an object is disabled, any of its LODs are disabled, or it is out of the visibility distance range, but is located within the bounding frustum, the intersection shall be detected). To check for intersections while taking into account the visibility aspect, use getVisibleIntersection().
Arguments
- const Math::WorldBoundFrustum & bf - Bounding frustum where intersection search will be performed.
- Vector<Ptr<Node>> & OUT_nodes - Array of intersected nodes' smart pointers.This output buffer is to be filled by the Engine as a result of executing the method.
Return value
true if intersections are found; otherwise, false.bool getVisibleIntersection ( const Math::Vec3 & camera, const Math::WorldBoundFrustum & bf, Vector<Ptr<Object>> & OUT_objects, float max_distance ) #
Searches for intersections with objects inside a given bounding frustum that are visible to the specified camera position, i.e. either of its LODs is within the visibility distance distance. Unlike the getIntersection()method, this one takes the "visibility" concept into account (hidden objects or the ones that are too far away won't be found). Check this usage example for more details.Arguments
- const Math::Vec3 & camera - Position of the camera from which the visibility distance to objects is checked.
- const Math::WorldBoundFrustum & bf - Bounding frustum inside which intersection search is performed.
- Vector<Ptr<Object>> & OUT_objects - Array of intersected objects.This output buffer is to be filled by the Engine as a result of executing the method.
- float max_distance - Maximum visibility distance for objects, in units. If the distance from the specified camera position to an object exceeds this limit, the intersection is not registered even if the node is within the specified bounding frustum.
Return value
true if at least one intersection is found; otherwise, false.bool getVisibleIntersection ( const Math::Vec3 & camera, const Math::WorldBoundFrustum & bf, Node::TYPE type, Vector<Ptr<Node>> & OUT_nodes, float max_distance ) #
Searches for intersections with nodes inside a given bounding frustum that are visible to the specified camera position, i.e. either of its LODs is within the visibility distance distance. Unlike the getIntersection()method, this one takes the "visibility" concept into account (hidden nodes or the ones that are too far away won't be found). Check this usage example for more details.
Arguments
- const Math::Vec3 & camera - Position of the camera from which the visibility distance to nodes is checked.
- const Math::WorldBoundFrustum & bf - Bounding frustum inside which intersection search is performed.
- Node::TYPE type - Node type (one of the NODE_* variables); set it to -1 if you won't use this filter.
- Vector<Ptr<Node>> & OUT_nodes - Array of intersected nodes.This output buffer is to be filled by the Engine as a result of executing the method.
- float max_distance - Maximum visibility distance for nodes, in units. If the distance from the specified camera position to a node exceeds this limit, the intersection is not registered even if the node is within the specified bounding frustum.
Return value
true if at least one intersection is found; otherwise, false.bool loadWorld ( const char * path ) #
Loads a world from the specified file path and replaces the current world with it. The world is not loaded immediately — loading starts at the beginning of the next frame, while the current world is unloaded at the end of the current frame.Arguments
- const char * path - Path to the file describing the world.
Return value
true if the world is loaded successfully; otherwise, false.bool loadWorld ( const char * path, bool partial_path ) #
Loads a world from the specified file path and replaces the current world with it. The world is not loaded immediately — loading starts at the beginning of the next frame, while the current world is unloaded at the end of the current frame.Arguments
- const char * path - Path to the file describing the world.
- bool partial_path - true if the path to the world file is partial; or false if it is a full path.
Return value
true if the world is loaded successfully; otherwise, false.bool loadWorldForce ( const char * path ) #
Loads a world from the specified file path and replaces the current world with it. The world is loaded immediately, breaking the Execution Sequence, therefore should be used either before Engine::update() or after Engine::swap(). If called in Engine::update(), the Execution Sequence will be as follows: update() before calling loadWorldForce(), loadWorldForce(), shutdown(), continuation of update() from the place of interruption, postUpdate(), swap(), init(), etc. This function is recommended for the Editor-related use.Arguments
- const char * path - Path to the file describing the world.
Return value
true if the world is loaded successfully; otherwise, false.bool loadWorldForce ( const char * path, bool partial_path ) #
Loads a world from the specified file path and replaces the current world with it. The world is loaded immediately, breaking the Execution Sequence, therefore should be used either before Engine::update() or after Engine::swap(). If called in Engine::update(), the Execution Sequence will be as follows: update() before calling loadWorldForce(), loadWorldForce(), shutdown(), continuation of update() from the place of interruption, postUpdate(), swap(), init(), etc. This function is recommended for the Editor-related use.Arguments
- const char * path - Path to the file describing the world.
- bool partial_path - true if the path to the world file is partial; or false if it is a full path.
Return value
true if the world is loaded successfully; otherwise, false.bool saveWorld ( ) #
Saves the World.Return value
true, if the world has been saved successfully; otherwise false.bool saveWorld ( const char * path ) #
Saves the world to the specified location.Arguments
- const char * path - Path to where the world is going to be saved.
Return value
true, if the world has been saved successfully; otherwise false.bool reloadWorld ( ) #
Reloads the World.Return value
true, if the world has been reloaded successfully; otherwise false.bool quitWorld ( ) #
Closes the World.Return value
true, if the world has been quit successfully; otherwise false.bool addWorld ( const char * name ) #
Loads a world from a file and adds it to the current World.Arguments
- const char * name - Name of the file describing the world.
Return value
1 if the world is loaded and added successfully; otherwise, 0.bool isNode ( int id ) const#
Checks if a node with a given ID exists in the World.Arguments
- int id - Node ID.
Return value
true if the node with the given ID exists; otherwise, false.void getNodes ( Vector<Ptr<Node>> & OUT_nodes ) const#
Collects all instances of all nodes (either loaded from the *.world file or created dynamically at run time), including cache, Node Reference internals, etc. and puts them to the specified output list.Arguments
- Vector<Ptr<Node>> & OUT_nodes - Array with node smart pointers.This output buffer is to be filled by the Engine as a result of executing the method.
bool clearNode ( const char * name ) const#
Clears cached nodes of the given node file.When the node is cached and you try to access it, take into account the following:
- if the node was loaded by the name — the node gets stored in the cache by its name;
- if the node was loaded from the parent node reference — the node is stored in the cache by its GUID.
NodePtr node = World::loadNode(file_name);
// change something in the node...
World::saveNode(file_name, node);
// clear cache by the name
World::clearNode(file_name);
// clear cache by the GUID (if this node is inside another node reference)
World::clearNode(FileSystem::getGUID(file_name).getFileSystemString());
// reload the node
node->deleteForce();
node = World::loadNode(file_name);
Arguments
- const char * name - Path to the *.node file.
Return value
1 if the cache is cleared successfully; otherwise, 0.Ptr<Node> loadNode ( const char * name, int cache = 1 ) #
Loads a node (or a hierarchy of nodes) from a .node / .fbx file. If the node is loaded successfully, it is managed by the current world (its Lifetime is World).Cached nodes remain in the memory. If you don't intend to load more node references from a certain .node asset, set the cache argument to 0 or you can delete cached nodes from the list of world nodes afterwards by using the clearNode() method.
Arguments
- const char * name - Path to the *.node file.
- int cache - 1 to use caching of nodes, 0 not to use.
Return value
Loaded node; NULL if the node cannot be loaded.int loadNodes ( const char * name, Vector<Ptr<Node>> & OUT_nodes ) const#
Loads nodes from a file.Arguments
- const char * name - Path to the *.node file.
- Vector<Ptr<Node>> & OUT_nodes - Array of nodes' smart pointers to which the loaded nodes are appended.This output buffer is to be filled by the Engine as a result of executing the method.
Return value
1 if the nodes are loaded successfully; otherwise, 0.bool saveNode ( const char * name, const Ptr<Node> & node, int binary = 0 ) #
Saves a given node to a file with due regard for its local transformation.Arguments
- const char * name - Path to the *.node file.
- const Ptr<Node> & node - Pointer to the node to save.
- int binary - If set to 1, the node is saved to the binary *.xml. This file cannot be read, but using it speeds up the saving of the node and requires less disk space.
Return value
1 if the node is saved successfully; otherwise, 0.int saveNodes ( const char * name, const Vector<Ptr<Node>> & nodes, int binary = 0 ) const#
Saves nodes to a file.Arguments
- const char * name - Path to the *.node file.
- const Vector<Ptr<Node>> & nodes - Array of nodes' smart pointers to be saved.
- int binary - If set to 1, the node is saved to the binary *.xml. This file cannot be read, but using it speeds up the saving of the node and requires less disk space.
Return value
1 if the nodes are saved successfully; otherwise, 0.void updateSpatial ( ) #
Updates the node BSP (binary space partitioning) tree.
The engine calls this method automatically each frame after the world script update() code is executed. As a new node becomes a part of the BSP tree only after this method is called, all engine subsystems (renderer, physics, sound, pathfinding, collisions, intersections, etc.) can process this node only in the next frame. If you need the subsystem to process the node in the very first frame, you can call the updateSpatial() method manually. The engine will call this method automatically after the update() code is executed anyways.
Ptr<Node> getNodeByID ( int node_id ) const#
Returns a node by its identifier if it exists.Arguments
- int node_id - Node ID.
Return value
Node, if it exists in the world; otherwise, nullptr.Ptr<Node> getNodeByName ( const char * name ) const#
Returns a node by its name if it exists. If the world contains multiple nodes having the same name, only the first one found shall be returned. To get all nodes having the same name, use the getNodesByName() method.Arguments
- const char * name - Node name.
Return value
Node, if it exists in the world; otherwise, nullptr.void getNodesByName ( const char * name, Vector<Ptr<Node>> & OUT_nodes ) const#
Generates a list of nodes in the world with a given name and puts it to nodes.Arguments
- const char * name - Node name.
- Vector<Ptr<Node>> & OUT_nodes - List of nodes with the given name (if any); otherwise, nullptr.This output buffer is to be filled by the Engine as a result of executing the method.
Ptr<Node> getNodeByType ( int type ) const#
Returns the first node of the specified type in the World. Hidden and system nodes are ignored.Arguments
- int type - Node type identifier, one of the NODE_* values.
Return value
First node of the specified type, if it exists in the world; otherwise, nullptr.void getNodesByType ( int type, Vector<Ptr<Node>> & OUT_nodes ) const#
Generates a list of nodes of the specified type in the world and puts it to nodes. Hidden and system nodes are ignored.Arguments
- int type - Node type identifier, one of the NODE_* values.
- Vector<Ptr<Node>> & OUT_nodes - List of nodes of the given type (if any); otherwise, nullptr.This output buffer is to be filled by the Engine as a result of executing the method.
bool isNode ( const char * name ) const#
Checks if a node with a given name exists in the World.Arguments
- const char * name - Node name.
Return value
true if a node with the specified name exists in the world; otherwise, false.void clearBindings ( ) #
Clears internal buffers with pointers and instances. This function is used for proper cloning of objects with hierarchies, for example, bodies and joints. Should be called before cloning.void getRootNodes ( Vector<Ptr<Node>> & OUT_nodes ) #
Gets all root nodes in the world hierarchy and puts them to nodes. Doesn't include cached nodes.Arguments
- Vector<Ptr<Node>> & OUT_nodes - Vector, to which all root nodes of the world hierarchy are to be put.This output buffer is to be filled by the Engine as a result of executing the method.
int getRootNodeIndex ( const Ptr<Node> & node ) const#
Returns the index for the specified root node, that belongs to the world hierarchy.Arguments
Return value
Index of the specified root node if it exists; otherwise, -1.void setRootNodeIndex ( const Ptr<Node> & node, int index ) #
Sets a new index for the specified root node, that belongs to the world hierarchy.Arguments
- const Ptr<Node> & node - Root node, for which a new index is to be set.
- int index - New index to be set for the specified root node.
void setNodeIdSeed ( unsigned int seed ) #
Sets a seed value for random generation of a node ID. This method is used for deterministic generation.Arguments
- unsigned int seed - A seed value.
void setNodeIdRange ( int from, int to ) #
Sets a range for random generation of a node ID. This method can be used, for example, to generate IDs for nodes divided in several groups: within a group, IDs will be generated in a separate range.Arguments
- int from - Beginning of the range.
- int to - End of the range.