add mat4.look_at(...)
This commit is contained in:
@@ -115,6 +115,15 @@ mat4.decompose(m: matrix)
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Look at point - *mat4.look_at(...)*
|
||||||
|
|
||||||
|
```lua
|
||||||
|
-- creates a view matrix from the 'eye' point to the 'center' point with up vector specified
|
||||||
|
mat4.look_at(eye: vec3, center: vec3, up: vec3)
|
||||||
|
-- writes the view matrix to dst
|
||||||
|
mat4.look_at(eye: vec3, center: vec3, up: vec3, dst: matrix)
|
||||||
|
```
|
||||||
|
|
||||||
## Casting to string - *mat4.tostring(...)*
|
## Casting to string - *mat4.tostring(...)*
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
|
|||||||
@@ -115,6 +115,15 @@ mat4.decompose(m: matrix)
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Отслеживание точки *mat4.look_at(...)*
|
||||||
|
|
||||||
|
```lua
|
||||||
|
-- cоздает матрицу вида с точки 'eye' на точку 'center', где вектор 'up' определяет верх.
|
||||||
|
mat4.look_at(eye: vec3, center: vec3, up: vec3)
|
||||||
|
-- записывает матрицу вида в dst
|
||||||
|
mat4.look_at(eye: vec3, center: vec3, up: vec3, dst: matrix)
|
||||||
|
```
|
||||||
|
|
||||||
## Перевод в строку - *mat4.tostring(...)*
|
## Перевод в строку - *mat4.tostring(...)*
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
|
|||||||
@@ -211,6 +211,22 @@ static int l_decompose(lua::State* L) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int l_look_at(lua::State* L) {
|
||||||
|
int argc = lua::gettop(L);
|
||||||
|
if (argc != 3 && argc != 4) {
|
||||||
|
throw std::runtime_error("invalid arguments number (3 or 4 expected)");
|
||||||
|
}
|
||||||
|
auto eye = lua::tovec<3>(L, 1);
|
||||||
|
auto center = lua::tovec<3>(L, 2);
|
||||||
|
auto up = lua::tovec<3>(L, 3);
|
||||||
|
|
||||||
|
if (argc == 3) {
|
||||||
|
return lua::pushmat4(L, glm::lookAt(eye, center, up));
|
||||||
|
} else {
|
||||||
|
return lua::setmat4(L, 4, glm::lookAt(eye, center, up));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int l_tostring(lua::State* L) {
|
static int l_tostring(lua::State* L) {
|
||||||
auto matrix = lua::tomat4(L, 1);
|
auto matrix = lua::tomat4(L, 1);
|
||||||
bool multiline = lua::toboolean(L, 2);
|
bool multiline = lua::toboolean(L, 2);
|
||||||
@@ -249,6 +265,7 @@ const luaL_Reg mat4lib [] = {
|
|||||||
{"transpose", lua::wrap<l_transpose>},
|
{"transpose", lua::wrap<l_transpose>},
|
||||||
{"determinant", lua::wrap<l_determinant>},
|
{"determinant", lua::wrap<l_determinant>},
|
||||||
{"decompose", lua::wrap<l_decompose>},
|
{"decompose", lua::wrap<l_decompose>},
|
||||||
|
{"look_at", lua::wrap<l_look_at>},
|
||||||
{"tostring", lua::wrap<l_tostring>},
|
{"tostring", lua::wrap<l_tostring>},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user