This page has been translated automatically.
Видеоуроки
Интерфейс
Основы
Продвинутый уровень
Подсказки и советы
Основы
Программирование на C#
Рендеринг
Профессиональный уровень (SIM)
Принципы работы
Свойства (properties)
Компонентная Система
Рендер
Режимы вывода изображения
Физика
Браузер SDK 2
Лицензирование и типы лицензий
Дополнения (Add-Ons)
Демонстрационные проекты
API Samples
Редактор UnigineEditor
Обзор интерфейса
Работа с ассетами
Контроль версий
Настройки и предпочтения
Работа с проектами
Настройка параметров ноды
Setting Up Materials
Настройка свойств
Освещение
Sandworm
Использование инструментов редактора для конкретных задач
Расширение функционала редактора
Встроенные объекты
Ноды (Nodes)
Объекты (Objects)
Эффекты
Декали
Источники света
Geodetics
World-ноды
Звуковые объекты
Объекты поиска пути
Player-ноды
Программирование
Основы
Настройка среды разработки
Примеры использования
C++
C#
UnigineScript
Унифицированный язык шейдеров UUSL (Unified UNIGINE Shader Language)
Плагины
Форматы файлов
Материалы и шейдеры
Rebuilding the Engine Tools
Интерфейс пользователя (GUI)
Двойная точность координат
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
VR-Related Classes
Работа с контентом
Оптимизация контента
Материалы
Визуальный редактор материалов
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Учебные материалы

Unigine.TextureRamp Class

Interface for handling ramp textures. This class lets the user store 2d curves in a form of a texture (convert vectors to raster data).

Ramp textures can be used for color variation in the particles_base material of Particle Systems or in other custom materials.

You can set up to 4 channels for the ramp texture.

TextureRamp Class

Properties

Texture Texture#

The new texture and updates hashes for curves, if required. Returns a pointer to the texture or null if the texture was not created.

int NumChannels#

The number of channels for the texture.

int Resolution#

The width resolution for the texture.

int Flags#

The texture flags.

bool IsDefaultAll#

The value indicating if the values of all curve channels are the default ones which were previously set via DefaultCurve.

Event EventChanged#

The event triggered on changing the ramp texture. 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 Changed event handler
void changed_event_handler()
{
	Log.Message("\Handling Changed event\n");
}

//////////////////////////////////////////////////////////////////////////////
//  1. Multiple subscriptions can be linked to an EventConnections instance
//  class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////

// create an instance of the EventConnections class
EventConnections changed_event_connections = new EventConnections();


// link to this instance when subscribing to an event (subscription to various events can be linked)
publisher.EventChanged.Connect(changed_event_connections, changed_event_handler);

// other subscriptions are also linked to this EventConnections instance 
// (e.g. you can subscribe using lambdas)
publisher.EventChanged.Connect(changed_event_connections, () => { 
		Log.Message("Handling Changed event lambda\n");
		}
	);

// later all of these linked subscriptions can be removed with a single line
changed_event_connections.DisconnectAll();

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

// subscribe to the Changed event with a handler function
publisher.EventChanged.Connect(changed_event_handler);


// remove subscription to the Changed event later by the handler function
publisher.EventChanged.Disconnect(changed_event_handler);


//////////////////////////////////////////////////////////////////////////////
//   3. Subscribe to an event and unsubscribe later via an EventConnection instance
//////////////////////////////////////////////////////////////////////////////

// define a connection to be used to unsubscribe later
EventConnection changed_event_connection;

// subscribe to the Changed event with a lambda handler function and keeping the connection
changed_event_connection = publisher.EventChanged.Connect(() => { 
		Log.Message("Handling Changed event lambda\n");
	}
);

// ...

// you can temporarily disable a particular event connection 
changed_event_connection.Enabled = false;

// ... perform certain actions

// and enable it back when necessary
changed_event_connection.Enabled = true;

// ...

// remove the subscription later using the saved connection
changed_event_connection.Disconnect();

//////////////////////////////////////////////////////////////////////////////
//   4. Ignoring Changed events when necessary
//////////////////////////////////////////////////////////////////////////////

// you can temporarily disable the event to perform certain actions without triggering it
publisher.EventChanged.Enabled = false;

// ... actions to be performed

// and enable it back when necessary
publisher.EventChanged.Enabled = true;

Members


TextureRamp ( int num_channels, int resolution, int flags ) #

Sets resolution, number of channels and texture flags for this TextureRamp instance. The pointer to the ramp texture is set to null and curves are marked for an update.

Arguments

  • int num_channels - Number of texture channels.
  • int resolution - Width resolution of the ramp texture.
  • int flags - Texture flags.

TextureRamp ( TextureRamp texture_ramp ) #

Ramp texture constructor. Creates a new ramp texture by copying a given source ramp texture.

Arguments

  • TextureRamp texture_ramp - Pointer to a new ramp texture.

TextureRamp ( ) #

void ReleaseTexture ( ) #

Deletes the texture and its pointer.

void Copy ( TextureRamp src_texture_ramp ) #

Copies the data of a source ramp texture to the texture.

Arguments

  • TextureRamp src_texture_ramp - Source ramp texture.

TextureRamp Clone ( ) #

Duplicates the ramp texture and returns a pointer to the copy.

Curve2d GetCurve ( int channel ) #

Returns a pointer to the Curve2d for the specified channel.

Arguments

  • int channel - Required channel.

Return value

Pointer to a Curve2d object.

void SetDefaultCurve ( Curve2d default_curve ) #

Resets a curve to a default one.

Arguments

  • Curve2d default_curve - A curve to be used as the default one.

void SetDefaultCurve ( int channel, Curve2d default_curve ) #

Resets a curve for the given channel to a default one.

Arguments

  • int channel - R, G, B, or A channel set by the corresponding value from 0 to 3.
  • Curve2d default_curve - A curve to be used as the default one.

bool IsDefault ( int channel ) #

Returns a value indicating if the value of the given curve channel is the default one which was previously set via setDefaultCurve.

Arguments

  • int channel - R, G, B, or A channel set by the corresponding value from 0 to 3.

Return value

true if the curve value is the default one set via setDefaultCurve, otherwise false.

void Save ( Xml xml ) #

Saves the ramp texture data to the given Xml node.

Arguments

  • Xml xml - Target Xml node.

void Save ( Json json ) #

Saves the ramp texture data to the given Json class instance.

Arguments

  • Json json - Target son class instance.

void Load ( Xml xml ) #

Loads the ramp texture data from the given Xml node.

Arguments

  • Xml xml - Source Xml node containing ramp texture data.

void Load ( Json json ) #

Loads the ramp texture data from the given Json class instance.

Arguments

  • Json json - Source Json class instance containing ramp texture data.

void SaveState ( Stream stream ) #

Saves the state of the ramp texture into a binary stream.

Example using SaveState() and RestoreState() methods:

Source code (C#)
// initialize a node and set its state
//...//

// save state
Blob blob_state = new Blob();
ramp.SaveState(blob_state);

// change the node state
//...//

// restore state
blob_state.SeekSet(0);	// returning the carriage to the start of the blob
ramp.RestoreState(blob_state);

Arguments

  • Stream stream - The stream to save the ramp texture state data.

void RestoreState ( Stream stream ) #

Restores the state of the ramp texture from the binary stream.

Example using SaveState() and RestoreState() methods:

Source code (C#)
// initialize a node and set its state
//...//

// save state
Blob blob_state = new Blob();
ramp.SaveState(blob_state);

// change the node state
//...//

// restore state
blob_state.SeekSet(0);	// returning the carriage to the start of the blob
ramp.RestoreState(blob_state);

Arguments

  • Stream stream - The stream that stores the ramp texture state data.
Last update: 13.12.2024
Build: ()