mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
Merge branch 'main' into physics-upgrade
This commit is contained in:
commit
1d4fb9bc07
9 changed files with 79 additions and 21 deletions
|
|
@ -78,14 +78,14 @@ Returns the id of all base packages (non-removeable)
|
|||
|
||||
```lua
|
||||
pack.get_info(packid: str) -> {
|
||||
id: str,
|
||||
title: str,
|
||||
creator: str,
|
||||
description: str,
|
||||
version: str,
|
||||
path: str,
|
||||
icon: str, -- not available in headless mode
|
||||
dependencies: optional strings array
|
||||
id: str,
|
||||
title: str,
|
||||
creator: str,
|
||||
description: str,
|
||||
version: str,
|
||||
path: str,
|
||||
icon: str, -- not available in headless mode
|
||||
dependencies: optional strings array
|
||||
}
|
||||
```
|
||||
|
||||
|
|
@ -95,6 +95,7 @@ Returns information about the pack (not necessarily installed).
|
|||
- `!` - required
|
||||
- `?` - optional
|
||||
- `~` - weak
|
||||
|
||||
for example `!teal`
|
||||
|
||||
To obtain information about multiple packs, use table of ids to avoid re-scanning:one
|
||||
|
|
|
|||
|
|
@ -213,9 +213,6 @@ Element must be in direct sub-element of *inventory*.
|
|||
## *slots-grid*
|
||||
|
||||
- `start-index` - inventory slot index of the first slot. Type: integer
|
||||
- `rows` - number of grid rows (unnecessary if *cols* and *count* specified). Type: integer
|
||||
- `cols` - number of grid columns (unnecessary if *rows* and *count* specified). Type: integer
|
||||
- `count` - total number of slots in grid (unnecessary if *rows* and *cols* specified). Type: integer
|
||||
- `interval` - visual slots interval. Type: number
|
||||
- `padding` - grid padding (not slots interval). Type: number. (*deprecated*)
|
||||
- `sharefunc` - Lua event called on <btn>LMB</btn> + <btn>Shift</btn>. Inventory id and slot index passed as arguments.
|
||||
|
|
@ -223,3 +220,8 @@ Element must be in direct sub-element of *inventory*.
|
|||
- `onrightclick` - Lua event called on <btn>RMB</btn> click. Inventory id and slot index passed as arguments.
|
||||
- `taking` - the ability to take an item from a slot.
|
||||
- `placing` - the ability to put an item in a slot.
|
||||
|
||||
Slots configuration (just specify two attributes):
|
||||
- `rows` - number of rows. Type: integer
|
||||
- `cols` - number of columns. Type: integer
|
||||
- `count` - total number of slots. Type: integer
|
||||
|
|
|
|||
|
|
@ -114,15 +114,29 @@ mat4.decompose(m: matrix)
|
|||
} или nil
|
||||
```
|
||||
|
||||
## Отслеживание точки *mat4.look_at(...)*
|
||||
## Отслеживание точки - *mat4.look_at(...)*
|
||||
|
||||
```lua
|
||||
-- cоздает матрицу вида с точки 'eye' на точку 'center', где вектор 'up' определяет верх.
|
||||
-- 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.perspective*
|
||||
|
||||
```lua
|
||||
-- возвращает расчитанную матрицу перспективы.
|
||||
-- параметр fov принимает значение вертикального поля зрения в градусах.
|
||||
-- параметр ratio задаёт отношение сторон (сторона X к стороне Y, пример: для монитора 800:600 отношение сторон равно 4 к 3, или 4 / 3).
|
||||
-- параметр near задаёт расстояние от камеры до плоскости Near.
|
||||
-- параметр far задаёт расстояние от камеры до плоскости Far.
|
||||
mat4.perspective(fov: number, ratio: number, near: number, far: number) -> mat4
|
||||
|
||||
-- расчитывает матрицу перспективы на основе переданных значений и записывает её в переменную dst.
|
||||
mat4.perspective(fov: number, ratio: number, near: number, far: number, dst: mat4) -> nil
|
||||
```
|
||||
|
||||
## Перевод в строку - *mat4.tostring(...)*
|
||||
|
||||
```lua
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ pack.get_info(packid: string) -> {
|
|||
- `!` - required
|
||||
- `?` - optional
|
||||
- `~` - weak
|
||||
|
||||
например `!teal`
|
||||
|
||||
Для получения информации о нескольких паках используйте таблицу id, чтобы не
|
||||
|
|
@ -101,4 +102,4 @@ pack.assemble(packids: table<string>) -> table<string>
|
|||
pack.request_writeable(packid: string, callback: function(string))
|
||||
```
|
||||
|
||||
Запрашивает у пользователя право на модификацию пака. При подтвержении новая точка входа будет передана в callback.
|
||||
Запрашивает у пользователя право на модификацию пака. При подтвержении новая точка входа будет передана в callback.
|
||||
|
|
|
|||
|
|
@ -2,22 +2,34 @@
|
|||
|
||||
Библиотека для работы с кватернионами.
|
||||
|
||||
## Кватернион из матрицы - *mat4.from_quat(...)*
|
||||
## Кватернион из матрицы - *quat.from_mat4(...)*
|
||||
|
||||
```lua
|
||||
-- создает кватернион на основе матрицы вращения
|
||||
-- создаёт кватернион на основе матрицы вращения
|
||||
quat.from_mat4(m: matrix) -> quat
|
||||
|
||||
-- записывает кватернион по матрице вращения в dst
|
||||
quat.from_mat4(m: matrix, dst: quat)
|
||||
```
|
||||
|
||||
## Кватернион из углов Эйлера - *quat.from_euler(...)*
|
||||
|
||||
```lua
|
||||
-- создаёт кватернион на основе вектора, содержащего углы Эйлера в порядке XYZ (pitch, yaw, roll)
|
||||
-- (значения углов строго в градусах)
|
||||
quat.from_euler(euler: vec3) -> quat
|
||||
|
||||
-- записывает кватернион в dst на основе вектора, содержащего углы Эйлера в порядке XYZ (pitch, yaw, roll)
|
||||
-- (значения углов строго в градусах)
|
||||
quat.from_euler(euler: vec3, dst: quat)
|
||||
```
|
||||
|
||||
## Сферическая линейная интерполяция - *quat.slerp(...)*
|
||||
|
||||
Интерполяция всегда выполняется по короткому пути, а вращение выполняется с постоянной скоростью.
|
||||
|
||||
```lua
|
||||
-- создает кватернион как интерполяцию между a и b,
|
||||
-- создаёт кватернион как интерполяцию между a и b,
|
||||
-- где t - фактор интерполяции
|
||||
quat.slerp(a: quat, b: quat, t: number) -> quat
|
||||
|
||||
|
|
@ -29,6 +41,6 @@ quat.slerp(a: quat, b: quat, t: number, dst: quat)
|
|||
## Перевод в строку - *quat.tostring(...)*
|
||||
|
||||
```lua
|
||||
-- возвращает строку представляющую содержимое кватерниона
|
||||
-- возвращает строку, представляющую содержимое кватерниона
|
||||
quat.tostring(q: quat) -> string
|
||||
```
|
||||
|
|
|
|||
|
|
@ -214,10 +214,8 @@
|
|||
## Сетка слотов - *slots-grid*
|
||||
|
||||
Элемент должен находиться внутри `inventory` элемента, без посредников.
|
||||
|
||||
- `start-index` - индекс первого слота
|
||||
- `rows` - число рядов (не указывается, если указано cols).
|
||||
- `cols` - число столбцов (не указывается, если указано rows).
|
||||
- `count` - общее число слотов (не указывается, если указаны rows и cols).
|
||||
- `interval` - интервал между слотами. Тип: число.
|
||||
- `padding` - отступ вокруг решетки слотов. Тип: число. (*атрибут будет удален*)
|
||||
- `sharefunc` - lua событие вызываемое при использовании ЛКМ + Shift. Передается id инвентаря и индекс слота
|
||||
|
|
@ -225,3 +223,8 @@
|
|||
- `onrightclick` - lua событие вызываемое при использовании ПКМ. Передается id инвентаря и индекс слота
|
||||
- `taking` - возможность взять предмет из слота.
|
||||
- `placing` - возможность положить предмет в слот.
|
||||
|
||||
Конфигурация слотов (достаточно указать два атрибута):
|
||||
- `rows` - число рядов. Тип: число.
|
||||
- `cols` - число столбцов. Тип: число.
|
||||
- `count` - общее число слотов. Тип: число.
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <cstdint>
|
||||
|
||||
class Engine;
|
||||
class World;
|
||||
|
|
|
|||
|
|
@ -229,6 +229,20 @@ static int l_look_at(lua::State* L) {
|
|||
}
|
||||
}
|
||||
|
||||
static int l_perspective(lua::State *L) {
|
||||
uint argc = lua::check_argc(L, 4, 5);
|
||||
|
||||
double fov = glm::radians(lua::tonumber(L, 1));
|
||||
double ratio = lua::tonumber(L, 2);
|
||||
double near = lua::tonumber(L, 3);
|
||||
double far = lua::tonumber(L, 4);
|
||||
|
||||
glm::mat4 mat = glm::perspective(fov, ratio, near, far);
|
||||
|
||||
if (argc == 5) return lua::setmat4(L, 5, mat);
|
||||
else return lua::pushmat4(L, mat);
|
||||
}
|
||||
|
||||
static int l_from_quat(lua::State* L) {
|
||||
uint argc = lua::check_argc(L, 1, 2);
|
||||
auto quat = lua::toquat(L, 1);
|
||||
|
|
@ -280,6 +294,7 @@ const luaL_Reg mat4lib[] = {
|
|||
{"determinant", lua::wrap<l_determinant>},
|
||||
{"decompose", lua::wrap<l_decompose>},
|
||||
{"look_at", lua::wrap<l_look_at>},
|
||||
{"perspective", lua::wrap<l_perspective>},
|
||||
{"from_quat", lua::wrap<l_from_quat>},
|
||||
{"tostring", lua::wrap<l_tostring>},
|
||||
{nullptr, nullptr}
|
||||
|
|
|
|||
|
|
@ -44,8 +44,17 @@ static int l_tostring(lua::State* L) {
|
|||
return lua::pushstring(L, ss.str());
|
||||
}
|
||||
|
||||
static int l_from_euler(lua::State *L) {
|
||||
uint argc = lua::check_argc(L, 1, 2);
|
||||
glm::vec3 euler = glm::radians(lua::tovec3(L, 1));
|
||||
|
||||
if (argc == 2) return lua::setquat(L, 2, glm::quat(euler));
|
||||
return lua::pushquat(L, glm::quat(euler));
|
||||
}
|
||||
|
||||
const luaL_Reg quatlib[] = {
|
||||
{"from_mat4", lua::wrap<l_from_mat4>},
|
||||
{"from_euler", lua::wrap<l_from_euler>},
|
||||
{"slerp", lua::wrap<l_slerp>},
|
||||
{"tostring", lua::wrap<l_tostring>},
|
||||
{nullptr, nullptr}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue