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
Учебные материалы
Внимание! Эта версия документация УСТАРЕЛА, поскольку относится к более ранней версии SDK! Пожалуйста, переключитесь на самую актуальную документацию для последней версии SDK.
Внимание! Эта версия документации описывает устаревшую версию SDK, которая больше не поддерживается! Пожалуйста, обновитесь до последней версии SDK.

Unigine::FieldShoreline Class

Header: #include <UnigineFields.h>
Inherits from: Field

This class is used to create and modify a field shoreline. The field is applied to global water and helps to create swashes near the shores and applies the wetness effect on objects near the shoreline.

Notice
A field shoreline object will affect water only if the FieldShoreline interaction option is enabled on the States tab of the water_global_base material.

Creating a Shoreline Field

Notice
When creating a FieldShoreline object you should specify a shoreline texture for as this object doesn't have any default texture.
Source code (C++)
// create a new instance of the FieldShoreline class and set its transformation
FieldShorelinePtr shoreline = FieldShoreline::create();
shoreline->setTransform(Mat4(1));
// set the size of the field 
shoreline->setSize(vec3(4096.0f, 4096.0f, 512.0f));
// set the path to the shoreline texture
shoreline->setTexturePath("unigine_project/textures/shorelines/shoreline_0.dds");

FieldShoreline Class

Members

Event<> getEventProgress() const#

event triggered when shoreline is baked (bakeWaterLevel() is called). This event is called for each baking iteration, and the value from 0 to 1 (where 1 equals to 100%) is passed to the event. You can subscribe to events via connect()  and unsubscribe via disconnect(). You can also use EventConnection  and EventConnections  classes for convenience (see examples below).
Notice
For more details see the Event Handling article.
The event handler signature is as follows: myhandler()

Usage Example

Source code (C++)
// implement the Progress event handler
void progress_event_handler()
{
	Log::message("\Handling Progress 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 progress_event_connections;

// link to this instance when subscribing to an event (subscription to various events can be linked)
publisher->getEventProgress().connect(progress_event_connections, progress_event_handler);

// other subscriptions are also linked to this EventConnections instance 
// (e.g. you can subscribe using lambdas)
publisher->getEventProgress().connect(progress_event_connections, []() { 
		Log::message("\Handling Progress event (lambda).\n");
	}
);

// ...

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

// subscribe to the Progress event with a handler function keeping the connection
publisher->getEventProgress().connect(progress_event_connection, progress_event_handler);

// ...

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

// ... actions to be performed

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

// ...

// remove subscription to the Progress event via the connection
progress_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 Progress event handler implemented as a class member
	void event_handler()
	{
		Log::message("\Handling Progress event\n");
		// ...
	}
};

SomeClass *sc = new SomeClass();

// ...

// specify a class instance in case a handler method belongs to some class
publisher->getEventProgress().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 to the Progress event with a handler function
publisher->getEventProgress().connect(progress_event_handler);


// remove subscription to the Progress event later by the handler function
publisher->getEventProgress().disconnect(progress_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 progress_handler_id;

// subscribe to the Progress event with a lambda handler function and keeping connection ID
progress_handler_id = publisher->getEventProgress().connect([]() { 
		Log::message("\Handling Progress event (lambda).\n");
	}
);

// remove the subscription later using the ID
publisher->getEventProgress().disconnect(progress_handler_id);


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

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

// ... actions to be performed

// and enable it back when necessary
publisher->getEventProgress().setEnabled(true);

Return value

Event reference.

static FieldShorelinePtr create ( ) #

Default constructor. Creates a FieldShoreline instance with the default size vec3(512.0f, 512.0f, 512.0f).
Notice
By default, a shoreline texture is empty. Specify it after creating the FieldShoreline by using an appropriate function.

int bakeWaterLevel ( const Ptr<Image> & image ) #

Bakes shoreline for the current water level of the global water object and puts it to the specified image. This method generates a shoreline texture by finding intersections of the Global Water object with terrains (Landscape Terrain and Terrain Global)

Arguments

  • const Ptr<Image> & image - Image instance to which the shoreline for the current water level is to be baked.

Return value

1 if the shoreline is baked successfully; otherwise, 0.

void setTexture ( const Ptr<Texture> & texture ) #

Sets the given texture from the Texture instance for the FieldShoreline.

Arguments

Ptr<Texture> getTexture ( ) const#

Returns the shoreline texture (from GPU) and saves it into the given Texture instance.

Return value

Shoreline texture.

int setTextureImage ( const Ptr<Image> & image ) #

Sets the given image as the shoreline texture of the FieldShoreline.

Arguments

  • const Ptr<Image> & image - Image instance with a shoreline texture for the FieldShoreline.

int getTextureImage ( const Ptr<Image> & image ) const#

Grabs the texture for the FieldShoreline (already loaded to GPU) and saves it into the given Image instance.

Arguments

  • const Ptr<Image> & image - Image instance into which the texture will be saved.

Return value

1 if the texture has been grabbed successfully; otherwise, 0.

void setTexturePath ( const char * path ) #

Sets the path to the FieldShoreline's shoreline texture.

Arguments

  • const char * path - Path to the shoreline texture.

const char * getTexturePath ( ) const#

Returns the path to the FieldShoreline's shoreline texture.

Return value

Path to the shoreline texture.

void setSize ( const Math::vec3 & size ) #

Sets the vec3 size vector of the FieldShoreline.

The default value is (512.0f, 512.0f, 512.0f).

Arguments

  • const Math::vec3 & size - Size vector (x,y,z), where:
    • x value is length of the FieldShoreline along X axis (in units),
    • y value is length of the FieldShoreline along Y axis (in units),
    • z value is length of the FieldShoreline along Z axis (in units).

Math::vec3 getSize ( ) const#

Returns the vec3 size vector of the FieldShoreline.

The default value is (512.0f, 512.0f, 512.0f).

Return value

Size vector (x,y,z), where:
  • x value is length of the FieldShoreline along X axis (in units),
  • y value is length of the FieldShoreline along Y axis (in units),
  • z value is length of the FieldShoreline along Z axis (in units).

int createShorelineDistanceField ( const Ptr<Texture> & texture, int shoreline_radius, int blur_radius, int downsample_resolution ) #

Creates a shoreline distance field with the specified parameters and puts it to the specified Image.
Source code
float shoreline_radius = 64;
int blur_radius = 8;
int downsample_resolution = 128;
Texture distance_field = new Texture();
field.createShorelineDistanceField(distance_field,shoreline_radius,blur_radius,downsample_resolution);

Arguments

  • const Ptr<Texture> & texture - Texture to which the shoreline distance field will be put.
  • int shoreline_radius - Radius of the shoreline.
  • int blur_radius - Radius of the blurred area.
  • int downsample_resolution - Shoreline resolution.

Return value

1 if the field was created successfully; otherwise, 0.

static int type ( ) #

Returns the type of the object.

Return value

FieldShoreline type identifier.
Last update: 20.03.2024
Build: ()