naev 0.12.5
nlua_transform.c File Reference

Handles transforms. More...

#include "nlua_transform.h"
#include "nluadef.h"
Include dependency graph for nlua_transform.c:

Go to the source code of this file.

Functions

static int transformL_tostring (lua_State *L)
 Gets a string representing the transform.
static int transformL_eq (lua_State *L)
 Compares two transforms to see if they are the same.
static int transformL_new (lua_State *L)
 Creates a new identity transform.Gets a transform.
static int transformL_mul (lua_State *L)
 Multiplies two transforms (A*B).
static int transformL_get (lua_State *L)
 Gets all the values of the transform.
static int transformL_set (lua_State *L)
 Sets an element of a transform.
static int transformL_scale (lua_State *L)
 Applies scaling to a transform.
static int transformL_translate (lua_State *L)
 Applies translation to a transform.
static int transformL_rotate2d (lua_State *L)
 Applies a 2D rotation (along Z-axis) to a transform.
static int transformL_ortho (lua_State *L)
 Creates an orthogonal matrix.
static int transformL_applyPoint (lua_State *L)
 Applies a transformation to a point.
static int transformL_applyDim (lua_State *L)
 Applies a transformation to a dimension.
int nlua_loadTransform (nlua_env env)
 Loads the transform library.
mat4lua_totransform (lua_State *L, int ind)
 Lua bindings to interact with transforms.
mat4luaL_checktransform (lua_State *L, int ind)
 Gets transform at index or raises error if there is no transform at index.
mat4lua_pushtransform (lua_State *L, mat4 transform)
 Pushes a transform on the stack.
int lua_istransform (lua_State *L, int ind)
 Checks to see if ind is a transform.

Variables

static const luaL_Reg transformL_methods []

Detailed Description

Handles transforms.

Definition in file nlua_transform.c.

Function Documentation

◆ lua_istransform()

int lua_istransform ( lua_State * L,
int ind )

Checks to see if ind is a transform.

Parameters
LLua state to check.
indIndex position to check.
Returns
1 if ind is a transform.

Definition at line 113 of file nlua_transform.c.

◆ lua_pushtransform()

mat4 * lua_pushtransform ( lua_State * L,
mat4 transform )

Pushes a transform on the stack.

Parameters
LLua state to push transform into.
transformTransform to push.
Returns
Newly pushed transform.

Definition at line 98 of file nlua_transform.c.

◆ lua_totransform()

mat4 * lua_totransform ( lua_State * L,
int ind )

Lua bindings to interact with transforms.

Lua module: transform

Gets transform at index.

Parameters
LLua state to get transform from.
indIndex position to find the transform.
Returns
Transform found at the index in the state.

Definition at line 72 of file nlua_transform.c.

◆ luaL_checktransform()

mat4 * luaL_checktransform ( lua_State * L,
int ind )

Gets transform at index or raises error if there is no transform at index.

Parameters
LLua state to get transform from.
indIndex position to find transform.
Returns
Transform found at the index in the state.

Definition at line 84 of file nlua_transform.c.

◆ nlua_loadTransform()

int nlua_loadTransform ( nlua_env env)

Loads the transform library.

Parameters
envEnvironment to load transform library into.
Returns
0 on success.

Definition at line 54 of file nlua_transform.c.

◆ transformL_applyDim()

int transformL_applyDim ( lua_State * L)
static

Applies a transformation to a dimension.

Note
This is similar to Transform.applyPoint, except the translation is not applied.

Lua function parameter: Transform T Transform to apply. Lua function parameter: number x Dimension X-coordinate. Lua function parameter: number y Dimension Y-coordinate. Lua function parameter: number z Dimension Z-coordinate. Lua return parameter: number New X coordinate. Lua return parameter: number New Y coordinate. Lua return parameter: number New Z coordinate.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: applyDim

Definition at line 379 of file nlua_transform.c.

◆ transformL_applyPoint()

int transformL_applyPoint ( lua_State * L)
static

Applies a transformation to a point.

Lua function parameter: Transform T Transform to apply. Lua function parameter: number x Point X-coordinate. Lua function parameter: number y Point Y-coordinate. Lua function parameter: number z Point Z-coordinate. Lua return parameter: number New X coordinate. Lua return parameter: number New Y coordinate. Lua return parameter: number New Z coordinate.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: applyPoint

Definition at line 346 of file nlua_transform.c.

◆ transformL_eq()

int transformL_eq ( lua_State * L)
static

Compares two transforms to see if they are the same.

Lua function parameter: Transform t1 Transform 1 to compare. Lua function parameter: Transform t2 Transform 2 to compare. Lua return parameter: boolean true if both transforms are the same.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: __eq

Definition at line 153 of file nlua_transform.c.

◆ transformL_get()

int transformL_get ( lua_State * L)
static

Gets all the values of the transform.

Note, this returns in column-major.

Lua function parameter: Transform T Transform te get parameters of. Lua return parameter: table 2D table containing all the values of the transform.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: get

Definition at line 204 of file nlua_transform.c.

◆ transformL_mul()

int transformL_mul ( lua_State * L)
static

Multiplies two transforms (A*B).

Lua function parameter: Transform A First element to multiply. Lua function parameter: Transform B Second element to multiply. Lua return parameter: Transform Result of multiplication.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: __mul

Definition at line 185 of file nlua_transform.c.

◆ transformL_new()

int transformL_new ( lua_State * L)
static

Creates a new identity transform.Gets a transform.

Lua return parameter: Transform A new transform corresponding to an identity matrix.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: new

Definition at line 167 of file nlua_transform.c.

◆ transformL_ortho()

int transformL_ortho ( lua_State * L)
static

Creates an orthogonal matrix.

Lua function parameter: number left Left value. Lua function parameter: number right Right value. Lua function parameter: number bottom Bottom value. Lua function parameter: number top Top value. Lua function parameter: number nearVal value. Lua function parameter: number farVal value. Lua return parameter: Transform A new transformation.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: translate

Definition at line 321 of file nlua_transform.c.

◆ transformL_rotate2d()

int transformL_rotate2d ( lua_State * L)
static

Applies a 2D rotation (along Z-axis) to a transform.

Lua function parameter: Transform T Transform to apply rotation to. Lua function parameter: number angle Angle to rotate (radians).

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: rotate2d

Definition at line 299 of file nlua_transform.c.

◆ transformL_scale()

int transformL_scale ( lua_State * L)
static

Applies scaling to a transform.

Lua function parameter: Transform T Transform to apply scaling to. Lua function parameter: number x X-axis scaling. Lua function parameter: number y Y-axis scaling. Lua function parameter: number z Z-axis scaling. Lua return parameter: Transform A new transformation.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: scale

Definition at line 258 of file nlua_transform.c.

◆ transformL_set()

int transformL_set ( lua_State * L)
static

Sets an element of a transform.

Lua function parameter: Transform T Transform to set element of. Lua function parameter: number i Column to set. Lua function parameter: number j Row to set. Lua function parameter: number v Value to set to.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: set

Definition at line 228 of file nlua_transform.c.

◆ transformL_tostring()

int transformL_tostring ( lua_State * L)
static

Gets a string representing the transform.

Lua function parameter: Transform t Transform to get string of. Lua return parameter: string String corresponding to the transform.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: __tostring

Definition at line 136 of file nlua_transform.c.

◆ transformL_translate()

int transformL_translate ( lua_State * L)
static

Applies translation to a transform.

Lua function parameter: Transform T Transform to apply translation to. Lua function parameter: number x X-axis translation. Lua function parameter: number y Y-axis translation. Lua function parameter: number z Z-axis translation. Lua return parameter: Transform A new transformation.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: translate

Definition at line 280 of file nlua_transform.c.

Variable Documentation

◆ transformL_methods

const luaL_Reg transformL_methods[]
static
Initial value:
= {
{ "__tostring", transformL_tostring },
{ "__eq", transformL_eq },
{ "__mul", transformL_mul },
{ "get", transformL_get },
{ "set", transformL_set },
{ "new", transformL_new },
{ "scale", transformL_scale },
{ "translate", transformL_translate },
{ "rotate2d", transformL_rotate2d },
{ "ortho", transformL_ortho },
{ "applyPoint", transformL_applyPoint },
{ "applyDim", transformL_applyDim },
{ 0, 0 } }
static int transformL_applyDim(lua_State *L)
Applies a transformation to a dimension.
static int transformL_scale(lua_State *L)
Applies scaling to a transform.
static int transformL_applyPoint(lua_State *L)
Applies a transformation to a point.
static int transformL_tostring(lua_State *L)
Gets a string representing the transform.
static int transformL_mul(lua_State *L)
Multiplies two transforms (A*B).
static int transformL_rotate2d(lua_State *L)
Applies a 2D rotation (along Z-axis) to a transform.
static int transformL_ortho(lua_State *L)
Creates an orthogonal matrix.
static int transformL_new(lua_State *L)
Creates a new identity transform.Gets a transform.
static int transformL_set(lua_State *L)
Sets an element of a transform.
static int transformL_translate(lua_State *L)
Applies translation to a transform.
static int transformL_get(lua_State *L)
Gets all the values of the transform.
static int transformL_eq(lua_State *L)
Compares two transforms to see if they are the same.

Transform metatable methods.

Definition at line 33 of file nlua_transform.c.