MCPcopy Create free account
hub / github.com/defold/defold / Matrix4_Translation

Function Matrix4_Translation

engine/script/src/script_vmath.cpp:1712–1734  ·  view source on GitHub ↗

creates a translation matrix from a position vector * The resulting matrix describes a translation of a point * in euclidean space. * * @name vmath.matrix4_translation * @param position [type:vector3|vector4] position vector to create matrix from * @return m [type:matrix4] matrix from the supplied position vector * @examples * * ```lua * -- Set cam

Source from the content-addressed store, hash-verified

1710 * ```
1711 */
1712 static int Matrix4_Translation(lua_State* L)
1713 {
1714 void* argument = 0;
1715 const ScriptUserType v_type = CheckUserData(L, 1, &argument);
1716
1717 if (v_type == SCRIPT_TYPE_VECTOR3)
1718 {
1719 const Vector3* t1 = (const Vector3*)argument;
1720 PushMatrix4(L, Matrix4::translation(*t1));
1721 }
1722 else if (v_type == SCRIPT_TYPE_VECTOR4)
1723 {
1724 const Vector4* t1 = (const Vector4*)argument;
1725 PushMatrix4(L, Matrix4::translation(t1->getXYZ()));
1726 }
1727 else
1728 {
1729 return luaL_error(L, "%s.%s accepts (%s|%s) as arguments.", SCRIPT_LIB_NAME, "matrix4_translation",
1730 SCRIPT_TYPE_NAME_VECTOR3, SCRIPT_TYPE_NAME_VECTOR4);
1731 }
1732
1733 return 1;
1734 }
1735
1736 /*# calculates the inverse matrix.
1737 * The resulting matrix is the inverse of the supplied matrix.

Callers

nothing calls this directly

Calls 4

CheckUserDataFunction · 0.85
PushMatrix4Function · 0.85
luaL_errorFunction · 0.85
getXYZMethod · 0.45

Tested by

no test coverage detected