This page has been translated automatically.
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Landscape Tool
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine Tools
GUI
Double Precision Coordinates
API
Containers
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
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

Curve2d Class

Warning
The scope of applications for UnigineScript is limited to implementing materials-related logic (material expressions, scriptable materials, brush materials). Do not use UnigineScript as a language for application logic, please consider C#/C++ instead, as these APIs are the preferred ones. Availability of new Engine features in UnigineScipt (beyond its scope of applications) is not guaranteed, as the current level of support assumes only fixing critical issues.

This class represents an interface enabling you to create and manage 2D curves. These curves are used, for example, to control behavior of various parameters of particle systems (how they change over time).

Curve2d Class

Members


Curve2d ( ) #

Constructor. Creates a new 2d curve instance.

void clear ( ) #

Clears the curve removing all key points and tangents.

void copy ( const Curve2d curve ) #

Copies all the data (all key points and tangents) from the specified source curve.

Arguments

  • const Curve2d curve - Source curve.

int getHash ( ) #

Returns a hash value calculated for the curve. This value is used for performance optimization and helps define if the curve really needs to be updated, or nothing has changed in its parameters (repeat mode, key points, and tangents are all the same).

Return value

Hash value calculated for the curve.

int getNumKeys ( ) #

Returns the current total number of key points in the curve .

Return value

Total number of key points in the curve.

int addKey ( const vec2 & point ) #

Adds a new key point with the specified coordinates to the curve. Upon completion on this operation the CHANGED callback is fired.

Arguments

  • const vec2 & point - Coordinates of the new key point to be added.

Return value

Number of the added key point.

int addKey ( const vec2 & point, const vec2 & left_tangent, const vec2 & right_tangent ) #

Adds a new key point with the specified coordinates and tangents to the curve. Upon completion on this operation the CHANGED callback is fired.

Arguments

  • const vec2 & point - Coordinates of the new key point to be added.
  • const vec2 & left_tangent - Coordinates of the left tangent at the key point.
  • const vec2 & right_tangent - Coordinates of the right tangent at the key point.

Return value

Number of the added key point.

void removeKey ( int index ) #

Removes the key point with the specified number from the curve. Upon completion on this operation the CHANGED callback is fired.

Arguments

int moveKey ( int index, const vec2 & point ) #

Moves the key point with the specified number to a new position (preserving the tangents). Upon completion on this operation the CHANGED callback is fired. The index of key point will be updated automatically. This method can be used to implement dragging of keys on the curve. In case of moving multiple keys it is recommended to use the setKeyPoint() method to set new values for keys and then sort them all at once via the sortKeys() method to save performance.

Arguments

void sortKeys ( ) #

Sorts all key points ov the curve by time (X axis) in the ascending order. Upon completion on this operation the CHANGED callback is fired.

void setKeyPoint ( int index, const vec2 & point ) #

Sets new coordinates for the specified key point (tangents are unaffected). Upon completion on this operation the CHANGED callback is fired. This method unlike the moveKey() does not update the index of the key point automatically. It can be used to implement dragging of multiple keys to set new values for them along with subsequent sorting all keys at once via the sortKeys() method to save performance.

Arguments

  • int index - Key point number, in the range from 0 to the total number of key points in the curve.
  • const vec2 & point - New coordinates to be set for the specified point.

void setKeyLeftTangent ( int index, const vec2 & point ) #

Sets new coordinates for the left tangent at the specified key point of the curve. Upon completion on this operation the CHANGED callback is fired.

Arguments

  • int index - Key point number, in the range from 0 to the total number of key points in the curve.
  • const vec2 & point - New coordinates of the left tangent at the specified key point to be set.

void setKeyRightTangent ( int index, const vec2 & point ) #

Sets new coordinates for the right tangent at the specified key point of the curve. Upon completion on this operation the CHANGED callback is fired.

Arguments

  • int index - Key point number, in the range from 0 to the total number of key points in the curve.
  • const vec2 & point - New coordinates of the right tangent at the specified key point to be set.

vec2 getKeyPoint ( int index ) #

Returns the coordinates of the key point with the specified number.

Arguments

Return value

Current coordinates of the specified key point.

vec2 getKeyLeftTangent ( int index ) #

Returns the current coordinates for the left tangent at the specified key point of the curve.

Arguments

Return value

Current coordinates of the left tangent at the specified key point.

vec2 getKeyRightTangent ( int index ) #

Returns the current coordinates for the right tangent at the specified key point of the curve.

Arguments

Return value

Current coordinates of the right tangent at the specified key point.

int saveState ( Stream stream ) #

Saves data of the curve to a binary stream.

Arguments

  • Stream stream - Stream to which the curve data will be saved.

Return value

1 if the curve data is saved successfully; otherwise, 0.

int restoreState ( Stream stream ) #

Restores curve data from a binary stream.

Arguments

  • Stream stream - Stream in which the saved curve parameter data is stored.

Return value

1 if the curve data is restored successfully; otherwise, 0.

int save ( Xml xml ) #

Saves data of the curve to the specified instance of the Xml class.

Arguments

  • Xml xml - Xml class instance to which the curve data will be saved.

Return value

1 if the curve data is successfully saved to the specified Xml class instance; otherwise, 0.

int load ( Xml xml ) #

Loads curve data from the specified instance of the Xml class.

Arguments

  • Xml xml - Xml class instance in which the curve data is stored.

Return value

1 if the curve data is successfully loaded from the specified Xml class instance; otherwise, 0.

void setRepeatModeStart ( int start ) #

Sets the mode for the beginning of the curve to be used for repeating the sequence defined by the key points of the curve (tiling curves).

Arguments

  • int start - Repeat mode for the beginning of the curve (defines behavior before the first key point), one of the REPEAT_MODE_* values.

int getRepeatModeStart ( ) #

Returns the current mode for the beginning of the curve used for repeating the sequence defined by the key points of the curve (tiling curves).

Return value

Current repeat mode for the beginning of the curve (defines behavior before the first key point), one of the REPEAT_MODE_* values.

void setRepeatModeEnd ( int end ) #

Sets the mode for the end of the curve to be used for repeating the sequence defined by the key points of the curve (tiling curves).

Arguments

  • int end - Repeat mode for the end of the curve (defines behavior after the last key point), one of the REPEAT_MODE_* values.

int getRepeatModeEnd ( ) #

Returns the current mode for the end of the curve used for repeating the sequence defined by the key points of the curve (tiling curves).

Return value

Current repeat mode for the end of the curve (defines behavior after the last key point), one of the REPEAT_MODE_* values.
Last update: 2020-07-31
Build: ()