This page has been translated automatically.
Видеоуроки
Интерфейс
Основы
Продвинутый уровень
Подсказки и советы
Основы
Программирование на C#
Рендеринг
Профессиональный уровень (SIM)
Принципы работы
Свойства (properties)
Компонентная Система
Рендер
Физика
Редактор UnigineEditor
Обзор интерфейса
Работа с ассетами
Контроль версий
Настройки и предпочтения
Работа с проектами
Настройка параметров ноды
Setting Up Materials
Настройка свойств
Освещение
Sandworm
Использование инструментов редактора для конкретных задач
Расширение функционала редактора
Встроенные объекты
Ноды (Nodes)
Объекты (Objects)
Эффекты
Декали
Источники света
Geodetics
World-ноды
Звуковые объекты
Объекты поиска пути
Player-ноды
Программирование
Основы
Настройка среды разработки
Примеры использования
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Плагины
Форматы файлов
Материалы и шейдеры
Rebuilding the Engine Tools
Интерфейс пользователя (GUI)
VR Development
Двойная точность координат
API
Animations-Related Classes
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
VR-Related Classes
Работа с контентом
Оптимизация контента
Материалы
Визуальный редактор материалов
Сэмплы материалов
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Учебные материалы

Unigine::WorldSplineGraph Class

Header: #include <UnigineWorlds.h>
Inherits from: Node
Warning
This feature is an experimental one and is not recommended for production use.

This class is used to generate specified nodes (called source nodes) along a spline graph.

UNIGINE's 3D spline system has a wide range of applications, particularly procedural content generation (rivers, roads, pipelines etc.).

A spline graph is determined by a set of points p0, p 1, ... p n and a set of segments (cubic Bezier splines), that connect some or all of these points.

Each segment is determined by the indices of the starting (pSTART ) and ending (pEND ) points and tangent vector coordinates at these points, which determine the form of the segment (tSTART and tEND respectively).

Coordinates of the "up" vector are additionally stored for each point of the segment. You can specify this vector to define orientation of geometry or objects, that can be stretched or tiled along the segments of the spline graph. By default this vector is parallel to the Z axis. The "up" vector does not affect the form of the spline segment.

It is possible to obtain an interpolated value for any point belonging to a segment, this can be used for various purposes (e.g. to change road profile). Interpolated "up" vector can be calculated as follows (pseudocode):

Source code (C++)
vec3 lerpUpVector(vec3 start_up, vec3 end_up, float t) const
{
	float angle = acos(dot(start_up, end_up)) * RAD2DEG;
	vec3 rotation_axis = cross(start_up, end_up);

	return rotateAxisAngle(rotation_axis, angle * t) * start_up;
}

A world spline graph consists of segments and has a list of source nodes (currently ObjectMeshStatic, ObjectMeshSkinned, and DecalProj) that can be placed at points and along the segments of the spline graph. Each point and segment can have a single or a set of source nodes assigned. An arbitrary number of WorldSplineGraph nodes can be added to the scene.

WorldSplineGraph has the following features:

  • Points of the spline graph are managed via the SplinePoint class.
  • Segments of the spline graph are managed via the SplineSegment class.
  • 3 modes are supported:
    • stretching: source nodes are stretched along the spline segment.
    • tiling: source nodes are duplicated along the spline segment.
    • adaptive - represents a combination of the first two: source nodes are duplicated along the spline segment, but the length of each node (stretching) is determined by the curvature of the corresponding part of the segment. Thus, long nodes are placed along the straight parts of segments, while short ones - along the curved parts, providing a reasonable balance between the plausible look and performance.
  • Forward axis selection for stretching/tiling source nodes.

See Also#

See the article on the World Spline Graph object.

See the following UnigineScript API samples to learn how to manage the WorldSplineGraph class:

<UnigineSDK>/data/samples/worlds/world_spline_graph_00 featuring:

  • Creation of a WorldSplineGraph node from a SplineGraph file
  • Generation of geometry along the graph segments in stretching mode

<UnigineSDK>/data/samples/worlds/world_spline_graph_01 featuring:

  • Creation of a WorldSplineGraph node from a SplineGraph file
  • Generation of geometry along the graph segments in tiling mode

The C++ API sample <UnigineSDK>/source/samples/Api/Nodes/SplineGraph

WorldSplineGraph Class

Members

getNumSplineSegments() const#

Returns the current total number of spline segments in the world spline graph.

Return value

Current

getNumSplinePoints() const#

Returns the current total number of spline points in the world spline graph.

Return value

Current

isCurved() const#

Returns the current value indicating if the world spline graph is curved.

Return value

Current

Event<const Ptr<WorldSplineGraph> &> getEventRebuildingFinished() const#

event triggered after the world spline graph is rebuilt. The world spline graph uses a deferred rebuild. You can subscribe to events via connect()  and unsubscribe via disconnect(). You can also use EventConnection  and EventConnections  classes for convenience (see examples below).

Usage Example

Source code (C++)
// implement the RebuildingFinished event handler
void rebuildingfinished_event_handler(const Ptr<WorldSplineGraph> & spline_graph)
{
	Log::message("\Handling RebuildingFinished 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 rebuildingfinished_event_connections;

// link to this instance when subscribing for an event (subscription for various events can be linked)
worldsplinegraph->getEventRebuildingFinished().connect(rebuildingfinished_event_connections, rebuildingfinished_event_handler);

// other subscriptions are also linked to this EventConnections instance 
// (e.g. you can subscribe using lambdas)
worldsplinegraph->getEventRebuildingFinished().connect(rebuildingfinished_event_connections, [](const Ptr<WorldSplineGraph> & spline_graph) { 
		Log::message("\Handling RebuildingFinished event (lambda).\n");
	}
);

// ...

// later all of these linked subscriptions can be removed with a single line
rebuildingfinished_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 rebuildingfinished_event_connection;

// subscribe for the RebuildingFinished event with a handler function keeping the connection
worldsplinegraph->getEventRebuildingFinished().connect(rebuildingfinished_event_connection, rebuildingfinished_event_handler);

// ...

// you can temporarily disable a particular event connection to perform certain actions
rebuildingfinished_event_connection.setEnabled(false);

// ... actions to be performed

// and enable it back when necessary
rebuildingfinished_event_connection.setEnabled(true);

// ...

// remove subscription for the RebuildingFinished event via the connection
rebuildingfinished_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 RebuildingFinished event handler implemented as a class member
	void event_handler(const Ptr<WorldSplineGraph> & spline_graph)
	{
		Log::message("\Handling RebuildingFinished event\n");
		// ...
	}
};

SomeClass *sc = new SomeClass();

// ...

// specify a class instance in case a handler method belongs to some class
worldsplinegraph->getEventRebuildingFinished().connect(sc->e_connections, sc, &SomeClass::event_handler);

// ...

// handler class instance is deleted with all its subscriptions removed automatically
delete sc;

//////////////////////////////////////////////////////////////////////////////
//  4. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////

// subscribe for the RebuildingFinished event with a handler function
worldsplinegraph->getEventRebuildingFinished().connect(rebuildingfinished_event_handler);


// remove subscription for the RebuildingFinished event later by the handler function
worldsplinegraph->getEventRebuildingFinished().disconnect(rebuildingfinished_event_handler);


//////////////////////////////////////////////////////////////////////////////
//   5. Subscribe to an event saving an ID and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////

// define a connection ID to be used to unsubscribe later
EventConnectionId rebuildingfinished_handler_id;

// subscribe for the RebuildingFinished event with a lambda handler function and keeping connection ID
rebuildingfinished_handler_id = worldsplinegraph->getEventRebuildingFinished().connect([](const Ptr<WorldSplineGraph> & spline_graph) { 
		Log::message("\Handling RebuildingFinished event (lambda).\n");
	}
);

// remove the subscription later using the ID
worldsplinegraph->getEventRebuildingFinished().disconnect(rebuildingfinished_handler_id);


//////////////////////////////////////////////////////////////////////////////
//   6. Ignoring all RebuildingFinished events when necessary
//////////////////////////////////////////////////////////////////////////////

// you can temporarily disable the event to perform certain actions without triggering it
worldsplinegraph->getEventRebuildingFinished().setEnabled(false);

// ... actions to be performed

// and enable it back when necessary
worldsplinegraph->getEventRebuildingFinished().setEnabled(true);
Notice
For more details see the Event Handling article.
The event handler signature is as follows: myhandler(const Ptr<WorldSplineGraph> & spline_graph)

Return value

Current

Event<const Ptr<WorldSplineGraph> &, const Ptr<SplineSegment> &> getEventSegmentRemoved() const#

event triggered when a segment of the world spline graph is removed. You can subscribe to events via connect()  and unsubscribe via disconnect(). You can also use EventConnection  and EventConnections  classes for convenience (see examples below).

Usage Example

Source code (C++)
// implement the SegmentRemoved event handler
void segmentremoved_event_handler(const Ptr<WorldSplineGraph> & spline_graph,  const Ptr<SplineSegment> & segment)
{
	Log::message("\Handling SegmentRemoved 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 segmentremoved_event_connections;

// link to this instance when subscribing for an event (subscription for various events can be linked)
worldsplinegraph->getEventSegmentRemoved().connect(segmentremoved_event_connections, segmentremoved_event_handler);

// other subscriptions are also linked to this EventConnections instance 
// (e.g. you can subscribe using lambdas)
worldsplinegraph->getEventSegmentRemoved().connect(segmentremoved_event_connections, [](const Ptr<WorldSplineGraph> & spline_graph,  const Ptr<SplineSegment> & segment) { 
		Log::message("\Handling SegmentRemoved event (lambda).\n");
	}
);

// ...

// later all of these linked subscriptions can be removed with a single line
segmentremoved_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 segmentremoved_event_connection;

// subscribe for the SegmentRemoved event with a handler function keeping the connection
worldsplinegraph->getEventSegmentRemoved().connect(segmentremoved_event_connection, segmentremoved_event_handler);

// ...

// you can temporarily disable a particular event connection to perform certain actions
segmentremoved_event_connection.setEnabled(false);

// ... actions to be performed

// and enable it back when necessary
segmentremoved_event_connection.setEnabled(true);

// ...

// remove subscription for the SegmentRemoved event via the connection
segmentremoved_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 SegmentRemoved event handler implemented as a class member
	void event_handler(const Ptr<WorldSplineGraph> & spline_graph,  const Ptr<SplineSegment> & segment)
	{
		Log::message("\Handling SegmentRemoved event\n");
		// ...
	}
};

SomeClass *sc = new SomeClass();

// ...

// specify a class instance in case a handler method belongs to some class
worldsplinegraph->getEventSegmentRemoved().connect(sc->e_connections, sc, &SomeClass::event_handler);

// ...

// handler class instance is deleted with all its subscriptions removed automatically
delete sc;

//////////////////////////////////////////////////////////////////////////////
//  4. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////

// subscribe for the SegmentRemoved event with a handler function
worldsplinegraph->getEventSegmentRemoved().connect(segmentremoved_event_handler);


// remove subscription for the SegmentRemoved event later by the handler function
worldsplinegraph->getEventSegmentRemoved().disconnect(segmentremoved_event_handler);


//////////////////////////////////////////////////////////////////////////////
//   5. Subscribe to an event saving an ID and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////

// define a connection ID to be used to unsubscribe later
EventConnectionId segmentremoved_handler_id;

// subscribe for the SegmentRemoved event with a lambda handler function and keeping connection ID
segmentremoved_handler_id = worldsplinegraph->getEventSegmentRemoved().connect([](const Ptr<WorldSplineGraph> & spline_graph,  const Ptr<SplineSegment> & segment) { 
		Log::message("\Handling SegmentRemoved event (lambda).\n");
	}
);

// remove the subscription later using the ID
worldsplinegraph->getEventSegmentRemoved().disconnect(segmentremoved_handler_id);


//////////////////////////////////////////////////////////////////////////////
//   6. Ignoring all SegmentRemoved events when necessary
//////////////////////////////////////////////////////////////////////////////

// you can temporarily disable the event to perform certain actions without triggering it
worldsplinegraph->getEventSegmentRemoved().setEnabled(false);

// ... actions to be performed

// and enable it back when necessary
worldsplinegraph->getEventSegmentRemoved().setEnabled(true);
Notice
For more details see the Event Handling article.
The event handler signature is as follows: myhandler(const Ptr<WorldSplineGraph> & spline_graph, const Ptr<SplineSegment> & segment)

Return value

Current

Event<const Ptr<WorldSplineGraph> &, const Ptr<SplineSegment> &> getEventSegmentChanged() const#

event triggered when a segment of the world spline graph is modified. You can subscribe to events via connect()  and unsubscribe via disconnect(). You can also use EventConnection  and EventConnections  classes for convenience (see examples below).

Usage Example

Source code (C++)
// implement the SegmentChanged event handler
void segmentchanged_event_handler(const Ptr<WorldSplineGraph> & spline_graph,  const Ptr<SplineSegment> & segment)
{
	Log::message("\Handling SegmentChanged 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 segmentchanged_event_connections;

// link to this instance when subscribing for an event (subscription for various events can be linked)
worldsplinegraph->getEventSegmentChanged().connect(segmentchanged_event_connections, segmentchanged_event_handler);

// other subscriptions are also linked to this EventConnections instance 
// (e.g. you can subscribe using lambdas)
worldsplinegraph->getEventSegmentChanged().connect(segmentchanged_event_connections, [](const Ptr<WorldSplineGraph> & spline_graph,  const Ptr<SplineSegment> & segment) { 
		Log::message("\Handling SegmentChanged event (lambda).\n");
	}
);

// ...

// later all of these linked subscriptions can be removed with a single line
segmentchanged_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 segmentchanged_event_connection;

// subscribe for the SegmentChanged event with a handler function keeping the connection
worldsplinegraph->getEventSegmentChanged().connect(segmentchanged_event_connection, segmentchanged_event_handler);

// ...

// you can temporarily disable a particular event connection to perform certain actions
segmentchanged_event_connection.setEnabled(false);

// ... actions to be performed

// and enable it back when necessary
segmentchanged_event_connection.setEnabled(true);

// ...

// remove subscription for the SegmentChanged event via the connection
segmentchanged_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 SegmentChanged event handler implemented as a class member
	void event_handler(const Ptr<WorldSplineGraph> & spline_graph,  const Ptr<SplineSegment> & segment)
	{
		Log::message("\Handling SegmentChanged event\n");
		// ...
	}
};

SomeClass *sc = new SomeClass();

// ...

// specify a class instance in case a handler method belongs to some class
worldsplinegraph->getEventSegmentChanged().connect(sc->e_connections, sc, &SomeClass::event_handler);

// ...

// handler class instance is deleted with all its subscriptions removed automatically
delete sc;

//////////////////////////////////////////////////////////////////////////////
//  4. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////

// subscribe for the SegmentChanged event with a handler function
worldsplinegraph->getEventSegmentChanged().connect(segmentchanged_event_handler);


// remove subscription for the SegmentChanged event later by the handler function
worldsplinegraph->getEventSegmentChanged().disconnect(segmentchanged_event_handler);


//////////////////////////////////////////////////////////////////////////////
//   5. Subscribe to an event saving an ID and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////

// define a connection ID to be used to unsubscribe later
EventConnectionId segmentchanged_handler_id;

// subscribe for the SegmentChanged event with a lambda handler function and keeping connection ID
segmentchanged_handler_id = worldsplinegraph->getEventSegmentChanged().connect([](const Ptr<WorldSplineGraph> & spline_graph,  const Ptr<SplineSegment> & segment) { 
		Log::message("\Handling SegmentChanged event (lambda).\n");
	}
);

// remove the subscription later using the ID
worldsplinegraph->getEventSegmentChanged().disconnect(segmentchanged_handler_id);


//////////////////////////////////////////////////////////////////////////////
//   6. Ignoring all SegmentChanged events when necessary
//////////////////////////////////////////////////////////////////////////////

// you can temporarily disable the event to perform certain actions without triggering it
worldsplinegraph->getEventSegmentChanged().setEnabled(false);

// ... actions to be performed

// and enable it back when necessary
worldsplinegraph->getEventSegmentChanged().setEnabled(true);
Notice
For more details see the Event Handling article.
The event handler signature is as follows: myhandler(const Ptr<WorldSplineGraph> & spline_graph, const Ptr<SplineSegment> & segment)

Return value

Current

Event<const Ptr<WorldSplineGraph> &, const Ptr<SplineSegment> &> getEventSegmentAdded() const#

event triggered when a segment is added to the world spline graph. You can subscribe to events via connect()  and unsubscribe via disconnect(). You can also use EventConnection  and EventConnections  classes for convenience (see examples below).

Usage Example

Source code (C++)
// implement the SegmentAdded event handler
void segmentadded_event_handler(const Ptr<WorldSplineGraph> & spline_graph,  const Ptr<SplineSegment> & segment)
{
	Log::message("\Handling SegmentAdded 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 segmentadded_event_connections;

// link to this instance when subscribing for an event (subscription for various events can be linked)
worldsplinegraph->getEventSegmentAdded().connect(segmentadded_event_connections, segmentadded_event_handler);

// other subscriptions are also linked to this EventConnections instance 
// (e.g. you can subscribe using lambdas)
worldsplinegraph->getEventSegmentAdded().connect(segmentadded_event_connections, [](const Ptr<WorldSplineGraph> & spline_graph,  const Ptr<SplineSegment> & segment) { 
		Log::message("\Handling SegmentAdded event (lambda).\n");
	}
);

// ...

// later all of these linked subscriptions can be removed with a single line
segmentadded_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 segmentadded_event_connection;

// subscribe for the SegmentAdded event with a handler function keeping the connection
worldsplinegraph->getEventSegmentAdded().connect(segmentadded_event_connection, segmentadded_event_handler);

// ...

// you can temporarily disable a particular event connection to perform certain actions
segmentadded_event_connection.setEnabled(false);

// ... actions to be performed

// and enable it back when necessary
segmentadded_event_connection.setEnabled(true);

// ...

// remove subscription for the SegmentAdded event via the connection
segmentadded_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 SegmentAdded event handler implemented as a class member
	void event_handler(const Ptr<WorldSplineGraph> & spline_graph,  const Ptr<SplineSegment> & segment)
	{
		Log::message("\Handling SegmentAdded event\n");
		// ...
	}
};

SomeClass *sc = new SomeClass();

// ...

// specify a class instance in case a handler method belongs to some class
worldsplinegraph->getEventSegmentAdded().connect(sc->e_connections, sc, &SomeClass::event_handler);

// ...

// handler class instance is deleted with all its subscriptions removed automatically
delete sc;

//////////////////////////////////////////////////////////////////////////////
//  4. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////

// subscribe for the SegmentAdded event with a handler function
worldsplinegraph->getEventSegmentAdded().connect(segmentadded_event_handler);


// remove subscription for the SegmentAdded event later by the handler function
worldsplinegraph->getEventSegmentAdded().disconnect(segmentadded_event_handler);


//////////////////////////////////////////////////////////////////////////////
//   5. Subscribe to an event saving an ID and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////

// define a connection ID to be used to unsubscribe later
EventConnectionId segmentadded_handler_id;

// subscribe for the SegmentAdded event with a lambda handler function and keeping connection ID
segmentadded_handler_id = worldsplinegraph->getEventSegmentAdded().connect([](const Ptr<WorldSplineGraph> & spline_graph,  const Ptr<SplineSegment> & segment) { 
		Log::message("\Handling SegmentAdded event (lambda).\n");
	}
);

// remove the subscription later using the ID
worldsplinegraph->getEventSegmentAdded().disconnect(segmentadded_handler_id);


//////////////////////////////////////////////////////////////////////////////
//   6. Ignoring all SegmentAdded events when necessary
//////////////////////////////////////////////////////////////////////////////

// you can temporarily disable the event to perform certain actions without triggering it
worldsplinegraph->getEventSegmentAdded().setEnabled(false);

// ... actions to be performed

// and enable it back when necessary
worldsplinegraph->getEventSegmentAdded().setEnabled(true);
Notice
For more details see the Event Handling article.
The event handler signature is as follows: myhandler(const Ptr<WorldSplineGraph> & spline_graph, const Ptr<SplineSegment> & segment)

Return value

Current

Event<const Ptr<WorldSplineGraph> &, const Ptr<SplinePoint> &> getEventPointRemoved() const#

event triggered when a point of the world spline graph is removed. You can subscribe to events via connect()  and unsubscribe via disconnect(). You can also use EventConnection  and EventConnections  classes for convenience (see examples below).

Usage Example

Source code (C++)
// implement the PointRemoved event handler
void pointremoved_event_handler(const Ptr<WorldSplineGraph> & spline_graph,  const Ptr<SplinePoint> & point)
{
	Log::message("\Handling PointRemoved 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 pointremoved_event_connections;

// link to this instance when subscribing for an event (subscription for various events can be linked)
worldsplinegraph->getEventPointRemoved().connect(pointremoved_event_connections, pointremoved_event_handler);

// other subscriptions are also linked to this EventConnections instance 
// (e.g. you can subscribe using lambdas)
worldsplinegraph->getEventPointRemoved().connect(pointremoved_event_connections, [](const Ptr<WorldSplineGraph> & spline_graph,  const Ptr<SplinePoint> & point) { 
		Log::message("\Handling PointRemoved event (lambda).\n");
	}
);

// ...

// later all of these linked subscriptions can be removed with a single line
pointremoved_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 pointremoved_event_connection;

// subscribe for the PointRemoved event with a handler function keeping the connection
worldsplinegraph->getEventPointRemoved().connect(pointremoved_event_connection, pointremoved_event_handler);

// ...

// you can temporarily disable a particular event connection to perform certain actions
pointremoved_event_connection.setEnabled(false);

// ... actions to be performed

// and enable it back when necessary
pointremoved_event_connection.setEnabled(true);

// ...

// remove subscription for the PointRemoved event via the connection
pointremoved_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 PointRemoved event handler implemented as a class member
	void event_handler(const Ptr<WorldSplineGraph> & spline_graph,  const Ptr<SplinePoint> & point)
	{
		Log::message("\Handling PointRemoved event\n");
		// ...
	}
};

SomeClass *sc = new SomeClass();

// ...

// specify a class instance in case a handler method belongs to some class
worldsplinegraph->getEventPointRemoved().connect(sc->e_connections, sc, &SomeClass::event_handler);

// ...

// handler class instance is deleted with all its subscriptions removed automatically
delete sc;

//////////////////////////////////////////////////////////////////////////////
//  4. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////

// subscribe for the PointRemoved event with a handler function
worldsplinegraph->getEventPointRemoved().connect(pointremoved_event_handler);


// remove subscription for the PointRemoved event later by the handler function
worldsplinegraph->getEventPointRemoved().disconnect(pointremoved_event_handler);


//////////////////////////////////////////////////////////////////////////////
//   5. Subscribe to an event saving an ID and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////

// define a connection ID to be used to unsubscribe later
EventConnectionId pointremoved_handler_id;

// subscribe for the PointRemoved event with a lambda handler function and keeping connection ID
pointremoved_handler_id = worldsplinegraph->getEventPointRemoved().connect([](const Ptr<WorldSplineGraph> & spline_graph,  const Ptr<SplinePoint> & point) { 
		Log::message("\Handling PointRemoved event (lambda).\n");
	}
);

// remove the subscription later using the ID
worldsplinegraph->getEventPointRemoved().disconnect(pointremoved_handler_id);


//////////////////////////////////////////////////////////////////////////////
//   6. Ignoring all PointRemoved events when necessary
//////////////////////////////////////////////////////////////////////////////

// you can temporarily disable the event to perform certain actions without triggering it
worldsplinegraph->getEventPointRemoved().setEnabled(false);

// ... actions to be performed

// and enable it back when necessary
worldsplinegraph->getEventPointRemoved().setEnabled(true);
Notice
For more details see the Event Handling article.
The event handler signature is as follows: myhandler(const Ptr<WorldSplineGraph> & spline_graph, const Ptr<SplinePoint> & point)

Return value

Current

Event<const Ptr<WorldSplineGraph> &, const Ptr<SplinePoint> &> getEventPointChanged() const#

event triggered when a point of the world spline graph is modified. You can subscribe to events via connect()  and unsubscribe via disconnect(). You can also use EventConnection  and EventConnections  classes for convenience (see examples below).

Usage Example

Source code (C++)
// implement the PointChanged event handler
void pointchanged_event_handler(const Ptr<WorldSplineGraph> & spline_graph,  const Ptr<SplinePoint> & point)
{
	Log::message("\Handling PointChanged 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 pointchanged_event_connections;

// link to this instance when subscribing for an event (subscription for various events can be linked)
worldsplinegraph->getEventPointChanged().connect(pointchanged_event_connections, pointchanged_event_handler);

// other subscriptions are also linked to this EventConnections instance 
// (e.g. you can subscribe using lambdas)
worldsplinegraph->getEventPointChanged().connect(pointchanged_event_connections, [](const Ptr<WorldSplineGraph> & spline_graph,  const Ptr<SplinePoint> & point) { 
		Log::message("\Handling PointChanged event (lambda).\n");
	}
);

// ...

// later all of these linked subscriptions can be removed with a single line
pointchanged_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 pointchanged_event_connection;

// subscribe for the PointChanged event with a handler function keeping the connection
worldsplinegraph->getEventPointChanged().connect(pointchanged_event_connection, pointchanged_event_handler);

// ...

// you can temporarily disable a particular event connection to perform certain actions
pointchanged_event_connection.setEnabled(false);

// ... actions to be performed

// and enable it back when necessary
pointchanged_event_connection.setEnabled(true);

// ...

// remove subscription for the PointChanged event via the connection
pointchanged_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 PointChanged event handler implemented as a class member
	void event_handler(const Ptr<WorldSplineGraph> & spline_graph,  const Ptr<SplinePoint> & point)
	{
		Log::message("\Handling PointChanged event\n");
		// ...
	}
};

SomeClass *sc = new SomeClass();

// ...

// specify a class instance in case a handler method belongs to some class
worldsplinegraph->getEventPointChanged().connect(sc->e_connections, sc, &SomeClass::event_handler);

// ...

// handler class instance is deleted with all its subscriptions removed automatically
delete sc;

//////////////////////////////////////////////////////////////////////////////
//  4. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////

// subscribe for the PointChanged event with a handler function
worldsplinegraph->getEventPointChanged().connect(pointchanged_event_handler);


// remove subscription for the PointChanged event later by the handler function
worldsplinegraph->getEventPointChanged().disconnect(pointchanged_event_handler);


//////////////////////////////////////////////////////////////////////////////
//   5. Subscribe to an event saving an ID and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////

// define a connection ID to be used to unsubscribe later
EventConnectionId pointchanged_handler_id;

// subscribe for the PointChanged event with a lambda handler function and keeping connection ID
pointchanged_handler_id = worldsplinegraph->getEventPointChanged().connect([](const Ptr<WorldSplineGraph> & spline_graph,  const Ptr<SplinePoint> & point) { 
		Log::message("\Handling PointChanged event (lambda).\n");
	}
);

// remove the subscription later using the ID
worldsplinegraph->getEventPointChanged().disconnect(pointchanged_handler_id);


//////////////////////////////////////////////////////////////////////////////
//   6. Ignoring all PointChanged events when necessary
//////////////////////////////////////////////////////////////////////////////

// you can temporarily disable the event to perform certain actions without triggering it
worldsplinegraph->getEventPointChanged().setEnabled(false);

// ... actions to be performed

// and enable it back when necessary
worldsplinegraph->getEventPointChanged().setEnabled(true);
Notice
For more details see the Event Handling article.
The event handler signature is as follows: myhandler(const Ptr<WorldSplineGraph> & spline_graph, const Ptr<SplinePoint> & point)

Return value

Current

Event<const Ptr<WorldSplineGraph> &, const Ptr<SplinePoint> &> getEventPointAdded() const#

event triggered when a point is added to the world spline graph. You can subscribe to events via connect()  and unsubscribe via disconnect(). You can also use EventConnection  and EventConnections  classes for convenience (see examples below).

Usage Example

Source code (C++)
// implement the PointAdded event handler
void pointadded_event_handler(const Ptr<WorldSplineGraph> & spline_graph,  const Ptr<SplinePoint> & point)
{
	Log::message("\Handling PointAdded 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 pointadded_event_connections;

// link to this instance when subscribing for an event (subscription for various events can be linked)
worldsplinegraph->getEventPointAdded().connect(pointadded_event_connections, pointadded_event_handler);

// other subscriptions are also linked to this EventConnections instance 
// (e.g. you can subscribe using lambdas)
worldsplinegraph->getEventPointAdded().connect(pointadded_event_connections, [](const Ptr<WorldSplineGraph> & spline_graph,  const Ptr<SplinePoint> & point) { 
		Log::message("\Handling PointAdded event (lambda).\n");
	}
);

// ...

// later all of these linked subscriptions can be removed with a single line
pointadded_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 pointadded_event_connection;

// subscribe for the PointAdded event with a handler function keeping the connection
worldsplinegraph->getEventPointAdded().connect(pointadded_event_connection, pointadded_event_handler);

// ...

// you can temporarily disable a particular event connection to perform certain actions
pointadded_event_connection.setEnabled(false);

// ... actions to be performed

// and enable it back when necessary
pointadded_event_connection.setEnabled(true);

// ...

// remove subscription for the PointAdded event via the connection
pointadded_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 PointAdded event handler implemented as a class member
	void event_handler(const Ptr<WorldSplineGraph> & spline_graph,  const Ptr<SplinePoint> & point)
	{
		Log::message("\Handling PointAdded event\n");
		// ...
	}
};

SomeClass *sc = new SomeClass();

// ...

// specify a class instance in case a handler method belongs to some class
worldsplinegraph->getEventPointAdded().connect(sc->e_connections, sc, &SomeClass::event_handler);

// ...

// handler class instance is deleted with all its subscriptions removed automatically
delete sc;

//////////////////////////////////////////////////////////////////////////////
//  4. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////

// subscribe for the PointAdded event with a handler function
worldsplinegraph->getEventPointAdded().connect(pointadded_event_handler);


// remove subscription for the PointAdded event later by the handler function
worldsplinegraph->getEventPointAdded().disconnect(pointadded_event_handler);


//////////////////////////////////////////////////////////////////////////////
//   5. Subscribe to an event saving an ID and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////

// define a connection ID to be used to unsubscribe later
EventConnectionId pointadded_handler_id;

// subscribe for the PointAdded event with a lambda handler function and keeping connection ID
pointadded_handler_id = worldsplinegraph->getEventPointAdded().connect([](const Ptr<WorldSplineGraph> & spline_graph,  const Ptr<SplinePoint> & point) { 
		Log::message("\Handling PointAdded event (lambda).\n");
	}
);

// remove the subscription later using the ID
worldsplinegraph->getEventPointAdded().disconnect(pointadded_handler_id);


//////////////////////////////////////////////////////////////////////////////
//   6. Ignoring all PointAdded events when necessary
//////////////////////////////////////////////////////////////////////////////

// you can temporarily disable the event to perform certain actions without triggering it
worldsplinegraph->getEventPointAdded().setEnabled(false);

// ... actions to be performed

// and enable it back when necessary
worldsplinegraph->getEventPointAdded().setEnabled(true);
Notice
For more details see the Event Handling article.
The event handler signature is as follows: myhandler(const Ptr<WorldSplineGraph> & spline_graph, const Ptr<SplinePoint> & point)

Return value

Current

static WorldSplineGraphPtr create ( ) #

Default constructor. Creates an empty world spline graph.

static WorldSplineGraphPtr create ( const char * name ) #

Constructor. Creates an empty world spline graph with a given name.

Arguments

  • const char * name - World spline graph name.

int getNumSplinePoints ( ) const#

Returns the total number of spline points in the world spline graph.

Return value

Number of spline points.

int getNumSplineSegments ( ) const#

Returns the total number of spline segments in the world spline graph.

Return value

Number of segments.

void setSplineGraphName ( const char * name, bool force_load = 0 ) #

Sets the name of the world spline graph.

Arguments

  • const char * name - World spline graph name.
  • bool force_load - Force flag.
    • If 1 is specified, the world spline graph will immediately loaded from a file.
    • If 0 is specified, only the world spline graph name will be updated.

const char * getSplineGraphName ( ) const#

Returns the name of the world spline graph.

Return value

World spline graph name.

void loadSegmentNodes ( int segment_index = -1 ) #

Loads source nodes assigned to the specified spline segment immediately.

Arguments

  • int segment_index - Segment index. If no segment index is specified, the method loads source nodes assigned to all segments.

void clear ( ) #

Clears the world spline graph.

bool isCurved ( ) const#

Returns a value indicating if the world spline graph is curved.

Return value

true if the world spline graph is curved; otherwise, false.

void makeCurved ( ) #

Curves the world spline graph using its geodetic pivot. The spline file is saved upon completion of the curving operation.
Notice
The world spline graph must be a child of a Geodetic Pivot node.

void makeFlat ( ) #

Flattens the world spline graph using its geodetic pivot. The spline file is saved upon completion of the flattening operation.
Notice
The world spline graph must be a child of a Geodetic Pivot node.

bool load ( const char * name ) #

Loads a spline graph from the specified XML-file.

Arguments

  • const char * name - Name of the XML-file to load the spline graph from.

Return value

true if the spline graph was successfully loaded; otherwise, false.

bool save ( const char * name ) #

Saves a spline graph to the specified XML-file.

Arguments

  • const char * name - Name of the XML-file to save the spline graph to.

Return value

true if the spline graph was successfully saved; otherwise, false.

static int type ( ) #

Returns the type of the node.

Return value

WorldSplineGraph type identifier.

void getSegmentNodeMesh ( const Ptr<Mesh> & mesh, const Ptr<SplineSegment> & segment, int node_index, bool bake_transform = 0 ) #

Gets a mesh used by a node with the specified index, placed along the specified spline segment, and puts it to the specified target Mesh instance.

Arguments

  • const Ptr<Mesh> & mesh - Target mesh instance to which the obtained mesh is to be put.
  • const Ptr<SplineSegment> & segment - Spline segment for which the mesh is to be returned.
  • int node_index - Number of the node instance placed along the spline segment.
  • bool bake_transform - true to use baked mesh transformation, false - to use default (the mesh will be placed at the origin). The default value is false.

void getPointNodeMesh ( const Ptr<Mesh> & mesh, const Ptr<SplinePoint> & point, int node_index, bool bake_transform = false ) #

Exports a mesh with the specified index placed as the specified spline point to the specified target mesh.
Notice
Due to the nature of the mesh, there will be visual artifacts connected with the float precision, in case an exported node is located very far from the origin (around 10,000 m and further). In this case we advise exporting it without baking transformation.

Arguments

  • const Ptr<Mesh> & mesh - Target mesh to store the desired mesh placed at the specified spline point.
  • const Ptr<SplinePoint> & point - Spline point for which a mesh is to be retrieved.
  • int node_index - Number of the desired node in a row of nodes placed at the specified point, in the range from 0 to the total number of nodes placed at the point.
    Notice
    The node must be an ObjectMeshStatic or an ObjectMeshSkinned, otherwise an error occurs.
  • bool bake_transform - Bake Transform flag: true - to export the mesh preserving the current coordinates (can be useful when splitting large WorldSplineGraph objects to keep relative positions of meshes); or false - to reset the position of the exported mesh to origin (0,0,0) with zero-rotation.

Ptr<SplinePoint> createSplinePoint ( const Math::Vec3 & position ) #

Creates a new spline point with the specified parameters and attaches it to the world spline graph.

Arguments

  • const Math::Vec3 & position - Position coordinates for the new splint point.

Return value

New spline point.

void removeSplinePoint ( const Ptr<SplinePoint> & point, bool merge = 0 ) #

Removes the specified spline point from the world spline graph. You can set the merge flag to merge spline segments sharing this point as their start and end points.
Notice
Segment merging is available only when the point to be removed is shared by two segments, otherwise the merge flag is ignored and all segments sharing this point are also removed.

Arguments

  • const Ptr<SplinePoint> & point - Spline point to be removed.
  • bool merge - true to merge spline segments sharing this point as their start and end points, false to remove all segments sharing this point. The default value is false.

void getSplinePoints ( Vector<Ptr<SplinePoint>> & OUT_points ) const#

Returns the list of all points of the world spline graph and puts them to the specified vector of SplinePoint elements.

Arguments

  • Vector<Ptr<SplinePoint>> & OUT_points - Vector to store the list of all points of the world spline graph.
    Notice
    This output buffer is to be filled by the Engine as a result of executing the method.

Ptr<SplineSegment> createSplineSegment ( const Ptr<SplinePoint> & start_point, const Math::vec3 & start_tangent, const Math::vec3 & start_up, const Ptr<SplinePoint> & end_point, const Math::vec3 & end_tangent, const Math::vec3 & end_up ) #

Creates a new spline segment with the specified parameters and attaches it to the world spline graph.

Arguments

  • const Ptr<SplinePoint> & start_point - Start point of the spline segment.
  • const Math::vec3 & start_tangent - Tangent coordinates for the start point of the spline segment.
  • const Math::vec3 & start_up - Coordinates of the "up" vector for the start point of the spline segment.
  • const Ptr<SplinePoint> & end_point - End point of the segment.
  • const Math::vec3 & end_tangent - Tangent coordinates for the end point of the spline segment.
  • const Math::vec3 & end_up - Coordinates of the "up" vector for the end point of the spline segment.

Return value

New spline segment connecting two specified points.

void removeSplineSegment ( const Ptr<SplineSegment> & segment, bool with_points = 0 ) #

Removes the specified spline segment from the world spline graph. You can set the with_points flag to remove the segment together with its start and end points.

Arguments

  • const Ptr<SplineSegment> & segment - Spline segment to be removed.
  • bool with_points - true to remove the segment with its start and end points, false to keep points. The default value is false.

void getSplineSegments ( Vector<Ptr<SplineSegment>> & OUT_segments ) const#

Returns the list of all segments of the world spline graph and puts them to the specified vector of SplineSegment elements.

Arguments

  • Vector<Ptr<SplineSegment>> & OUT_segments - Vector to store the list of all segments of the world spline graph.
    Notice
    This output buffer is to be filled by the Engine as a result of executing the method.

void rebuild ( int try_force = 0 ) #

Rebuilds the world spline graph. This method is to be called after making any changes to spline segments (mode, etc.), point positions, tangents, or "up" vectors, as well as after changing source node assignments and/or other parameters (UV tiling, gap, etc.)

Arguments

  • int try_force - Forced rebuild flag: set 1 to try and force rebuild the world spline graph.

int isRebuilding ( ) const#

Returns a value indicating if the world spline graph is currently being rebuilt. The world spline graph uses a deferred rebuild.

Return value

1 if the world spline graph is currently being rebuilt; otherwise 0.

void splitSplineSegment ( const Ptr<SplineSegment> & segment, float new_point_t ) #

Splits the specified spline segment into two parts by inserting a new point placed at the parametrically specified point on the T (times axis) in the [0.0f, 1.0f] range from the segment's start point.

Arguments

  • const Ptr<SplineSegment> & segment - Spline segment to be split.
  • float new_point_t - Coordinate of the splitting point of the segment along the horizontal T (times) axis in the range [0.0f, 1.0f].

void breakSplinePoint ( const Ptr<SplinePoint> & point ) #

Breaks the specified spline point shared by several spline segments into a set of separate ones, so that each of the segments gets its own point.

Arguments

  • const Ptr<SplinePoint> & point - Spline point to be broken.
    Notice
    The point must be shared by a least 2 segments.

void weldSplinePoints ( Vector<Ptr<SplinePoint>> & OUT_points ) #

Joins all spline points specified in the list into a single one, so that this point is shared by all spline segments having the specified points as starting or ending ones.

Arguments

  • Vector<Ptr<SplinePoint>> & OUT_points - List of spline points to be joined into a single one.
    Notice
    This output buffer is to be filled by the Engine as a result of executing the method.

bool isLinked ( const Ptr<SplinePoint> & point ) const#

Returns a value indicating if the specified spline point is linked to any spline segment.

Arguments

Return value

1 if the specified spline point is linked to any spline segment; otherwise, 0.
Last update: 19.12.2023
Build: ()