Description
The goal of this library is to provide the mathematical objects commonly used in games:
- all values have 32 bit floating point type unless otherwise noted
- vec2, vec3, vec4 (2,3 and 4 dimension vectors)
- mat4 (4x4 matrix)
- aabb2 (2D axis-aligned bounding box)
- color (red, green, blue, alpha values)
- floatarray (array of floating point values)
The library is compiled to a 'sgsxgmath' shared library so it can be included this way (assuming that, on Linux and similar systems, LD_LIBRARY_PATH is set correctly):
include "sgsxgmath";
It is extremely important that only one instance of this library is loaded in the application for constant sharing to enable object interface recognition.
SGScript API
Objects:
Functions:
- vec2 - create a vec2 object
- vec2_dot - return dot product of two 2D vectors
- vec3 - create a vec3 object
- vec3_dot - return dot product of two 3D vectors
- vec3_cross - return cross product of two 3D vectors
- vec4 - create a vec4 object
- vec4_dot - return dot product of two 4D vectors
- aabb2 - create a 2D AABB from 4 real values
- aabb2v - create a 2D AABB from 2 2D vectors
- aabb2_intersect - intersect two 2D AABB values
- color
- mat4
- floatarray - create floatarray from array/list of int/real values
- floatarray_buffer - create 0-initialized floatarray
- vec2array - create floatarray from array/list of int/real/vec2 values
- vec3array - create floatarray from array/list of int/real/vec3 values
- vec4array - create floatarray from array/list of int/real/vec4 values
- floatarray_from_*_buffer - create floatarray from byte buffer
vec2 [object]
- methods
- rotate - return vector, rotated by specified angle
- read-only properties
- [real] length
- [real] length_squared
- [vec2] normalized - return a vector with length = 1 if possible, length = 0 if too short
- [vec2] perp - returns vec2(-y,x) - 90 degree clockwise vector
- [vec2] perp2 - returns vec2(y,-x) - 90 degree counter-clockwise vector
- [int] size - returns 2 - the number of components in this vector
- read/write properties
- [real] x
- [real] y
- [real] angle
- overloaded operators
+
- adds two vec2/real values
-
- subtracts two vec2/real values
*
- multiplies two vec2/real values
/
- divides two vec2/real values
%
- returns modulo of two vec2/real values
- comparison between vec2 values: first by X, then by Y
- unary
-
- returns negated vec2
- other features:
- cloning support
- serialization support
- GC-safe
- indexing support for indices 0 - 1: returns/sets the specified subvalue
- tostring, dump = "vec2(<x>;<y>)"
vec2.rotate [method]
vec2.rotate( real angle )
return vec2, rotated by angle in radians
vec2 [function]
vec2( real x[, real y ])
create a vec2 value from 1 - 2 real values
- if only one argument is given, it is used for both
x
and y
vec2_dot [function]
vec2_dot( vec2 v1, vec2 v2 )
return the dot product of both vectors
- returns
v1.x v2.x + v1.y v2.y
vec3 [object]
- read-only properties
- [real] length
- [real] length_squared
- [vec3] normalized - return a vector with length = 1 if possible, length = 0 if too short
- [int] size - returns 3 - the number of components in this vector
- read/write properties
- [real] x
- [real] y
- [real] z
- overloaded operators
+
- adds two vec3/real values
-
- subtracts two vec3/real values
*
- multiplies two vec3/real values
/
- divides two vec3/real values
%
- returns modulo of two vec3/real values
- comparison between vec3 values: first by X, then by Y, then by Z
- unary
-
- returns negated vec3
- other features:
- cloning support
- serialization support
- GC-safe
- indexing support for indices 0 - 2: returns/sets the specified subvalue
- tostring, dump = "vec3(<x>;<y>;<z>)"
vec3 [function]
vec3( real x[, real y[, real z ]])
create a vec3 value from 1 or 3 real values
- if only one argument is given, it is used for
x
, y
and z
vec3_dot [function]
vec3_dot( vec3 v1, vec3 v2 )
return the dot product of both vectors
- returns
v1.x v2.x + v1.y v2.y + v1.z * v2.z
vec3_cross [function]
vec3_cross( vec3 v1, vec3 v2 )
return the cross product of both vectors
- returns
vec3( v1.y v2.z - v1.z v2.y, v1.z v2.x - v1.x v2.z, v1.x v2.y - v1.y v2.x )
vec4 [object]
- read-only properties
- [real] length
- [real] length_squared
- [vec4] normalized - return a vector with length = 1 if possible, length = 0 if too short
- [int] size - returns 4 - the number of components in this vector
- read/write properties
- [real] x
- [real] y
- [real] z
- [real] w
- overloaded operators
+
- adds two vec4/real values
-
- subtracts two vec4/real values
*
- multiplies two vec4/real values
/
- divides two vec4/real values
%
- returns modulo of two vec4/real values
- comparison between vec4 values: first by X, then by Y, then by Z, then by W
- unary
-
- returns negated vec4
- other features:
- cloning support
- serialization support
- GC-safe
- indexing support for indices 0 - 3: returns/sets the specified subvalue
- tostring, dump = "vec4(<x>;<y>;<z>;<w>)"
vec4 [function]
vec4( real x[, real y[, real z[, real w ]]])
create a vec4 value from 1, 2 or 4 real values
- if only one argument is given, it is used for
x
, y
, z
and w
- if two arguments are given, use argument 1 for
x
, y
and z
; argument 2 for w
vec4_dot [function]
vec4_dot( vec4 v1, vec4 v2 )
return the dot product of both vectors
- returns
v1.x v2.x + v1.y v2.y + v1.z v2.z + v1.w v2.w
aabb2 [object]
In this object, assume 1 = min and 2 = max.
- methods
- expand - include other vec2/aabb2 items in current AABB
- read-only properties
- [real] width -- x2 - x1
- [real] height -- y2 - y1
- [vec2] center -- (p1 + p2) / 2
- [real] area -- width * height
- [bool] valid -- returns if x1 <= x2 and y1 <= y2
- read/write properties
- [real] x1
- [real] y1
- [real] x2
- [real] y2
- [vec2] p1
- [vec2] p2
- overloaded operators
- comparison between aabb2 values: first by X1, then by Y1, then by X2, then by Y2
- other features:
- cloning support
- serialization support
- GC-safe
- tostring, dump = "aabb2(<x1>;<y1> - <x2>;<y2>)"
aabb2.expand( ... ) [function]
aabb2.expand( ... )
include other vec2/aabb2 items in current AABB
aabb2 [function]
aabb2( real x1, real y1, real x2, real y2 )
create a 2D AABB object from 4 real values
aabb2v [function]
aabb2v( vec2 p1, vec2 p2 )
create a 2D AABB object from 2 vec2 values
aabb2_intersect [function]
aabb2_intersect( aabb2 bb1, aabb2 bb2 )
check if two AABBs intersect
color [object]
- read-only properties
- [int] size - returns 4 - the number of components in this vector
- read/write properties
- [real] r
- [real] g
- [real] b
- [real] a
- overloaded operators
+
- adds two color/real values
-
- subtracts two color/real values
*
- multiplies two color/real values
/
- divides two color/real values
%
- returns modulo of two color/real values
- comparison between color values: first by R, then by G, then by B, then by A
- unary
-
- returns negated color
- other features:
- cloning support
- serialization support
- GC-safe
- indexing support for indices 0 - 3: returns/sets the specified subvalue
- tostring, dump = "color(<r>;<g>;<b>;<a>)"
color [function]
color( real r[, real g[, real b[, real a ]]])
create a color value from 1 to 4 real values
- if one argument is given, it is used for all components
- if two arguments are given, argument 1 is used for R, G and B, argument 2 is used for A
- if three arguments are given, they're used for R, G and B; 1 is the value of A
mat4 [object]
A column-major matrix
- methods
- read-only properties
- [int] size - returns 16 - the number of components in this vector
- read/write properties
- overloaded operators
- comparison between subvalues: column-major subvalue order
- other features:
- cloning support
- serialization support
- GC-safe
- indexing support for indices 0 - 15: returns/sets the specified subvalue
- tostring = "mat4"
- dump:
mat4
(
<m00> <m10> <m20> <m30>
<m01> <m11> <m21> <m31>
<m02> <m12> <m22> <m32>
<m03> <m13> <m23> <m33>
)
mat4.identity [method]
mat4.identity()
set the matrix to identity
mat4.multiply [method]
mat4.multiply( mat4 m )
multiply this matrix and another matrix, putting the other matrix on the right side of multiplication
mat4.multiply_left [method]
mat4.multiply_left( mat4 m )
multiply this matrix and another matrix, putting the other matrix on the left side of multiplication
mat4.multiply2 [method]
mat4.multiply2( mat4 m1, mat4 m2 )
multiply two matrices into this matrix
mat4.transpose [method]
mat4.transpose()
transpose this matrix into itself
mat4.transpose_from [method]
mat4.transpose_from( mat4 m )
transpose another matrix into this matrix
mat4.invert [method]
mat4.invert()
invert this matrix into itself, return if successful
mat4.invert_from [method]
mat4.invert_from( mat4 m )
invert another matrix into this matrix
mat4.translate [method]
mat4.translate( real x, real y, real z[, bool reset ])
generate a translation matrix and multiply or set it to this matrix
- if
reset
is true, the generated matrix is directly set to this matrix
- otherwise, generated matrix is right-multiplied to this matrix
- if current matrix is an identity matrix,
reset
has no effect
mat4.translate_v3 [method]
mat4.translate_v3( vec3 v[, bool reset ])
generate a translation matrix and multiply or set it to this matrix
- if
reset
is true, the generated matrix is directly set to this matrix
- otherwise, generated matrix is right-multiplied to this matrix
- if current matrix is an identity matrix,
reset
has no effect
mat4.rotateX [method]
mat4.rotateX( real a[, bool reset ])
generate a rotation matrix (rotation around X axis) and multiply or set it to this matrix
- if
reset
is true, the generated matrix is directly set to this matrix
- otherwise, generated matrix is right-multiplied to this matrix
- if current matrix is an identity matrix,
reset
has no effect
mat4.rotateY [method]
mat4.rotateY( real a[, bool reset ])
generate a rotation matrix (rotation around Y axis) and multiply or set it to this matrix
- if
reset
is true, the generated matrix is directly set to this matrix
- otherwise, generated matrix is right-multiplied to this matrix
- if current matrix is an identity matrix,
reset
has no effect
mat4.rotateZ [method]
mat4.rotateZ( real a[, bool reset ])
generate a rotation matrix (rotation around Z axis) and multiply or set it to this matrix
- if
reset
is true, the generated matrix is directly set to this matrix
- otherwise, generated matrix is right-multiplied to this matrix
- if current matrix is an identity matrix,
reset
has no effect
mat4.rotate_axis_angle [method]
mat4.rotate_axis_angle( real x, real y, real z, real a[, bool reset ])
generate a rotation matrix (rotation around specified axis) and multiply or set it to this matrix
- if
reset
is true, the generated matrix is directly set to this matrix
- otherwise, generated matrix is right-multiplied to this matrix
- if current matrix is an identity matrix,
reset
has no effect
mat4.rotate_axis_angle_v3 [method]
mat4.rotate_axis_angle( vec3 v, real a[, bool reset ])
generate a rotation matrix (rotation around specified axis) and multiply or set it to this matrix
- if
reset
is true, the generated matrix is directly set to this matrix
- otherwise, generated matrix is right-multiplied to this matrix
- if current matrix is an identity matrix,
reset
has no effect
mat4.scale [method]
mat4.scale( real x, real y, real z[, bool reset ])
generate a scale matrix and multiply or set it to this matrix
- if
reset
is true, the generated matrix is directly set to this matrix
- otherwise, generated matrix is right-multiplied to this matrix
- if current matrix is an identity matrix,
reset
has no effect
mat4.scale_v3 [method]
mat4.scale_v3( vec3 v[, bool reset ])
generate a scale matrix and multiply or set it to this matrix
- if
reset
is true, the generated matrix is directly set to this matrix
- otherwise, generated matrix is right-multiplied to this matrix
- if current matrix is an identity matrix,
reset
has no effect
mat4.transform [method]
mat4.transform( vec4 v )
multiply a 4D vector by this matrix
mat4.transform_pos [method]
mat4.transform_pos( vec3 v )
multiply a 3D position vector by this matrix
- multiply vec4( v.x, v.y, v.z, 1 ) by this matrix, return vec3( x / w, y / w, z / w )
mat4.transform_normal [method]
mat4.transform_normal( vec3 v )
multiply a 3D normal vector by this matrix
- multiply vec4( v.x, v.y, v.z, 0 ) by this matrix, return vec3( x, y, z )
mat4 [function]
mat4( mat4 m )
copy the matrix
mat4( vec4 row1, vec4 row2, vec4 row3[, vec4 row4 ])
create a matrix from 3 or 4 rows
mat4( real v[16] )
create a matrix from 16 real values
floatarray [object]
- methods
- clear - set all values to 0
- set1 - set all values to 1
- negate - negate all values
- assign - copy values from another source
- negate_from - copy negated values
- *[_assign] - combine values with arithmetic operations
- randbox - set values to random between two sources
- randext - set values to random around source 1 in the range of source 2
- multiply_add_assign - multiply two sources and add the result to this one
- lerp_to - linearly interpolate this source and another to the factor of the third one
- to_*_buffer - convert values to byte buffer, optionally scaling them
- read-only properties
- [int] size - returns array size - the number of values in this array
- [int] size2 - returns array size / 2 - the number of vec2 values in this array
- [int] size3 - returns array size / 3 - the number of vec3 values in this array
- [int] size4 - returns array size / 4 - the number of vec4 values in this array
- [int] size16 - returns array size / 16 - the number of mat4 values in this array
- other features:
- cloning support
- serialization support
- GC-safe
- indexing support for indices 0 - (size-1): returns/sets the specified subvalue
- tostring = "floatarray"
- dump: first 64 values, array formatting
floatarray data transformation methods
- 'source' type can take
int
, real
, vec2
, vec3
, vec4
, mat4
and floatarray
sources.
- source values are accessed, indexed by (i % source.size)
- function works on all values inside array
floatarray.*[_assign] (add|sub|mul|div|mod|pow) [methods]
floatarray.add( s1, s2 )
add values from two sources to this floatarray (this = s1 + s2)
floatarray.sub( s1, s2 )
subtract values from two sources to this floatarray (this = s1 - s2)
floatarray.mul( s1, s2 )
multiply values from two sources to this floatarray (this = s1 * s2)
floatarray.div( s1, s2 )
divide values from two sources to this floatarray (this = s1 / s2)
floatarray.mod( s1, s2 )
set modulo from two sources to this floatarray (this = s1 % s2)
floatarray.pow( s1, s2 )
set power of two sources to this floatarray (this = s1 ^ s2)
floatarray.add_assign( s1 )
add values from another source to floatarray (this = this + s1)
floatarray.sub_assign( s1 )
subtract values from another source to floatarray (this = this - s1)
floatarray.mul_assign( s1 )
subtract values from another source to floatarray (this = this * s1)
floatarray.div_assign( s1 )
subtract values from another source to floatarray (this = this / s1)
floatarray.mod_assign( s1 )
subtract values from another source to floatarray (this = this % s1)
floatarray.pow_assign( s1 )
subtract values from another source to floatarray (this = this ^ s1)
for more info, refer to this page: floatarray data transformation methods
floatarray.randbox [method]
floatarray.randbox( s1, s2 )
set values to random between two sources (this = lerp( s1, s2, randf() )
)
for more info, refer to this page: floatarray data transformation methods
floatarray.randext [method]
floatarray.randext( s1, s2 )
set values to random around source 1 in the range of source 2 (this = lerp( s1 - s2, s1 + s2, randf() )
)
for more info, refer to this page: floatarray data transformation methods
floatarray.multiply_add_assign [method]
floatarray.multiply_add_assign( s1, s2 )
multiply two sources and add the result to this one (this += s1 * s2
)
for more info, refer to this page: floatarray data transformation methods
floatarray.lerp_to [method]
floatarray.lerp_to( s1, s2 )
linearly interpolate this source and another to the factor of the third one (this = lerp( this, s1, s2 )
)
for more info, refer to this page: floatarray data transformation methods
floatarray.to_*_buffer [method]
floatarray.to_int8_buffer( real scale = 1 )
floatarray.to_int16_buffer( real scale = 1 )
floatarray.to_int32_buffer( real scale = 1 )
floatarray.to_int64_buffer( real scale = 1 )
floatarray.to_uint8_buffer( real scale = 1 )
floatarray.to_uint16_buffer( real scale = 1 )
floatarray.to_uint32_buffer( real scale = 1 )
floatarray.to_uint64_buffer( real scale = 1 )
floatarray.to_float32_buffer( real scale = 1 )
floatarray.to_float64_buffer( real scale = 1 )
create a byte buffer from floatarray contents, optionally scaling the values
floatarray_buffer [function]
floatarray_buffer( int size )
create a floatarray of the specified size, filled with zeroes
floatarray [function]
floatarray([ int/real v0, ... ])
create a floatarray from a list of int/real values
floatarray( array varr )
create a floatarray from an array of int/real values
vec2array [function]
vec2array([ int/real v0, ... ])
create a floatarray from a list of int/real values (must be a multiple of 2)
vec2array([ vec2 v0, ... ])
create a floatarray from a list of vec2 values
vec2array( array varr )
create a floatarray from an array of vec2 values
vec3array [function]
vec3array([ int/real v0, ... ])
create a floatarray from a list of int/real values (must be a multiple of 3)
vec3array([ vec3 v0, ... ])
create a floatarray from a list of vec3 values
vec3array( array varr )
create a floatarray from an array of vec3 values
vec4array [function]
vec4array([ int/real v0, ... ])
create a floatarray from a list of int/real values (must be a multiple of 4)
vec4array([ vec4 v0, ... ])
create a floatarray from a list of vec4 values
vec4array( array varr )
create a floatarray from an array of vec4 values
floatarray_from_*_buffer [function]
floatarray_from_int8_buffer( string buffer, scale = 1, stride = 1, offset = 0 )
floatarray_from_int16_buffer( string buffer, scale = 1, stride = 1, offset = 0 )
floatarray_from_int32_buffer( string buffer, scale = 1, stride = 1, offset = 0 )
floatarray_from_int64_buffer( string buffer, scale = 1, stride = 1, offset = 0 )
floatarray_from_uint8_buffer( string buffer, scale = 1, stride = 1, offset = 0 )
floatarray_from_uint16_buffer( string buffer, scale = 1, stride = 1, offset = 0 )
floatarray_from_uint32_buffer( string buffer, scale = 1, stride = 1, offset = 0 )
floatarray_from_uint64_buffer( string buffer, scale = 1, stride = 1, offset = 0 )
floatarray_from_float32_buffer( string buffer, scale = 1, stride = 1, offset = 0 )
floatarray_from_float64_buffer( string buffer, scale = 1, stride = 1, offset = 0 )
create a floatarray from byte buffer, optionally specifying scale, stride and offset to first value
ray_plane_intersect [function]
ray_plane_intersect( vec3 ray_pos, vec3 ray_dir, vec4 plane )
tests for an intersection between ray and plane, returning all relevant output data
- if ray is (near-)parallel to plane, false is returned
- otherwise, signed distance along ray and signed origin distance from plane are returned
- if signed distance along ray to plane is larger than 0, plane is in front of ray
- if signed distance from origin to plane is larger than 0, ray origin is in front of the plane
All SGScript objects (A-Z)
All SGScript functions (A-Z)
xgm_vtarray [struct]
xgm_vtarray
- properties:
- XGM_VT* data - array of floating point values
- sgs_SizeVal size - current size of array (current item count)
- sgs_SizeVal mem - max. size of array (capacity, allocated item count)
xgm_*_iface [interfaces]
sgs_ObjInterface xgm_vec2_iface[1]
interface for vec2 objects
sgs_ObjInterface xgm_vec3_iface[1]
interface for vec3 objects
sgs_ObjInterface xgm_vec4_iface[1]
interface for vec4 objects
sgs_ObjInterface xgm_aabb2_iface[1]
interface for aabb2 objects
sgs_ObjInterface xgm_color_iface[1]
interface for color objects
sgs_ObjInterface xgm_mat4_iface[1]
interface for mat4 objects
sgs_ObjInterface xgm_floatarr_iface[1]
interface for floatarray objects
sgs_Init* [functions]
void sgs_InitVec2( SGS_CTX, sgs_Variable* var, XGM_VT x, XGM_VT y )
void sgs_InitVec3( SGS_CTX, sgs_Variable* var, XGM_VT x, XGM_VT y, XGM_VT z )
void sgs_InitVec4( SGS_CTX, sgs_Variable* var, XGM_VT x, XGM_VT y, XGM_VT z, XGM_VT w )
void sgs_InitAABB2( SGS_CTX, sgs_Variable* var, XGM_VT x1, XGM_VT y1, XGM_VT x2, XGM_VT y2 )
void sgs_InitColor( SGS_CTX, sgs_Variable* var, XGM_VT r, XGM_VT g, XGM_VT b, XGM_VT a )
void sgs_InitMat4( SGS_CTX, sgs_Variable* var, const XGM_VT* v16f, int transpose )
void sgs_InitFloatArray( SGS_CTX, sgs_Variable* var, const XGM_VT* vfn, sgs_SizeVal size )
void sgs_InitVec2p( SGS_CTX, sgs_Variable* var, const XGM_VT* v2f )
void sgs_InitVec3p( SGS_CTX, sgs_Variable* var, const XGM_VT* v3f )
void sgs_InitVec4p( SGS_CTX, sgs_Variable* var, const XGM_VT* v4f )
void sgs_InitAABB2p( SGS_CTX, sgs_Variable* var, const XGM_VT* v4f )
void sgs_InitColorp( SGS_CTX, sgs_Variable* var, const XGM_VT* v4f )
void sgs_InitColorvp( SGS_CTX, sgs_Variable* var, const XGM_VT* vf, int numfloats )
initialize a variable of the right type to the specified arguments
Notes:
- v*f - array of the specified number of XGM_VT values
- sgs_InitColorvp accepts 0, 1, 2, 3 or 4 for
numfloats
- if 0: R, G, B, A = 0
- if 1: R, G, B, A = arg1
- if 2: R, G, B = arg1; A = arg2
- if 3: R = arg1; G = arg2; B = arg3; A = 1
- otherwise arguments are mapped to components sequentially
- the
p
postfix for functions means that function accepts arrays instead of plain values, if that's what the non -p function takes
sgs_Push* [functions]
void sgs_PushVec2( SGS_CTX, XGM_VT x, XGM_VT y )
void sgs_PushVec3( SGS_CTX, XGM_VT x, XGM_VT y, XGM_VT z )
void sgs_PushVec4( SGS_CTX, XGM_VT x, XGM_VT y, XGM_VT z, XGM_VT w )
void sgs_PushAABB2( SGS_CTX, XGM_VT x1, XGM_VT y1, XGM_VT x2, XGM_VT y2 )
void sgs_PushColor( SGS_CTX, XGM_VT r, XGM_VT g, XGM_VT b, XGM_VT a )
void sgs_PushMat4( SGS_CTX, const XGM_VT* v16f, int transpose )
void sgs_PushFloatArray( SGS_CTX, const XGM_VT* vfn, sgs_SizeVal size )
void sgs_PushVec2p( SGS_CTX, const XGM_VT* v2f )
void sgs_PushVec3p( SGS_CTX, const XGM_VT* v3f )
void sgs_PushVec4p( SGS_CTX, const XGM_VT* v4f )
void sgs_PushAABB2p( SGS_CTX, const XGM_VT* v4f )
void sgs_PushColorp( SGS_CTX, const XGM_VT* v4f )
void sgs_PushColorvp( SGS_CTX, const XGM_VT* vf, int numfloats )
push a new variable on stack of the right type, initialized to the specified arguments
For notes, refer to sgs_Init*
sgs_Parse* [functions]
SGSBOOL sgs_ParseVTP( SGS_CTX, sgs_Variable* var, XGM_VT* out )
SGSBOOL sgs_ParseVec2P( SGS_CTX, sgs_Variable* var, XGM_VT* v2f, int strict )
SGSBOOL sgs_ParseVec3P( SGS_CTX, sgs_Variable* var, XGM_VT* v3f, int strict )
SGSBOOL sgs_ParseVec4P( SGS_CTX, sgs_Variable* var, XGM_VT* v4f, int strict )
SGSBOOL sgs_ParseAABB2P( SGS_CTX, sgs_Variable* var, XGM_VT* v4f )
SGSBOOL sgs_ParseColorP( SGS_CTX, sgs_Variable* var, XGM_VT* v4f, int strict )
SGSBOOL sgs_ParseMat4P( SGS_CTX, sgs_Variable* var, XGM_VT* v16f )
SGSBOOL sgs_ParseFloatArrayP( SGS_CTX, sgs_Variable* var, XGM_VT** vfa, sgs_SizeVal* osz )
parse the specified variable to retrieve object data
SGSBOOL sgs_ParseVT( SGS_CTX, sgs_StkIdx item, XGM_VT* out )
SGSBOOL sgs_ParseVec2( SGS_CTX, sgs_StkIdx item, XGM_VT* v2f, int strict )
SGSBOOL sgs_ParseVec3( SGS_CTX, sgs_StkIdx item, XGM_VT* v3f, int strict )
SGSBOOL sgs_ParseVec4( SGS_CTX, sgs_StkIdx item, XGM_VT* v4f, int strict )
SGSBOOL sgs_ParseAABB2( SGS_CTX, sgs_StkIdx item, XGM_VT* v4f )
SGSBOOL sgs_ParseColor( SGS_CTX, sgs_StkIdx item, XGM_VT* v4f, int strict )
SGSBOOL sgs_ParseMat4( SGS_CTX, sgs_StkIdx item, XGM_VT* v16f )
SGSBOOL sgs_ParseFloatArray( SGS_CTX, sgs_StkIdx item, XGM_VT** vfa, sgs_SizeVal* osz )
parse the specified stack item to retrieve object data
strict
means that only the object of the specified type is allowed to be parsed
- otherwise, real values are parsed too
sgs_ArgCheck_* [functions]
int sgs_ArgCheck_Vec2( SGS_CTX, int argid, va_list* args, int flags )
int sgs_ArgCheck_Vec3( SGS_CTX, int argid, va_list* args, int flags )
int sgs_ArgCheck_Vec4( SGS_CTX, int argid, va_list* args, int flags )
int sgs_ArgCheck_AABB2( SGS_CTX, int argid, va_list* args, int flags )
int sgs_ArgCheck_Color( SGS_CTX, int argid, va_list* args, int flags )
int sgs_ArgCheck_Mat4( SGS_CTX, int argid, va_list* args, int flags )
int sgs_ArgCheck_FloatArray( SGS_CTX, int argid, va_list* args, int flags )
argument parsing functions for sgs_LoadArgs* function family
- variable argument list expectations:
- Vec2: XGM_VT[2] if output is enabled
- Vec3: XGM_VT[3] if output is enabled
- Vec4: XGM_VT[4] if output is enabled
- AABB2: XGM_VT[4] if output is enabled
- Color: XGM_VT[4] if output is enabled
- Mat4: XGM_VT[16] if output is enabled
- FloatArray: xgm_vtarray** if output is enabled
SGS_RETURN_* [functions]
SGS_RETURN_VEC2( XGM_VT x, XGM_VT y )
SGS_RETURN_VEC3( XGM_VT x, XGM_VT y, XGM_VT z )
SGS_RETURN_VEC4( XGM_VT x, XGM_VT y, XGM_VT z, XGM_VT w )
SGS_RETURN_AABB2( XGM_VT x1, XGM_VT y1, XGM_VT x2, XGM_VT y2 )
SGS_RETURN_COLOR( XGM_VT r, XGM_VT g, XGM_VT b, XGM_VT a )
SGS_RETURN_VEC2P( XGM_VT* v2f )
SGS_RETURN_VEC3P( XGM_VT* v3f )
SGS_RETURN_VEC4P( XGM_VT* v4f )
SGS_RETURN_AABB2P( XGM_VT* v4f )
SGS_RETURN_COLORP( XGM_VT* v4f )
SGS_RETURN_MAT4( XGM_VT* v16f )
push the specified value and return SGS_SUCCESS
- these macros are meant to be used in GETINDEX object interface functions
- assuming SGS_CTX (
sgs_Context* C
)
SGS_PARSE_* [functions]
SGS_PARSE_VEC2( outptr, strict )
SGS_PARSE_VEC3( outptr, strict )
SGS_PARSE_VEC4( outptr, strict )
SGS_PARSE_AABB2( outptr )
SGS_PARSE_COLOR( outptr, strict )
SGS_PARSE_MAT4( outptr )
parse input variable in a SETINDEX object interface function
outptr
requires the following data:
- VEC2: XGM_VT[2]
- VEC3: XGM_VT[3]
- VEC4: XGM_VT[4]
- AABB2: XGM_VT[4]
- COLOR: XGM_VT[4]
- MAT4: XGM_VT[16]
- assuming SGS_CTX (
sgs_Context* C
)
- assuming
sgs_Variable* val
(from SGS_ARGS_SETINDEXFUNC)