This page has been translated automatically.
UnigineScript
The Language
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
High-Level Systems
Samples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Content Creation
Materials
Unigine Material Library
Tutorials
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.

Type Conversion Functions

Variable dmat4 (double x, double y, double z)

Casts values to the dmat4 type, returning a translation matrix.

Arguments

  • double x - X component of the translation vector.
  • double y - Y component of the translation vector.
  • double z - Z component of the translation vector.

Return value

Translation matrix.

Variable dmat4 (float x, float y, float z, float angle)

Casts values to the dmat4 type, returning a rotation matrix.

Arguments

  • float x - X component of the rotation axis.
  • float y - Y component of the rotation axis.
  • float z - Z component of the rotation axis.
  • float angle - Rotation angle in degrees.

Return value

Rotation matrix.

Variable dmat4 (variable v)

Casts a value to the dmat4 type. The last of the matrix is always (0,0,0,1).

Arguments

  • variable v - Target value. Can be of the following types:
    • int (all elements of the matrix except for last row will be equal to the argument)
    • long
    • float
    • double
    • vec3 (see translate() function)
    • dvec3 (see translate() function)
    • mat4
    • dmat4
    • quat
    • string — it should contain 16 floating point values separated with whitespace characters, for example:
      Source code (UnigineScript)
      dmat4 a = dmat4(string("1 0 0 9 0 1 0 9 0 0 1 9 0 0 0 9"));
      dmat4 b = dmat4(string("1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 875765"));
      /*	a and b will be identical matrices in the result:
      1 0 0 0
      0 1 0 0
      0 0 1 0
      0 0 0 1
      */
      

Return value

Converted value.

Variable dmat4 (variable v1, variable v2)

Casts values to the dmat4 type, returning a rotation matrix. The casted values can be of the following types:
  • Roation axis and rotation angle: vec3 or dvec3 as the first argument and float as a second one.
  • Roatation and position: quat as the first argument and dvec3 as a second one.

Arguments

  • variable v1 - Rotation axis (vec3, dvec3) or rotation (quat).
  • variable v2 - Rotation angle in degrees (float) if the first argument is vec3 or dvec3 or position (dvec3) if the first argument is quat.

Return value

Rotation matrix.

Variable double (variable v)

Casts a value to the double type.

Arguments

  • variable v - Target value. Can be of the following types:
    • int
    • long
    • float
    • double
    • string - its first non-whitespace characters should form a double precision floating point number. Additional characters after it will be ignored. inf and -inf are also convertible. For example:
      Source code (UnigineScript)
      double a = double(string("-0.05"));         // a = -0.05
      double b = double(string("0.87354f 1.0f")); // b = 0.87354
      double c = double(string("inf"));           // c = 1E+9f
      

Return value

Converted value.

Variable dvec3 (double x, double y, double z)

Casts values to the dvec3 type.

Arguments

  • double x - X component of the vector.
  • double y - Y component of the vector.
  • double z - Z component of the vector.

Return value

Converted value.

Variable dvec3 (variable v)

Casts values to the dvec3 type.

Arguments

  • variable v - Target value. Can be of the following types:
    • int (all components will be equal to the argument)
    • long
    • float
    • double
    • vec3
    • vec4 (w component of the vector will be omitted)
    • dvec3
    • dvec4 (w component of the vector will be omitted)
    • ivec3
    • string - it should contain 3 double precision floating point numbers separated with whitespace characters, for example:
      Source code (UnigineScript)
      dvec3 a = dvec3(string("8.5 8.5 -0.847657946"));      // a = 8.5 8.5 -0.847657946
      dvec3 b = dvec3(string("10.5f character 1 75476.5")); // b = 10.5 0.0 1.0
      

Return value

Converted value.

Variable dvec4 (double x, double y, double z, double w)

Casts values to the dvec4 type.

Arguments

  • double x - X component of the vector.
  • double y - Y component of the vector.
  • double z - Z component of the vector.
  • double w - W component of the vector.

Return value

Converted value.

Variable dvec4 (variable v)

Casts values to the dvec4 type.

Arguments

  • variable v - Target value. Can be of the following types:
    • int (all components of the vector will be equal to the argument)
    • long
    • float
    • double
    • vec3 (w component of the vector will be equal to 1)
    • vec4
    • dvec3 (w component of the vector will be equal to 1)
    • dvec4
    • ivec4
    • string — it should contain 4 double precision floating point numbers separated with whitespace characters, for example:
      Source code (UnigineScript)
      dvec4 a = dvec4(string("0.5 0.5 -0.5 74567576.0"));      // a = 0.5 0.5 -0.5 74567576.0
      dvec4 b = dvec4(string("10.5f character 1 2 85646.02")); // b = 10.5 0.0 1.0 2.0
      

Return value

Converted value.

Variable dvec4 (variable Variable, double w)

Casts values to the dvec4 type.

Arguments

  • variable Variable - Vector with the first three components (either vec3 or dvec3).
  • double w - W component of the vector.

Return value

Converted value.

variable float (variable v)

Casts a value to the float type.

Arguments

  • variable v - Target value. Can be of the following types:
    • int
    • long
    • float
    • double
    • string — its first non-whitespace characters should form a floating point number. Additional characters after it will be ignored. inf and -inf are also convertible. For example:
      Source code (UnigineScript)
      float a = float(string("0.5"));     // a = 0.5
      float b = float(string("10.5 45")); // b = 10.5
      float c = float(string("inf"));     // c = 1E+9f
      

Return value

Converted value.

variable int (variable v)

Casts a value to the int type.

Arguments

  • variable v - Target value. Can be of the following types:
    • int
    • long
    • float
    • double
    • string — its first non-whitespace characters should form an integer number. Additional characters after it will be ignored. For example:
      Source code (UnigineScript)
      int a = int(string("3"));    // a = 3
      int b = int(string("0.4"));  // b = 0
      int c = int(string("3 42")); // c = 3
      

Return value

Converted value.

variable ivec3 (int x, int y, int z)

Casts values to the ivec3 type.

Arguments

  • int x - X component of the vector.
  • int y - Y component of the vector.
  • int z - Z component of the vector.

Return value

Converted value.

Variable ivec3 (variable v)

Casts a value to the ivec3 type.

Arguments

  • variable v - Target value. Can be of the following types:
    • int (all components will be equal to the argument)
    • long
    • float
    • double
    • vec3
    • dvec3
    • ivec3
    • string - it should contain 3 integer numbers separated with whitespace characters, for example:
      Source code (UnigineScript)
      ivec3 a = ivec3(string("1 -1 42"));               // a = 1 -1 42
      ivec3 b = ivec3(string("10.5f character 1 768")); // b = 10 0 1
      

Return value

Converted value.

Variable ivec4 (int x, int y, int z, int w)

Casts values to the ivec4 type.

Arguments

  • int x - X component of the vector.
  • int y - Y component of the vector.
  • int z - Z component of the vector.
  • int w - W component of the vector.

Return value

Converted value.

Variable ivec4 (variable v)

Casts a value to the ivec4 type.

Arguments

  • variable v - Target value. Can be of the following types:
    • int (all components of the vector will be equal to the argument)
    • long
    • float
    • double
    • vec4
    • dvec4
    • ivec4
    • string — it should contain 4 integer numbers separated with whitespace characters, for example:
      Source code (UnigineScript)
      ivec4 a = ivec4(string("1 1 1 -1"));                // a = 1 1 1 -1
      ivec4 b = ivec4(string("10.5f character 1 2 658")); // b = 10 0 1 2
      

Return value

Converted value.

Variable long (variable v)

Casts a value to the long type.

Arguments

  • variable v - Target value. Can be of the following types:
    • int
    • long
    • float
    • double
    • string - its first non-whitespace characters should form a floating point number. Additional characters after it will be ignored. For example:
      Source code (UnigineScript)
      long a = long(string("8757656")); // a = 8757656
      long b = long(string("34.5"));    // b = 34
      long c = long(string("3 42"));    // c = 3
      

Return value

Converted value.

variable mat4 (float x, float y, float z)

Casts values to the mat4 type, returning a translation matrix.

Arguments

  • float x - X component of the translation vector.
  • float y - Y component of the translation vector.
  • float z - Z component of the translation vector.

Return value

Translation matrix.

Examples

Source code (UnigineScript)
mat4 a;
a = mat4(1,2,3);
/*	translation matrix:
1 0 0 1
0 1 0 2
0 0 1 3
0 0 0 1
*/

variable mat4 (float x, float y, float z, float angle)

Casts values to the mat4 type, returning a rotation matrix.

Arguments

  • float x - X component of the rotation axis.
  • float y - Y component of the rotation axis.
  • float z - Z component of the rotation axis.
  • float angle - Rotation angle in degrees.

Return value

Rotation matrix.

Examples

Source code (UnigineScript)
mat4 a;
a = mat4(1,0,0,45);
/*	rotation matrix:
1 0 0 1
0 0.7 -0.7 0
0 0.7 0.7 0
0 0 0 1
*/

variable mat4 (variable v)

Casts a value to the mat4 type.

Arguments

  • variable v - Target value. Can be of the following types:
    • int (all elements of the matrix will be equal to the argument)
    • long
    • float
    • double
    • vec3 (see translate() function)
    • dvec3 (see translate() function)
    • mat4
    • dmat4
    • quat
    • string — it should contain 16 floating point values separated with whitespace characters, for example:
      Source code (UnigineScript)
      mat4 a = mat4(string("1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1"));
      mat4 b = mat4(string("1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 875765"));
      /*	a and b will be identical matrices in the result:
      1 0 0 0
      0 1 0 0
      0 0 1 0
      0 0 0 1
      */
      

Return value

Converted value.

Variable mat4 (variable v1, variable v2)

Casts values to the mat4 type, returning a rotation matrix. The casted values can be of the following types:
  • Roation axis and rotation angle: vec3 or dvec3 as the first argument and float as a second one.
  • Roatation and position: quat as the first argument and vec3 or dvec3 as a second one.

Arguments

  • variable v1 - Rotation axis (vec3, dvec3) or rotation (quat).
  • variable v2 - Rotation angle in degrees (float) if the first argument is vec3 or dvec3 or position (vec3 or dvec3) if the first argument is quat.

Return value

Rotation matrix.

Examples

Source code (UnigineScript)
mat4 a;
a = mat4(vec3(1,0,0),45);
/*	rotation matrix:
1 0 0 1
0 0.7 -0.7 0
0 0.7 0.7 0
0 0 0 1
*/

Variable quat (float roll, float pitch, float yaw)

Casts values to the quat type, returning a rotation description.

Arguments

  • float roll - Roll component of the rotation.
  • float pitch - Pitch component of the rotation.
  • float yaw - Yaw component of the rotation.

Return value

Converted value representing a rotation.

variable quat (float x, float y, float z, float angle)

Casts values to the quat type, returning a rotation description.

Arguments

  • float x - X component of the rotation axis.
  • float y - Y component of the rotation axis.
  • float z - Z component of the rotation axis.
  • float angle - Rotation angle in degrees.

Return value

Converted value representing a rotation.

variable quat (variable v)

Casts a value to the quat type.

Arguments

  • variable v - Target value. Can be of the following types:
    • mat4
    • dmat4
    • quat
    • string — it should contain 4 floating point numbers separated with whitespace characters, for example:
      Source code (UnigineScript)
      quat a = quat(string("0.0 0.0 0.0 1.0"));     // a = 0.0 0.0 0.0 1.0
      quat b = quat(string("2.5 character 2 2 564")); // a = 2.5 0.0 2.0 2.0
      

Return value

Converted value.

Variable quat (variable axis, float angle)

Casts values to the quat type, returning a rotation description.

Arguments

  • variable axis - Rotation axis (vec3 or dvec3).
  • float angle - Rotation angle in degrees.

Return value

Converted value representing a rotation.

variable string (variable v)

Casts a value to the string type.

Arguments

  • variable v - Target value. Can be of the following types:
    • int
    • long
    • float
    • double
    • vec3
    • vec4
    • dvec3
    • dvec4
    • mat4 (will be written in the column-major order)
    • dmat4 (will be written in the column-major order)
    • quat
    • string

Return value

String representation of the target value.

Examples

Source code (UnigineScript)
string c = string(vec3(1,2,3));   // c = "1 2 3"
string d = string(vec4(1,2,3,4)); // d = "1 2 3 4"
string e = string(quat(1,2,3,4)); // e = "0.00932728 0.0186546 0.0279819 0.999391"
string f = string(mat4(1,2,3));   // f = "1 0 0 0 0 1 0 0 0 0 1 0 1 2 3 1"
// the last row of dmat4 is not stored and is always equal to "0 0 0 1"
string g = string(dmat4("1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16")); // g = "1 2 3 0 5 6 7 0 9 10 11 0 13 14 15 1"

variable vec3 (float x, float y, float z)

Casts values to the vec3 type.

Arguments

  • float x - X component of the vector.
  • float y - Y component of the vector.
  • float z - Z component of the vector.

Return value

Converted value.

variable vec3 (variable v)

Casts a value to the vec3 type.

Arguments

  • variable v - Target value. Can be of the following types:
    • int (all components will be equal to the argument)
    • long
    • float
    • double
    • vec3
    • vec4 (w component of the vector will be omitted)
    • dvec3
    • dvec4 (w component of the vector will be omitted)
    • ivec3
    • string - it should contain 3 floating point numbers separated with whitespace characters, for example:
      Source code (UnigineScript)
      vec3 a = vec3(string("1.5 1.5 -0.676"));         // a = 1.5 1.5 -0.676
      vec3 b = vec3(string("10.5f character 1 78.7")); // b = 10.5 0.0 1.0
      

Return value

Converted value.

variable vec4 (float x, float y, float z, float w)

Casts values to the vec4 type.

Arguments

  • float x - X component of the vector.
  • float y - Y component of the vector.
  • float z - Z component of the vector.
  • float w - W component of the vector.

Return value

Converted value.

variable vec4 (variable v)

Casts a value to the vec4 type.

Arguments

  • variable v - Target value. Can be of the following types:
    • int (all components of the vector will be equal to the argument)
    • long
    • float
    • double
    • vec3 (w component of the vector will be equal to 1)
    • vec4
    • dvec3 (w component of the vector will be equal to 1)
    • dvec4
    • ivec4
    • string — it should contain 4 floating point numbers separated with whitespace characters, for example:
      Source code (UnigineScript)
      vec4 a = vec4(string("0.5 -0.5 7456.0"));            // a = 0.5 0.5 -0.5 7456.0
      vec4 b = vec4(string("10.5f character 1 2 856.02")); // b = 10.5 0.0 1.0 2.0
      

Return value

Converted value.

Variable vec4 (variable Variable, float w)

Casts values to the vec4 type.

Arguments

  • variable Variable - Vector with the first three components (either vec3 or dvec3).
  • float w - W component of the vector.

Return value

Converted value.
Last update: 2017-07-03
Build: ()