mirror of
https://github.com/enduro2d/enduro2d.git
synced 2025-12-14 16:09:06 +07:00
new binds
This commit is contained in:
@@ -111,34 +111,4 @@ namespace sol
|
|||||||
return ptr.get();
|
return ptr.get();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template < typename T >
|
|
||||||
struct unique_usertype_traits<e2d::gcomponent<T>> {
|
|
||||||
using type = T;
|
|
||||||
using actual_type = e2d::gcomponent<T>;
|
|
||||||
static const bool value = true;
|
|
||||||
|
|
||||||
static bool is_null(const actual_type& ptr) {
|
|
||||||
return !ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
static type* get(actual_type& ptr) {
|
|
||||||
return ptr.find();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template < typename T >
|
|
||||||
struct unique_usertype_traits<e2d::const_gcomponent<T>> {
|
|
||||||
using type = T;
|
|
||||||
using actual_type = e2d::const_gcomponent<T>;
|
|
||||||
static const bool value = true;
|
|
||||||
|
|
||||||
static bool is_null(const actual_type& ptr) {
|
|
||||||
return !ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
static type* get(actual_type& ptr) {
|
|
||||||
return ptr.find();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -742,7 +742,6 @@ namespace e2d::math
|
|||||||
|
|
||||||
template < typename T >
|
template < typename T >
|
||||||
T inverse_lerp(T l, T r, T v) noexcept {
|
T inverse_lerp(T l, T r, T v) noexcept {
|
||||||
E2D_ASSERT(!approximately(l, r, T(0)));
|
|
||||||
return (v - l) / (r - l);
|
return (v - l) / (r - l);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,12 +6,30 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <enduro2d/high/luasol.hpp>
|
#include <enduro2d/high/_high.hpp>
|
||||||
|
|
||||||
namespace e2d::bindings
|
namespace e2d::bindings
|
||||||
{
|
{
|
||||||
void bind_math(sol::state& l);
|
template < typename T >
|
||||||
void bind_utils(sol::state& l);
|
struct component_wrapper {
|
||||||
void bind_core(sol::state& l);
|
gcomponent<T> component;
|
||||||
void bind_high(sol::state& l);
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace sol
|
||||||
|
{
|
||||||
|
template < typename T >
|
||||||
|
struct unique_usertype_traits<e2d::bindings::component_wrapper<T>> {
|
||||||
|
using type = e2d::gcomponent<T>;
|
||||||
|
using actual_type = e2d::bindings::component_wrapper<T>;
|
||||||
|
static const bool value = true;
|
||||||
|
|
||||||
|
static bool is_null(const actual_type& ptr) {
|
||||||
|
return !ptr.component.exists();
|
||||||
|
}
|
||||||
|
|
||||||
|
static type* get(actual_type& ptr) {
|
||||||
|
return &ptr.component;
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
29
sources/enduro2d/high/bindings/core_binds/_core_binds.hpp
Normal file
29
sources/enduro2d/high/bindings/core_binds/_core_binds.hpp
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "Enduro2D"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "../bindings.hpp"
|
||||||
|
|
||||||
|
namespace e2d::bindings::core
|
||||||
|
{
|
||||||
|
void bind_dbgui(sol::state& l);
|
||||||
|
void bind_debug(sol::state& l);
|
||||||
|
void bind_engine(sol::state& l);
|
||||||
|
void bind_input(sol::state& l);
|
||||||
|
void bind_window(sol::state& l);
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace e2d::bindings
|
||||||
|
{
|
||||||
|
inline void bind_core(sol::state& l) {
|
||||||
|
core::bind_dbgui(l);
|
||||||
|
core::bind_debug(l);
|
||||||
|
core::bind_engine(l);
|
||||||
|
core::bind_input(l);
|
||||||
|
core::bind_window(l);
|
||||||
|
}
|
||||||
|
}
|
||||||
22
sources/enduro2d/high/bindings/core_binds/dbgui_binds.cpp
Normal file
22
sources/enduro2d/high/bindings/core_binds/dbgui_binds.cpp
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "Enduro2D"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "_core_binds.hpp"
|
||||||
|
|
||||||
|
namespace e2d::bindings::core
|
||||||
|
{
|
||||||
|
void bind_dbgui(sol::state& l) {
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
["core"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<dbgui>("dbgui",
|
||||||
|
sol::no_constructor,
|
||||||
|
|
||||||
|
"visible", sol::property(
|
||||||
|
&dbgui::visible,
|
||||||
|
&dbgui::toggle_visible)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
34
sources/enduro2d/high/bindings/core_binds/debug_binds.cpp
Normal file
34
sources/enduro2d/high/bindings/core_binds/debug_binds.cpp
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "Enduro2D"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "_core_binds.hpp"
|
||||||
|
|
||||||
|
namespace e2d::bindings::core
|
||||||
|
{
|
||||||
|
void bind_debug(sol::state& l) {
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
["core"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<debug>("debug",
|
||||||
|
sol::no_constructor,
|
||||||
|
|
||||||
|
"trace", [](debug& d, const char* s){
|
||||||
|
d.trace(s);
|
||||||
|
},
|
||||||
|
|
||||||
|
"warning", [](debug& d, const char* s){
|
||||||
|
d.warning(s);
|
||||||
|
},
|
||||||
|
|
||||||
|
"error", [](debug& d, const char* s){
|
||||||
|
d.error(s);
|
||||||
|
},
|
||||||
|
|
||||||
|
"fatal", [](debug& d, const char* s){
|
||||||
|
d.fatal(s);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
24
sources/enduro2d/high/bindings/core_binds/engine_binds.cpp
Normal file
24
sources/enduro2d/high/bindings/core_binds/engine_binds.cpp
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "Enduro2D"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "_core_binds.hpp"
|
||||||
|
|
||||||
|
namespace e2d::bindings::core
|
||||||
|
{
|
||||||
|
void bind_engine(sol::state& l) {
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
["core"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<engine>("engine",
|
||||||
|
sol::no_constructor,
|
||||||
|
|
||||||
|
"time", sol::property(&engine::time),
|
||||||
|
"delta_time", sol::property(&engine::delta_time),
|
||||||
|
"frame_rate", sol::property(&engine::frame_rate),
|
||||||
|
"frame_count", sol::property(&engine::frame_count),
|
||||||
|
"realtime_time", sol::property(&engine::realtime_time)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,52 +1,28 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* This file is part of the "Enduro2D"
|
* This file is part of the "Enduro2D"
|
||||||
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#include "bindings.hpp"
|
#include "_core_binds.hpp"
|
||||||
|
|
||||||
namespace
|
namespace e2d::bindings::core
|
||||||
{
|
{
|
||||||
using namespace e2d;
|
|
||||||
|
|
||||||
void bind_debug(sol::state& l) {
|
|
||||||
l.new_usertype<debug>("debug",
|
|
||||||
"min_level", sol::property(&debug::min_level, &debug::set_min_level),
|
|
||||||
"log", [](debug& d, debug::level l, const char* s){ d.log(l, s); },
|
|
||||||
"trace", [](debug& d, const char* s){ d.trace(s); },
|
|
||||||
"warning", [](debug& d, const char* s){ d.warning(s); },
|
|
||||||
"error", [](debug& d, const char* s){ d.error(s); },
|
|
||||||
"fatal", [](debug& d, const char* s){ d.fatal(s); }
|
|
||||||
);
|
|
||||||
#define DEBUG_LEVEL_PAIR(x) {#x, debug::level::x},
|
|
||||||
l["debug"].get_or_create<sol::table>()
|
|
||||||
.new_enum<debug::level>("level", {
|
|
||||||
DEBUG_LEVEL_PAIR(trace)
|
|
||||||
DEBUG_LEVEL_PAIR(warning)
|
|
||||||
DEBUG_LEVEL_PAIR(error)
|
|
||||||
DEBUG_LEVEL_PAIR(fatal)
|
|
||||||
});
|
|
||||||
#undef DEBUG_LEVEL_PAIR
|
|
||||||
}
|
|
||||||
|
|
||||||
void bind_engine(sol::state& l) {
|
|
||||||
l.new_usertype<engine>("engine",
|
|
||||||
"time", sol::property(&engine::time),
|
|
||||||
"delta_time", sol::property(&engine::delta_time),
|
|
||||||
"frame_rate", sol::property(&engine::frame_rate),
|
|
||||||
"frame_count", sol::property(&engine::frame_count),
|
|
||||||
"realtime_time", sol::property(&engine::realtime_time)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void bind_input(sol::state& l) {
|
void bind_input(sol::state& l) {
|
||||||
l.new_usertype<input>("input",
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
["core"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<input>("input",
|
||||||
|
sol::no_constructor,
|
||||||
|
|
||||||
"mouse", sol::property(&input::mouse),
|
"mouse", sol::property(&input::mouse),
|
||||||
"keyboard", sol::property(&input::keyboard)
|
"keyboard", sol::property(&input::keyboard)
|
||||||
);
|
);
|
||||||
|
|
||||||
l.new_usertype<mouse>("mouse",
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
["core"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<mouse>("mouse",
|
||||||
|
sol::no_constructor,
|
||||||
|
|
||||||
"cursor_pos", sol::property(&mouse::cursor_pos),
|
"cursor_pos", sol::property(&mouse::cursor_pos),
|
||||||
"scroll_delta", sol::property(&mouse::scroll_delta),
|
"scroll_delta", sol::property(&mouse::scroll_delta),
|
||||||
|
|
||||||
@@ -63,8 +39,14 @@ namespace
|
|||||||
"just_released_buttons", sol::property(&mouse::just_released_buttons)
|
"just_released_buttons", sol::property(&mouse::just_released_buttons)
|
||||||
);
|
);
|
||||||
|
|
||||||
l.new_usertype<keyboard>("keyboard",
|
l["e2d"].get_or_create<sol::table>()
|
||||||
"input_text", sol::property([](const keyboard& k){ return make_utf8(k.input_text()); }),
|
["core"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<keyboard>("keyboard",
|
||||||
|
sol::no_constructor,
|
||||||
|
|
||||||
|
"input_text", sol::property([](const keyboard& k){
|
||||||
|
return make_utf8(k.input_text());
|
||||||
|
}),
|
||||||
|
|
||||||
"is_any_key_pressed", sol::property(&keyboard::is_any_key_pressed),
|
"is_any_key_pressed", sol::property(&keyboard::is_any_key_pressed),
|
||||||
"is_any_key_just_pressed", sol::property(&keyboard::is_any_key_just_pressed),
|
"is_any_key_just_pressed", sol::property(&keyboard::is_any_key_just_pressed),
|
||||||
@@ -80,7 +62,8 @@ namespace
|
|||||||
);
|
);
|
||||||
|
|
||||||
#define MOUSE_BUTTON_PAIR(x) {#x, mouse_button::x},
|
#define MOUSE_BUTTON_PAIR(x) {#x, mouse_button::x},
|
||||||
l.new_enum<mouse_button>("mouse_button", {
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
.new_enum<mouse_button>("mouse_button", {
|
||||||
MOUSE_BUTTON_PAIR(left)
|
MOUSE_BUTTON_PAIR(left)
|
||||||
MOUSE_BUTTON_PAIR(right)
|
MOUSE_BUTTON_PAIR(right)
|
||||||
MOUSE_BUTTON_PAIR(middle)
|
MOUSE_BUTTON_PAIR(middle)
|
||||||
@@ -90,7 +73,8 @@ namespace
|
|||||||
#undef MOUSE_BUTTON_PAIR
|
#undef MOUSE_BUTTON_PAIR
|
||||||
|
|
||||||
#define KEYBOARD_KEY_PAIR(x) {#x, keyboard_key::x},
|
#define KEYBOARD_KEY_PAIR(x) {#x, keyboard_key::x},
|
||||||
l.new_enum<keyboard_key>("keyboard_key", {
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
.new_enum<keyboard_key>("keyboard_key", {
|
||||||
KEYBOARD_KEY_PAIR(_0)
|
KEYBOARD_KEY_PAIR(_0)
|
||||||
KEYBOARD_KEY_PAIR(_1)
|
KEYBOARD_KEY_PAIR(_1)
|
||||||
KEYBOARD_KEY_PAIR(_2)
|
KEYBOARD_KEY_PAIR(_2)
|
||||||
@@ -225,49 +209,4 @@ namespace
|
|||||||
});
|
});
|
||||||
#undef KEYBOARD_KEY_PAIR
|
#undef KEYBOARD_KEY_PAIR
|
||||||
}
|
}
|
||||||
|
|
||||||
void bind_window(sol::state& l) {
|
|
||||||
l.new_usertype<window>("window",
|
|
||||||
"hide", &window::hide,
|
|
||||||
"show", &window::show,
|
|
||||||
"restore", &window::restore,
|
|
||||||
"minimize", &window::minimize,
|
|
||||||
|
|
||||||
"enabled", sol::property(&window::enabled),
|
|
||||||
"visible", sol::property(&window::visible),
|
|
||||||
"focused", sol::property(&window::focused),
|
|
||||||
"minimized", sol::property(&window::minimized),
|
|
||||||
|
|
||||||
"fullscreen", sol::property(
|
|
||||||
&window::fullscreen,
|
|
||||||
&window::toggle_fullscreen),
|
|
||||||
|
|
||||||
"cursor_hidden", sol::property(
|
|
||||||
&window::is_cursor_hidden,
|
|
||||||
[](window& w, bool yesno){
|
|
||||||
if ( yesno ) {
|
|
||||||
w.hide_cursor();
|
|
||||||
} else {
|
|
||||||
w.show_cursor();
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
|
|
||||||
"real_size", sol::property([](const window& w){ return w.real_size().cast_to<f32>(); }),
|
|
||||||
"virtual_size", sol::property([](const window& w){ return w.virtual_size().cast_to<f32>(); }),
|
|
||||||
"framebuffer_size", sol::property([](const window& w){ return w.framebuffer_size().cast_to<f32>(); }),
|
|
||||||
|
|
||||||
"title", sol::property(&window::title, &window::set_title),
|
|
||||||
"should_close", sol::property(&window::should_close, &window::set_should_close)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace e2d::bindings
|
|
||||||
{
|
|
||||||
void bind_core(sol::state& l) {
|
|
||||||
bind_debug(l);
|
|
||||||
bind_engine(l);
|
|
||||||
bind_input(l);
|
|
||||||
bind_window(l);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
62
sources/enduro2d/high/bindings/core_binds/window_binds.cpp
Normal file
62
sources/enduro2d/high/bindings/core_binds/window_binds.cpp
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "Enduro2D"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "_core_binds.hpp"
|
||||||
|
|
||||||
|
namespace e2d::bindings::core
|
||||||
|
{
|
||||||
|
void bind_window(sol::state& l) {
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
["core"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<window>("window",
|
||||||
|
sol::no_constructor,
|
||||||
|
|
||||||
|
"hide", &window::hide,
|
||||||
|
"show", &window::show,
|
||||||
|
"restore", &window::restore,
|
||||||
|
"minimize", &window::minimize,
|
||||||
|
|
||||||
|
"enabled", sol::property(&window::enabled),
|
||||||
|
"visible", sol::property(&window::visible),
|
||||||
|
"focused", sol::property(&window::focused),
|
||||||
|
"minimized", sol::property(&window::minimized),
|
||||||
|
|
||||||
|
"fullscreen", sol::property(
|
||||||
|
&window::fullscreen,
|
||||||
|
&window::toggle_fullscreen),
|
||||||
|
|
||||||
|
"cursor_hidden", sol::property(
|
||||||
|
&window::is_cursor_hidden,
|
||||||
|
[](window& w, bool yesno){
|
||||||
|
if ( yesno ) {
|
||||||
|
w.hide_cursor();
|
||||||
|
} else {
|
||||||
|
w.show_cursor();
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
|
||||||
|
"real_size", sol::property([](const window& w){
|
||||||
|
return w.real_size().cast_to<f32>();
|
||||||
|
}),
|
||||||
|
|
||||||
|
"virtual_size", sol::property([](const window& w){
|
||||||
|
return w.virtual_size().cast_to<f32>();
|
||||||
|
}),
|
||||||
|
|
||||||
|
"framebuffer_size", sol::property([](const window& w){
|
||||||
|
return w.framebuffer_size().cast_to<f32>();
|
||||||
|
}),
|
||||||
|
|
||||||
|
"title", sol::property(
|
||||||
|
&window::title,
|
||||||
|
&window::set_title),
|
||||||
|
|
||||||
|
"should_close", sol::property(
|
||||||
|
&window::should_close,
|
||||||
|
&window::set_should_close)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* This file is part of the "Enduro2D"
|
|
||||||
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
|
||||||
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
|
||||||
******************************************************************************/
|
|
||||||
|
|
||||||
#include "bindings.hpp"
|
|
||||||
|
|
||||||
#include <enduro2d/high/library.hpp>
|
|
||||||
#include <enduro2d/high/luasol.hpp>
|
|
||||||
#include <enduro2d/high/world.hpp>
|
|
||||||
|
|
||||||
#include <enduro2d/high/node.hpp>
|
|
||||||
#include <enduro2d/high/gobject.hpp>
|
|
||||||
|
|
||||||
#include <enduro2d/high/components/actor.hpp>
|
|
||||||
#include <enduro2d/high/components/behaviour.hpp>
|
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
using namespace e2d;
|
|
||||||
|
|
||||||
void bind_library(sol::state& l) {
|
|
||||||
l.new_usertype<library>("library");
|
|
||||||
}
|
|
||||||
|
|
||||||
void bind_luasol(sol::state& l) {
|
|
||||||
l.new_usertype<luasol>("luasol");
|
|
||||||
}
|
|
||||||
|
|
||||||
void bind_world(sol::state& l) {
|
|
||||||
l.new_usertype<world>("world");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
using namespace e2d;
|
|
||||||
|
|
||||||
void bind_node(sol::state& l) {
|
|
||||||
l.new_usertype<node>("node");
|
|
||||||
}
|
|
||||||
|
|
||||||
void bind_gobject(sol::state& l) {
|
|
||||||
l.new_usertype<gobject>("gobject");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
using namespace e2d;
|
|
||||||
|
|
||||||
void bind_actor(sol::state& l) {
|
|
||||||
l.new_usertype<actor>("actor");
|
|
||||||
}
|
|
||||||
|
|
||||||
void bind_behaviour(sol::state& l) {
|
|
||||||
l.new_usertype<behaviour>("behaviour");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace e2d::bindings
|
|
||||||
{
|
|
||||||
void bind_high(sol::state& l) {
|
|
||||||
bind_library(l);
|
|
||||||
bind_luasol(l);
|
|
||||||
bind_world(l);
|
|
||||||
|
|
||||||
bind_node(l);
|
|
||||||
bind_gobject(l);
|
|
||||||
|
|
||||||
bind_actor(l);
|
|
||||||
bind_behaviour(l);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
55
sources/enduro2d/high/bindings/high_binds/_high_binds.hpp
Normal file
55
sources/enduro2d/high/bindings/high_binds/_high_binds.hpp
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "Enduro2D"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "../bindings.hpp"
|
||||||
|
|
||||||
|
namespace e2d::bindings::high
|
||||||
|
{
|
||||||
|
void bind_library(sol::state& l);
|
||||||
|
void bind_luasol(sol::state& l);
|
||||||
|
void bind_world(sol::state& l);
|
||||||
|
|
||||||
|
void bind_node(sol::state& l);
|
||||||
|
void bind_gobject(sol::state& l);
|
||||||
|
|
||||||
|
void bind_actor(sol::state& l);
|
||||||
|
void bind_behaviour(sol::state& l);
|
||||||
|
void bind_camera(sol::state& l);
|
||||||
|
void bind_flipbook_player(sol::state& l);
|
||||||
|
void bind_label(sol::state& l);
|
||||||
|
void bind_model_renderer(sol::state& l);
|
||||||
|
void bind_named(sol::state& l);
|
||||||
|
void bind_renderer(sol::state& l);
|
||||||
|
void bind_scene(sol::state& l);
|
||||||
|
void bind_spine_player(sol::state& l);
|
||||||
|
void bind_sprite_renderer(sol::state& l);
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace e2d::bindings
|
||||||
|
{
|
||||||
|
inline void bind_high(sol::state& l) {
|
||||||
|
high::bind_library(l);
|
||||||
|
high::bind_luasol(l);
|
||||||
|
high::bind_world(l);
|
||||||
|
|
||||||
|
high::bind_node(l);
|
||||||
|
high::bind_gobject(l);
|
||||||
|
|
||||||
|
high::bind_actor(l);
|
||||||
|
high::bind_behaviour(l);
|
||||||
|
high::bind_camera(l);
|
||||||
|
high::bind_flipbook_player(l);
|
||||||
|
high::bind_label(l);
|
||||||
|
high::bind_model_renderer(l);
|
||||||
|
high::bind_named(l);
|
||||||
|
high::bind_renderer(l);
|
||||||
|
high::bind_scene(l);
|
||||||
|
high::bind_spine_player(l);
|
||||||
|
high::bind_sprite_renderer(l);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "Enduro2D"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "../_high_binds.hpp"
|
||||||
|
|
||||||
|
#include <enduro2d/high/gobject.hpp>
|
||||||
|
#include <enduro2d/high/components/actor.hpp>
|
||||||
|
|
||||||
|
namespace e2d::bindings::high
|
||||||
|
{
|
||||||
|
void bind_actor(sol::state& l) {
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
["components"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<gcomponent<actor>>("actor",
|
||||||
|
"node", sol::property([](const gcomponent<actor>& a){ return a->node(); })
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "Enduro2D"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "../_high_binds.hpp"
|
||||||
|
|
||||||
|
#include <enduro2d/high/gobject.hpp>
|
||||||
|
#include <enduro2d/high/components/behaviour.hpp>
|
||||||
|
|
||||||
|
namespace e2d::bindings::high
|
||||||
|
{
|
||||||
|
void bind_behaviour(sol::state& l) {
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
["components"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<gcomponent<behaviour>>("behaviour",
|
||||||
|
"meta", sol::property(
|
||||||
|
[](const gcomponent<behaviour>& b){ return b->meta(); },
|
||||||
|
[](gcomponent<behaviour>& b, sol::table v){ b->meta(std::move(v)); })
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "Enduro2D"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "../_high_binds.hpp"
|
||||||
|
|
||||||
|
#include <enduro2d/high/gobject.hpp>
|
||||||
|
#include <enduro2d/high/components/camera.hpp>
|
||||||
|
|
||||||
|
namespace e2d::bindings::high
|
||||||
|
{
|
||||||
|
void bind_camera(sol::state& l) {
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
["components"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<gcomponent<camera>>("camera",
|
||||||
|
"depth", sol::property(
|
||||||
|
[](const gcomponent<camera>& b){ return b->depth(); },
|
||||||
|
[](gcomponent<camera>& b, i32 v){ b->depth(v); }),
|
||||||
|
"viewport", sol::property(
|
||||||
|
[](const gcomponent<camera>& b){ return b->viewport().cast_to<f32>(); },
|
||||||
|
[](gcomponent<camera>& b, const b2f& v){ b->viewport(v.cast_to<u32>()); }),
|
||||||
|
"projection", sol::property(
|
||||||
|
[](const gcomponent<camera>& b){ return b->projection(); },
|
||||||
|
[](gcomponent<camera>& b, const m4f& v){ b->projection(v); }),
|
||||||
|
"target", sol::property(
|
||||||
|
[](const gcomponent<camera>& b){ return b->target(); },
|
||||||
|
[](gcomponent<camera>& b, const render_target_ptr& v){ b->target(v); }),
|
||||||
|
"background", sol::property(
|
||||||
|
[](const gcomponent<camera>& b){ return b->background(); },
|
||||||
|
[](gcomponent<camera>& b, const color& v){ b->background(v); })
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "Enduro2D"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "../_high_binds.hpp"
|
||||||
|
|
||||||
|
#include <enduro2d/high/gobject.hpp>
|
||||||
|
#include <enduro2d/high/components/flipbook_player.hpp>
|
||||||
|
|
||||||
|
namespace e2d::bindings::high
|
||||||
|
{
|
||||||
|
void bind_flipbook_player(sol::state& l) {
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
["components"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<gcomponent<flipbook_player>>("flipbook_player",
|
||||||
|
"time", sol::property(
|
||||||
|
[](const gcomponent<flipbook_player>& b){ return b->time(); },
|
||||||
|
[](gcomponent<flipbook_player>& b, f32 v){ b->time(v); }),
|
||||||
|
"speed", sol::property(
|
||||||
|
[](const gcomponent<flipbook_player>& b){ return b->speed(); },
|
||||||
|
[](gcomponent<flipbook_player>& b, f32 v){ b->speed(v); }),
|
||||||
|
"looped", sol::property(
|
||||||
|
[](const gcomponent<flipbook_player>& b){ return b->looped(); },
|
||||||
|
[](gcomponent<flipbook_player>& b, bool v){ b->looped(v); }),
|
||||||
|
"stopped", sol::property(
|
||||||
|
[](const gcomponent<flipbook_player>& b){ return b->stopped(); },
|
||||||
|
[](gcomponent<flipbook_player>& b, bool v){ b->stopped(v); }),
|
||||||
|
"playing", sol::property(
|
||||||
|
[](const gcomponent<flipbook_player>& b){ return b->playing(); },
|
||||||
|
[](gcomponent<flipbook_player>& b, bool v){ b->playing(v); }),
|
||||||
|
"sequence", sol::property(
|
||||||
|
[](const gcomponent<flipbook_player>& b){ return b->sequence(); },
|
||||||
|
[](gcomponent<flipbook_player>& b, str_hash v){ b->sequence(v); }),
|
||||||
|
"flipbook", sol::property(
|
||||||
|
[](const gcomponent<flipbook_player>& b){ return b->flipbook(); },
|
||||||
|
[](gcomponent<flipbook_player>& b, const flipbook_asset::ptr& v){ b->flipbook(v); }),
|
||||||
|
|
||||||
|
"stop", sol::overload(
|
||||||
|
[](gcomponent<flipbook_player>& b, f32 v){ b->stop(v); },
|
||||||
|
[](gcomponent<flipbook_player>& b, str_hash v){ b->stop(v); }),
|
||||||
|
"play", sol::overload(
|
||||||
|
[](gcomponent<flipbook_player>& b, f32 v){ b->play(v); },
|
||||||
|
[](gcomponent<flipbook_player>& b, str_hash v){ b->play(v); })
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "Enduro2D"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "../_high_binds.hpp"
|
||||||
|
|
||||||
|
#include <enduro2d/high/gobject.hpp>
|
||||||
|
#include <enduro2d/high/components/label.hpp>
|
||||||
|
|
||||||
|
namespace e2d::bindings::high
|
||||||
|
{
|
||||||
|
void bind_label(sol::state& l) {
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
["components"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<gcomponent<label>>("label",
|
||||||
|
"text", sol::property(
|
||||||
|
[](const gcomponent<label>& l){
|
||||||
|
return l->text();
|
||||||
|
},
|
||||||
|
[](gcomponent<label>& l, str v){
|
||||||
|
l->text(std::move(v));
|
||||||
|
l.owner().component<label::dirty>().assign();
|
||||||
|
}),
|
||||||
|
"font", sol::property(
|
||||||
|
[](const gcomponent<label>& l){
|
||||||
|
return l->font();
|
||||||
|
},
|
||||||
|
[](gcomponent<label>& l, const font_asset::ptr& v){
|
||||||
|
l->font(v);
|
||||||
|
l.owner().component<label::dirty>().assign();
|
||||||
|
}),
|
||||||
|
"tint", sol::property(
|
||||||
|
[](const gcomponent<label>& l){
|
||||||
|
return l->tint();
|
||||||
|
},
|
||||||
|
[](gcomponent<label>& l, const color32& v){
|
||||||
|
l->tint(v);
|
||||||
|
l.owner().component<label::dirty>().assign();
|
||||||
|
}),
|
||||||
|
"halign", sol::property(
|
||||||
|
[](const gcomponent<label>& l){
|
||||||
|
return l->halign();
|
||||||
|
},
|
||||||
|
[](gcomponent<label>& l, label::haligns v){
|
||||||
|
l->halign(v);
|
||||||
|
l.owner().component<label::dirty>().assign();
|
||||||
|
}),
|
||||||
|
"valign", sol::property(
|
||||||
|
[](const gcomponent<label>& l){
|
||||||
|
return l->valign();
|
||||||
|
},
|
||||||
|
[](gcomponent<label>& l, label::valigns v){
|
||||||
|
l->valign(v);
|
||||||
|
l.owner().component<label::dirty>().assign();
|
||||||
|
}),
|
||||||
|
"leading", sol::property(
|
||||||
|
[](const gcomponent<label>& l){
|
||||||
|
return l->leading();
|
||||||
|
},
|
||||||
|
[](gcomponent<label>& l, f32 v){
|
||||||
|
l->leading(v);
|
||||||
|
l.owner().component<label::dirty>().assign();
|
||||||
|
}),
|
||||||
|
"tracking", sol::property(
|
||||||
|
[](const gcomponent<label>& l){
|
||||||
|
return l->tracking();
|
||||||
|
},
|
||||||
|
[](gcomponent<label>& l, f32 v){
|
||||||
|
l->tracking(v);
|
||||||
|
l.owner().component<label::dirty>().assign();
|
||||||
|
}),
|
||||||
|
"text_width", sol::property(
|
||||||
|
[](const gcomponent<label>& l){
|
||||||
|
return l->text_width();
|
||||||
|
},
|
||||||
|
[](gcomponent<label>& l, f32 v){
|
||||||
|
l->text_width(v);
|
||||||
|
l.owner().component<label::dirty>().assign();
|
||||||
|
}),
|
||||||
|
"glyph_dilate", sol::property(
|
||||||
|
[](const gcomponent<label>& l){
|
||||||
|
return l->glyph_dilate();
|
||||||
|
},
|
||||||
|
[](gcomponent<label>& l, f32 v){
|
||||||
|
l->glyph_dilate(v);
|
||||||
|
l.owner().component<label::dirty>().assign();
|
||||||
|
}),
|
||||||
|
"outline_width", sol::property(
|
||||||
|
[](const gcomponent<label>& l){
|
||||||
|
return l->outline_width();
|
||||||
|
},
|
||||||
|
[](gcomponent<label>& l, f32 v){
|
||||||
|
l->outline_width(v);
|
||||||
|
l.owner().component<label::dirty>().assign();
|
||||||
|
}),
|
||||||
|
"outline_color", sol::property(
|
||||||
|
[](const gcomponent<label>& l){
|
||||||
|
return l->outline_color();
|
||||||
|
},
|
||||||
|
[](gcomponent<label>& l, const color32& v){
|
||||||
|
l->outline_color(v);
|
||||||
|
l.owner().component<label::dirty>().assign();
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
#define LABEL_HALIGN_PAIR(x) {#x, label::haligns::x},
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
["label"].get_or_create<sol::table>()
|
||||||
|
.new_enum<label::haligns>("haligns", {
|
||||||
|
LABEL_HALIGN_PAIR(left)
|
||||||
|
LABEL_HALIGN_PAIR(center)
|
||||||
|
LABEL_HALIGN_PAIR(right)
|
||||||
|
});
|
||||||
|
#undef LABEL_HALIGN_PAIR
|
||||||
|
|
||||||
|
#define LABEL_VALIGN_PAIR(x) {#x, label::valigns::x},
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
["label"].get_or_create<sol::table>()
|
||||||
|
.new_enum<label::valigns>("valigns", {
|
||||||
|
LABEL_VALIGN_PAIR(top)
|
||||||
|
LABEL_VALIGN_PAIR(center)
|
||||||
|
LABEL_VALIGN_PAIR(bottom)
|
||||||
|
LABEL_VALIGN_PAIR(baseline)
|
||||||
|
});
|
||||||
|
#undef LABEL_VALIGN_PAIR
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "Enduro2D"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "../_high_binds.hpp"
|
||||||
|
|
||||||
|
#include <enduro2d/high/gobject.hpp>
|
||||||
|
#include <enduro2d/high/components/model_renderer.hpp>
|
||||||
|
|
||||||
|
namespace e2d::bindings::high
|
||||||
|
{
|
||||||
|
void bind_model_renderer(sol::state& l) {
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
["components"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<gcomponent<model_renderer>>("model_renderer",
|
||||||
|
"model", sol::property(
|
||||||
|
[](const gcomponent<model_renderer>& l){ return l->model(); },
|
||||||
|
[](gcomponent<model_renderer>& l, const model_asset::ptr& v){ l->model(v); })
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "Enduro2D"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "../_high_binds.hpp"
|
||||||
|
|
||||||
|
#include <enduro2d/high/gobject.hpp>
|
||||||
|
#include <enduro2d/high/components/named.hpp>
|
||||||
|
|
||||||
|
namespace e2d::bindings::high
|
||||||
|
{
|
||||||
|
void bind_named(sol::state& l) {
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
["components"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<gcomponent<named>>("named",
|
||||||
|
"name", sol::property(
|
||||||
|
[](const gcomponent<named>& c){ return c->name(); },
|
||||||
|
[](gcomponent<named>& c, str v){ c->name(std::move(v)); })
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "Enduro2D"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "../_high_binds.hpp"
|
||||||
|
|
||||||
|
#include <enduro2d/high/gobject.hpp>
|
||||||
|
#include <enduro2d/high/components/renderer.hpp>
|
||||||
|
|
||||||
|
namespace e2d::bindings::high
|
||||||
|
{
|
||||||
|
void bind_renderer(sol::state& l) {
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
["components"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<gcomponent<renderer>>("renderer");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "Enduro2D"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "../_high_binds.hpp"
|
||||||
|
|
||||||
|
#include <enduro2d/high/gobject.hpp>
|
||||||
|
#include <enduro2d/high/components/scene.hpp>
|
||||||
|
|
||||||
|
namespace e2d::bindings::high
|
||||||
|
{
|
||||||
|
void bind_scene(sol::state& l) {
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
["components"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<gcomponent<scene>>("scene",
|
||||||
|
"depth", sol::property(
|
||||||
|
[](const gcomponent<scene>& b){ return b->depth(); },
|
||||||
|
[](gcomponent<scene>& b, i32 v){ b->depth(v); })
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,167 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "Enduro2D"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "../_high_binds.hpp"
|
||||||
|
|
||||||
|
#include <enduro2d/high/gobject.hpp>
|
||||||
|
#include <enduro2d/high/components/spine_player.hpp>
|
||||||
|
#include <enduro2d/high/components/spine_player_cmd.hpp>
|
||||||
|
#include <enduro2d/high/components/spine_player_evt.hpp>
|
||||||
|
|
||||||
|
namespace e2d::bindings::high
|
||||||
|
{
|
||||||
|
void bind_spine_player(sol::state& l) {
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
["components"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<gcomponent<spine_player>>("spine_player",
|
||||||
|
"spine", sol::property(
|
||||||
|
[](const gcomponent<spine_player>& sp){ return sp->spine(); },
|
||||||
|
[](gcomponent<spine_player>& sp, const spine_asset::ptr& v){ sp->spine(v); }),
|
||||||
|
|
||||||
|
"skin", [](gcomponent<spine_player>& sp, const char* name){
|
||||||
|
sp->skin(name);
|
||||||
|
},
|
||||||
|
|
||||||
|
"attachment", [](gcomponent<spine_player>& sp, const char* slot, const char* name){
|
||||||
|
sp->attachment(slot, name);
|
||||||
|
},
|
||||||
|
|
||||||
|
"has_skin", [](const gcomponent<spine_player>& sp, const char* name){
|
||||||
|
return sp->has_skin(name);
|
||||||
|
},
|
||||||
|
|
||||||
|
"has_animation", [](const gcomponent<spine_player>& sp, const char* name){
|
||||||
|
return sp->has_animation(name);
|
||||||
|
},
|
||||||
|
|
||||||
|
"add_command", [](gcomponent<spine_player>& sp, spine_player_cmd::command cmd){
|
||||||
|
sp.owner().component<spine_player_cmd>().ensure().add_command(std::move(cmd));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// commands
|
||||||
|
//
|
||||||
|
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
["spine_player"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<spine_player_cmd::clear_track_cmd>("clear_track_cmd",
|
||||||
|
sol::constructors<spine_player_cmd::clear_track_cmd(u32)>(),
|
||||||
|
"track", sol::property(&spine_player_cmd::clear_track_cmd::track)
|
||||||
|
);
|
||||||
|
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
["spine_player"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<spine_player_cmd::set_anim_cmd>("set_anim_cmd",
|
||||||
|
sol::constructors<spine_player_cmd::set_anim_cmd(u32,str)>(),
|
||||||
|
"track", sol::property(&spine_player_cmd::set_anim_cmd::track),
|
||||||
|
"name", sol::property(&spine_player_cmd::set_anim_cmd::name),
|
||||||
|
|
||||||
|
"loop", sol::property(
|
||||||
|
sol::resolve<bool()const>(&spine_player_cmd::set_anim_cmd::loop),
|
||||||
|
sol::resolve<spine_player_cmd::set_anim_cmd&(bool)>(&spine_player_cmd::set_anim_cmd::loop)),
|
||||||
|
"end_message", sol::property(
|
||||||
|
sol::resolve<const str&()const>(&spine_player_cmd::set_anim_cmd::end_message),
|
||||||
|
sol::resolve<spine_player_cmd::set_anim_cmd&(str)>(&spine_player_cmd::set_anim_cmd::end_message)),
|
||||||
|
"complete_message", sol::property(
|
||||||
|
sol::resolve<const str&()const>(&spine_player_cmd::set_anim_cmd::complete_message),
|
||||||
|
sol::resolve<spine_player_cmd::set_anim_cmd&(str)>(&spine_player_cmd::set_anim_cmd::complete_message))
|
||||||
|
);
|
||||||
|
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
["spine_player"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<spine_player_cmd::add_anim_cmd>("add_anim_cmd",
|
||||||
|
sol::constructors<spine_player_cmd::add_anim_cmd(u32,str)>(),
|
||||||
|
"track", sol::property(&spine_player_cmd::add_anim_cmd::track),
|
||||||
|
"name", sol::property(&spine_player_cmd::add_anim_cmd::name),
|
||||||
|
|
||||||
|
"loop", sol::property(
|
||||||
|
sol::resolve<bool()const>(&spine_player_cmd::add_anim_cmd::loop),
|
||||||
|
sol::resolve<spine_player_cmd::add_anim_cmd&(bool)>(&spine_player_cmd::add_anim_cmd::loop)),
|
||||||
|
"delay", sol::property(
|
||||||
|
sol::resolve<secf()const>(&spine_player_cmd::add_anim_cmd::delay),
|
||||||
|
sol::resolve<spine_player_cmd::add_anim_cmd&(secf)>(&spine_player_cmd::add_anim_cmd::delay)),
|
||||||
|
"end_message", sol::property(
|
||||||
|
sol::resolve<const str&()const>(&spine_player_cmd::add_anim_cmd::end_message),
|
||||||
|
sol::resolve<spine_player_cmd::add_anim_cmd&(str)>(&spine_player_cmd::add_anim_cmd::end_message)),
|
||||||
|
"complete_message", sol::property(
|
||||||
|
sol::resolve<const str&()const>(&spine_player_cmd::add_anim_cmd::complete_message),
|
||||||
|
sol::resolve<spine_player_cmd::add_anim_cmd&(str)>(&spine_player_cmd::add_anim_cmd::complete_message))
|
||||||
|
);
|
||||||
|
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
["spine_player"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<spine_player_cmd::set_empty_anim_cmd>("set_empty_anim_cmd",
|
||||||
|
sol::constructors<spine_player_cmd::set_empty_anim_cmd(u32)>(),
|
||||||
|
"track", sol::property(&spine_player_cmd::set_empty_anim_cmd::track),
|
||||||
|
|
||||||
|
"mix_duration", sol::property(
|
||||||
|
sol::resolve<secf()const>(&spine_player_cmd::set_empty_anim_cmd::mix_duration),
|
||||||
|
sol::resolve<spine_player_cmd::set_empty_anim_cmd&(secf)>(&spine_player_cmd::set_empty_anim_cmd::mix_duration)),
|
||||||
|
"end_message", sol::property(
|
||||||
|
sol::resolve<const str&()const>(&spine_player_cmd::set_empty_anim_cmd::end_message),
|
||||||
|
sol::resolve<spine_player_cmd::set_empty_anim_cmd&(str)>(&spine_player_cmd::set_empty_anim_cmd::end_message)),
|
||||||
|
"complete_message", sol::property(
|
||||||
|
sol::resolve<const str&()const>(&spine_player_cmd::set_empty_anim_cmd::complete_message),
|
||||||
|
sol::resolve<spine_player_cmd::set_empty_anim_cmd&(str)>(&spine_player_cmd::set_empty_anim_cmd::complete_message))
|
||||||
|
);
|
||||||
|
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
["spine_player"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<spine_player_cmd::add_empty_anim_cmd>("add_empty_anim_cmd",
|
||||||
|
sol::constructors<spine_player_cmd::add_empty_anim_cmd(u32)>(),
|
||||||
|
"track", sol::property(&spine_player_cmd::add_empty_anim_cmd::track),
|
||||||
|
|
||||||
|
"delay", sol::property(
|
||||||
|
sol::resolve<secf()const>(&spine_player_cmd::add_empty_anim_cmd::delay),
|
||||||
|
sol::resolve<spine_player_cmd::add_empty_anim_cmd&(secf)>(&spine_player_cmd::add_empty_anim_cmd::delay)),
|
||||||
|
"mix_duration", sol::property(
|
||||||
|
sol::resolve<secf()const>(&spine_player_cmd::add_empty_anim_cmd::mix_duration),
|
||||||
|
sol::resolve<spine_player_cmd::add_empty_anim_cmd&(secf)>(&spine_player_cmd::add_empty_anim_cmd::mix_duration)),
|
||||||
|
"end_message", sol::property(
|
||||||
|
sol::resolve<const str&()const>(&spine_player_cmd::add_empty_anim_cmd::end_message),
|
||||||
|
sol::resolve<spine_player_cmd::add_empty_anim_cmd&(str)>(&spine_player_cmd::add_empty_anim_cmd::end_message)),
|
||||||
|
"complete_message", sol::property(
|
||||||
|
sol::resolve<const str&()const>(&spine_player_cmd::add_empty_anim_cmd::complete_message),
|
||||||
|
sol::resolve<spine_player_cmd::add_empty_anim_cmd&(str)>(&spine_player_cmd::add_empty_anim_cmd::complete_message))
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// events
|
||||||
|
//
|
||||||
|
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
["spine_player"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<spine_player_evt::custom_evt>("custom_evt",
|
||||||
|
sol::constructors<spine_player_evt::custom_evt(str_hash)>(),
|
||||||
|
"name", sol::property(&spine_player_evt::custom_evt::name),
|
||||||
|
|
||||||
|
"int_value", sol::property(
|
||||||
|
sol::resolve<i32()const>(&spine_player_evt::custom_evt::int_value),
|
||||||
|
sol::resolve<spine_player_evt::custom_evt&(i32)>(&spine_player_evt::custom_evt::int_value)),
|
||||||
|
"float_value", sol::property(
|
||||||
|
sol::resolve<f32()const>(&spine_player_evt::custom_evt::float_value),
|
||||||
|
sol::resolve<spine_player_evt::custom_evt&(f32)>(&spine_player_evt::custom_evt::float_value)),
|
||||||
|
"string_value", sol::property(
|
||||||
|
sol::resolve<const str&()const>(&spine_player_evt::custom_evt::string_value),
|
||||||
|
sol::resolve<spine_player_evt::custom_evt&(str)>(&spine_player_evt::custom_evt::string_value))
|
||||||
|
);
|
||||||
|
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
["spine_player"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<spine_player_evt::end_evt>("end_evt",
|
||||||
|
sol::constructors<spine_player_evt::end_evt(str)>(),
|
||||||
|
"message", sol::property(&spine_player_evt::end_evt::message)
|
||||||
|
);
|
||||||
|
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
["spine_player"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<spine_player_evt::complete_evt>("complete_evt",
|
||||||
|
sol::constructors<spine_player_evt::complete_evt(str)>(),
|
||||||
|
"message", sol::property(&spine_player_evt::complete_evt::message)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "Enduro2D"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "../_high_binds.hpp"
|
||||||
|
|
||||||
|
#include <enduro2d/high/gobject.hpp>
|
||||||
|
#include <enduro2d/high/components/sprite_renderer.hpp>
|
||||||
|
|
||||||
|
namespace e2d::bindings::high
|
||||||
|
{
|
||||||
|
void bind_sprite_renderer(sol::state& l) {
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
["components"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<gcomponent<sprite_renderer>>("sprite_renderer",
|
||||||
|
"tint", sol::property(
|
||||||
|
[](const gcomponent<sprite_renderer>& l){ return l->tint(); },
|
||||||
|
[](gcomponent<sprite_renderer>& l, const color32& v){ l->tint(v); }),
|
||||||
|
"blending", sol::property(
|
||||||
|
[](const gcomponent<sprite_renderer>& l){ return l->blending(); },
|
||||||
|
[](gcomponent<sprite_renderer>& l, sprite_renderer::blendings v){ l->blending(v); }),
|
||||||
|
"filtering", sol::property(
|
||||||
|
[](const gcomponent<sprite_renderer>& l){ return l->filtering(); },
|
||||||
|
[](gcomponent<sprite_renderer>& l, bool v){ l->filtering(v); }),
|
||||||
|
"sprite", sol::property(
|
||||||
|
[](const gcomponent<sprite_renderer>& l){ return l->sprite(); },
|
||||||
|
[](gcomponent<sprite_renderer>& l, const sprite_asset::ptr& v){ l->sprite(v); })
|
||||||
|
);
|
||||||
|
|
||||||
|
#define SPRITE_RENDERER_BLENDINGS_PAIR(x) {#x, sprite_renderer::blendings::x},
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
["sprite_renderer"].get_or_create<sol::table>()
|
||||||
|
.new_enum<sprite_renderer::blendings>("blendings", {
|
||||||
|
SPRITE_RENDERER_BLENDINGS_PAIR(normal)
|
||||||
|
SPRITE_RENDERER_BLENDINGS_PAIR(additive)
|
||||||
|
SPRITE_RENDERER_BLENDINGS_PAIR(multiply)
|
||||||
|
SPRITE_RENDERER_BLENDINGS_PAIR(screen)
|
||||||
|
});
|
||||||
|
#undef SPRITE_RENDERER_BLENDINGS_PAIR
|
||||||
|
}
|
||||||
|
}
|
||||||
47
sources/enduro2d/high/bindings/high_binds/gobject_binds.cpp
Normal file
47
sources/enduro2d/high/bindings/high_binds/gobject_binds.cpp
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "Enduro2D"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "_high_binds.hpp"
|
||||||
|
|
||||||
|
#include <enduro2d/high/gobject.hpp>
|
||||||
|
|
||||||
|
#include <enduro2d/high/components/actor.hpp>
|
||||||
|
#include <enduro2d/high/components/behaviour.hpp>
|
||||||
|
#include <enduro2d/high/components/camera.hpp>
|
||||||
|
#include <enduro2d/high/components/flipbook_player.hpp>
|
||||||
|
#include <enduro2d/high/components/label.hpp>
|
||||||
|
#include <enduro2d/high/components/model_renderer.hpp>
|
||||||
|
#include <enduro2d/high/components/named.hpp>
|
||||||
|
#include <enduro2d/high/components/renderer.hpp>
|
||||||
|
#include <enduro2d/high/components/scene.hpp>
|
||||||
|
#include <enduro2d/high/components/spine_player.hpp>
|
||||||
|
#include <enduro2d/high/components/sprite_renderer.hpp>
|
||||||
|
|
||||||
|
namespace e2d::bindings::high
|
||||||
|
{
|
||||||
|
void bind_gobject(sol::state& l) {
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
["high"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<gobject>("gobject",
|
||||||
|
"alive", sol::property(&gobject::alive),
|
||||||
|
"valid", sol::property(&gobject::valid),
|
||||||
|
|
||||||
|
"destroy", &gobject::destroy,
|
||||||
|
|
||||||
|
"actor", sol::property([](gobject& go){ return component_wrapper<actor>{go}; }),
|
||||||
|
"behaviour", sol::property([](gobject& go){ return component_wrapper<behaviour>{go}; }),
|
||||||
|
"camera", sol::property([](gobject& go){ return component_wrapper<camera>{go}; }),
|
||||||
|
"flipbook_player", sol::property([](gobject& go){ return component_wrapper<flipbook_player>{go}; }),
|
||||||
|
"label", sol::property([](gobject& go){ return component_wrapper<label>{go}; }),
|
||||||
|
"model_renderer", sol::property([](gobject& go){ return component_wrapper<model_renderer>{go}; }),
|
||||||
|
"named", sol::property([](gobject& go){ return component_wrapper<named>{go}; }),
|
||||||
|
"renderer", sol::property([](gobject& go){ return component_wrapper<renderer>{go}; }),
|
||||||
|
"scene", sol::property([](gobject& go){ return component_wrapper<scene>{go}; }),
|
||||||
|
"spine_player", sol::property([](gobject& go){ return component_wrapper<spine_player>{go}; }),
|
||||||
|
"sprite_renderer", sol::property([](gobject& go){ return component_wrapper<sprite_renderer>{go}; })
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
18
sources/enduro2d/high/bindings/high_binds/library_binds.cpp
Normal file
18
sources/enduro2d/high/bindings/high_binds/library_binds.cpp
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "Enduro2D"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "_high_binds.hpp"
|
||||||
|
|
||||||
|
#include <enduro2d/high/library.hpp>
|
||||||
|
|
||||||
|
namespace e2d::bindings::high
|
||||||
|
{
|
||||||
|
void bind_library(sol::state& l) {
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
["high"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<library>("library");
|
||||||
|
}
|
||||||
|
}
|
||||||
18
sources/enduro2d/high/bindings/high_binds/luasol_binds.cpp
Normal file
18
sources/enduro2d/high/bindings/high_binds/luasol_binds.cpp
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "Enduro2D"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "_high_binds.hpp"
|
||||||
|
|
||||||
|
#include <enduro2d/high/luasol.hpp>
|
||||||
|
|
||||||
|
namespace e2d::bindings::high
|
||||||
|
{
|
||||||
|
void bind_luasol(sol::state& l) {
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
["high"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<luasol>("luasol");
|
||||||
|
}
|
||||||
|
}
|
||||||
75
sources/enduro2d/high/bindings/high_binds/node_binds.cpp
Normal file
75
sources/enduro2d/high/bindings/high_binds/node_binds.cpp
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "Enduro2D"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "_high_binds.hpp"
|
||||||
|
|
||||||
|
#include <enduro2d/high/node.hpp>
|
||||||
|
|
||||||
|
namespace e2d::bindings::high
|
||||||
|
{
|
||||||
|
void bind_node(sol::state& l) {
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
["high"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<node>("node",
|
||||||
|
"owner", sol::property(
|
||||||
|
[](const node& n){ return n.owner(); }),
|
||||||
|
|
||||||
|
"transform", sol::property(
|
||||||
|
[](const node& n){ return n.transform(); },
|
||||||
|
sol::resolve<void(const t3f&)>(&node::transform)),
|
||||||
|
"translation", sol::property(
|
||||||
|
[](const node& n){ return n.translation(); },
|
||||||
|
sol::resolve<void(const v3f&)>(&node::translation)),
|
||||||
|
"rotation", sol::property(
|
||||||
|
[](const node& n){ return n.rotation(); },
|
||||||
|
sol::resolve<void(const q4f&)>(&node::rotation)),
|
||||||
|
"scale", sol::property(
|
||||||
|
[](const node& n){ return n.scale(); },
|
||||||
|
sol::resolve<void(const v3f&)>(&node::scale)),
|
||||||
|
|
||||||
|
"local_matrix", sol::property(
|
||||||
|
[](const node& n){ return n.local_matrix(); }),
|
||||||
|
"world_matrix", sol::property(
|
||||||
|
[](const node& n){ return n.world_matrix(); }),
|
||||||
|
|
||||||
|
"root", sol::property(
|
||||||
|
[](const node& n){ return n.root(); }),
|
||||||
|
"parent", sol::property(
|
||||||
|
[](const node& n){ return n.parent(); }),
|
||||||
|
|
||||||
|
"remove_from_parent", &node::remove_from_parent,
|
||||||
|
"remove_all_children", &node::remove_all_children,
|
||||||
|
|
||||||
|
"child_count", sol::property(
|
||||||
|
[](const node& n){ return n.child_count(); }),
|
||||||
|
"child_count_recursive", sol::property(
|
||||||
|
[](const node& n){ return n.child_count_recursive(); }),
|
||||||
|
|
||||||
|
"add_child", &node::add_child,
|
||||||
|
"add_child_to_back", &node::add_child_to_back,
|
||||||
|
"add_child_to_front", &node::add_child_to_front,
|
||||||
|
"add_child_before", &node::add_child_before,
|
||||||
|
"add_child_after", &node::add_child_after,
|
||||||
|
"add_sibling_before", &node::add_sibling_before,
|
||||||
|
"add_sibling_after", &node::add_sibling_after,
|
||||||
|
"remove_child", &node::remove_child,
|
||||||
|
|
||||||
|
"send_backward", &node::send_backward,
|
||||||
|
"bring_to_back", &node::bring_to_back,
|
||||||
|
"send_forward", &node::send_forward,
|
||||||
|
"bring_to_front", &node::bring_to_front,
|
||||||
|
|
||||||
|
"first_child", sol::property(
|
||||||
|
[](const node& n){ return n.first_child(); }),
|
||||||
|
"last_child", sol::property(
|
||||||
|
[](const node& n){ return n.last_child(); }),
|
||||||
|
"prev_sibling", sol::property(
|
||||||
|
[](const node& n){ return n.prev_sibling(); }),
|
||||||
|
"next_sibling", sol::property(
|
||||||
|
[](const node& n){ return n.next_sibling(); })
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
18
sources/enduro2d/high/bindings/high_binds/world_binds.cpp
Normal file
18
sources/enduro2d/high/bindings/high_binds/world_binds.cpp
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "Enduro2D"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "_high_binds.hpp"
|
||||||
|
|
||||||
|
#include <enduro2d/high/world.hpp>
|
||||||
|
|
||||||
|
namespace e2d::bindings::high
|
||||||
|
{
|
||||||
|
void bind_world(sol::state& l) {
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
["high"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<world>("world");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,678 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* This file is part of the "Enduro2D"
|
|
||||||
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
|
||||||
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
|
||||||
******************************************************************************/
|
|
||||||
|
|
||||||
#include "bindings.hpp"
|
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
using namespace e2d;
|
|
||||||
|
|
||||||
template < typename T >
|
|
||||||
void bind_vec2(const str& name, sol::state& l) {
|
|
||||||
l.new_usertype<vec2<T>>(name,
|
|
||||||
sol::constructors<
|
|
||||||
vec2<T>(),
|
|
||||||
vec2<T>(T),
|
|
||||||
vec2<T>(T,T),
|
|
||||||
vec2<T>(vec2<T>),
|
|
||||||
vec2<T>(vec3<T>),
|
|
||||||
vec2<T>(vec4<T>)>(),
|
|
||||||
|
|
||||||
"zero", &vec2<T>::zero,
|
|
||||||
"unit", &vec2<T>::unit,
|
|
||||||
"unit_x", &vec2<T>::unit_x,
|
|
||||||
"unit_y", &vec2<T>::unit_y,
|
|
||||||
|
|
||||||
"x", &vec2<T>::x,
|
|
||||||
"y", &vec2<T>::y,
|
|
||||||
|
|
||||||
sol::meta_function::equal_to, sol::resolve<bool(const vec2<T>&, const vec2<T>&)>(::operator==),
|
|
||||||
sol::meta_function::less_than, sol::resolve<bool(const vec2<T>&, const vec2<T>&)>(::operator<),
|
|
||||||
sol::meta_function::less_than_or_equal_to, sol::resolve<bool(const vec2<T>&, const vec2<T>&)>(::operator<=),
|
|
||||||
|
|
||||||
sol::meta_function::unary_minus, sol::resolve<vec2<T>(const vec2<T>&)>(::operator-),
|
|
||||||
|
|
||||||
sol::meta_function::addition, sol::overload(
|
|
||||||
sol::resolve<vec2<T>(T, const vec2<T>&)>(::operator+),
|
|
||||||
sol::resolve<vec2<T>(const vec2<T>&, T)>(::operator+),
|
|
||||||
sol::resolve<vec2<T>(const vec2<T>&, const vec2<T>&)>(::operator+)),
|
|
||||||
|
|
||||||
sol::meta_function::subtraction, sol::overload(
|
|
||||||
sol::resolve<vec2<T>(T, const vec2<T>&)>(::operator-),
|
|
||||||
sol::resolve<vec2<T>(const vec2<T>&, T)>(::operator-),
|
|
||||||
sol::resolve<vec2<T>(const vec2<T>&, const vec2<T>&)>(::operator-)),
|
|
||||||
|
|
||||||
sol::meta_function::multiplication, sol::overload(
|
|
||||||
sol::resolve<vec2<T>(T, const vec2<T>&)>(::operator*),
|
|
||||||
sol::resolve<vec2<T>(const vec2<T>&, T)>(::operator*),
|
|
||||||
sol::resolve<vec2<T>(const vec2<T>&, const vec2<T>&)>(::operator*),
|
|
||||||
sol::resolve<vec2<T>(const vec2<T>&, const mat2<T>&)>(::operator*)),
|
|
||||||
|
|
||||||
sol::meta_function::division, sol::overload(
|
|
||||||
sol::resolve<vec2<T>(T, const vec2<T>&)>(::operator/),
|
|
||||||
sol::resolve<vec2<T>(const vec2<T>&, T)>(::operator/),
|
|
||||||
sol::resolve<vec2<T>(const vec2<T>&, const vec2<T>&)>(::operator/)),
|
|
||||||
|
|
||||||
"approximately", [](const vec2<T>& l, const vec2<T>& r){ return math::approximately(l,r); },
|
|
||||||
|
|
||||||
"dot", sol::resolve<T(const vec2<T>&, const vec2<T>&)>(&math::dot),
|
|
||||||
"abs_dot", sol::resolve<T(const vec2<T>&, const vec2<T>&)>(&math::abs_dot),
|
|
||||||
|
|
||||||
"length_squared", sol::resolve<T(const vec2<T>&)>(&math::length_squared),
|
|
||||||
"length", sol::resolve<T(const vec2<T>&)>(&math::length),
|
|
||||||
|
|
||||||
"distance_squared", sol::resolve<math::make_distance_t<T>(const vec2<T>&, const vec2<T>&)>(&math::distance_squared),
|
|
||||||
"distance", sol::resolve<T(const vec2<T>&, const vec2<T>&)>(&math::distance),
|
|
||||||
|
|
||||||
"normalized", [](const vec2<T>& v){ return math::normalized(v); },
|
|
||||||
|
|
||||||
"minimum", sol::resolve<T(const vec2<T>&)>(&math::minimum),
|
|
||||||
"maximum", sol::resolve<T(const vec2<T>&)>(&math::maximum),
|
|
||||||
|
|
||||||
"minimized", sol::resolve<vec2<T>(const vec2<T>&, const vec2<T>&)>(&math::minimized),
|
|
||||||
"maximized", sol::resolve<vec2<T>(const vec2<T>&, const vec2<T>&)>(&math::maximized),
|
|
||||||
"clamped", sol::resolve<vec2<T>(const vec2<T>&, const vec2<T>&, const vec2<T>&)>(&math::clamped),
|
|
||||||
"saturated", sol::resolve<vec2<T>(const vec2<T>&)>(&math::saturated),
|
|
||||||
|
|
||||||
"lerp", sol::resolve<vec2<T>(const vec2<T>&, const vec2<T>&, T)>(&math::lerp),
|
|
||||||
"lerp", sol::resolve<vec2<T>(const vec2<T>&, const vec2<T>&, const vec2<T>&)>(&math::lerp),
|
|
||||||
"inverse_lerp", sol::resolve<vec2<T>(const vec2<T>&, const vec2<T>&, const vec2<T>&)>(&math::inverse_lerp),
|
|
||||||
|
|
||||||
"contains_nan", sol::resolve<bool(const vec2<T>&)>(&math::contains_nan));
|
|
||||||
}
|
|
||||||
|
|
||||||
template < typename T >
|
|
||||||
void bind_vec3(const str& name, sol::state& l) {
|
|
||||||
l.new_usertype<vec3<T>>(name,
|
|
||||||
sol::constructors<
|
|
||||||
vec3<T>(),
|
|
||||||
vec3<T>(T),
|
|
||||||
vec3<T>(T,T,T),
|
|
||||||
vec3<T>(vec2<T>,T),
|
|
||||||
vec3<T>(vec3<T>),
|
|
||||||
vec3<T>(vec4<T>)>(),
|
|
||||||
|
|
||||||
"zero", &vec3<T>::zero,
|
|
||||||
"unit", &vec3<T>::unit,
|
|
||||||
"unit_x", &vec3<T>::unit_x,
|
|
||||||
"unit_y", &vec3<T>::unit_y,
|
|
||||||
"unit_z", &vec3<T>::unit_z,
|
|
||||||
|
|
||||||
"x", &vec3<T>::x,
|
|
||||||
"y", &vec3<T>::y,
|
|
||||||
"z", &vec3<T>::z,
|
|
||||||
|
|
||||||
sol::meta_function::equal_to, sol::resolve<bool(const vec3<T>&, const vec3<T>&)>(::operator==),
|
|
||||||
sol::meta_function::less_than, sol::resolve<bool(const vec3<T>&, const vec3<T>&)>(::operator<),
|
|
||||||
sol::meta_function::less_than_or_equal_to, sol::resolve<bool(const vec3<T>&, const vec3<T>&)>(::operator<=),
|
|
||||||
|
|
||||||
sol::meta_function::unary_minus, sol::resolve<vec3<T>(const vec3<T>&)>(::operator-),
|
|
||||||
|
|
||||||
sol::meta_function::addition, sol::overload(
|
|
||||||
sol::resolve<vec3<T>(T, const vec3<T>&)>(::operator+),
|
|
||||||
sol::resolve<vec3<T>(const vec3<T>&, T)>(::operator+),
|
|
||||||
sol::resolve<vec3<T>(const vec3<T>&, const vec3<T>&)>(::operator+)),
|
|
||||||
|
|
||||||
sol::meta_function::subtraction, sol::overload(
|
|
||||||
sol::resolve<vec3<T>(T, const vec3<T>&)>(::operator-),
|
|
||||||
sol::resolve<vec3<T>(const vec3<T>&, T)>(::operator-),
|
|
||||||
sol::resolve<vec3<T>(const vec3<T>&, const vec3<T>&)>(::operator-)),
|
|
||||||
|
|
||||||
sol::meta_function::multiplication, sol::overload(
|
|
||||||
sol::resolve<vec3<T>(T, const vec3<T>&)>(::operator*),
|
|
||||||
sol::resolve<vec3<T>(const vec3<T>&, T)>(::operator*),
|
|
||||||
sol::resolve<vec3<T>(const vec3<T>&, const vec3<T>&)>(::operator*),
|
|
||||||
sol::resolve<vec3<T>(const vec3<T>&, const mat3<T>&)>(::operator*),
|
|
||||||
sol::resolve<vec3<T>(const vec3<T>&, const quat<T>&)>(::operator*)),
|
|
||||||
|
|
||||||
sol::meta_function::division, sol::overload(
|
|
||||||
sol::resolve<vec3<T>(T, const vec3<T>&)>(::operator/),
|
|
||||||
sol::resolve<vec3<T>(const vec3<T>&, T)>(::operator/),
|
|
||||||
sol::resolve<vec3<T>(const vec3<T>&, const vec3<T>&)>(::operator/)),
|
|
||||||
|
|
||||||
"approximately", [](const vec3<T>& l, const vec3<T>& r){ return math::approximately(l,r); },
|
|
||||||
|
|
||||||
"dot", sol::resolve<T(const vec3<T>&, const vec3<T>&)>(&math::dot),
|
|
||||||
"abs_dot", sol::resolve<T(const vec3<T>&, const vec3<T>&)>(&math::abs_dot),
|
|
||||||
|
|
||||||
"cross", sol::resolve<vec3<T>(const vec3<T>&, const vec3<T>&)>(&math::cross),
|
|
||||||
|
|
||||||
"length_squared", sol::resolve<T(const vec3<T>&)>(&math::length_squared),
|
|
||||||
"length", sol::resolve<T(const vec3<T>&)>(&math::length),
|
|
||||||
|
|
||||||
"distance_squared", sol::resolve<math::make_distance_t<T>(const vec3<T>&, const vec3<T>&)>(&math::distance_squared),
|
|
||||||
"distance", sol::resolve<T(const vec3<T>&, const vec3<T>&)>(&math::distance),
|
|
||||||
|
|
||||||
"normalized", [](const vec3<T>& v){ return math::normalized(v); },
|
|
||||||
|
|
||||||
"minimum", sol::resolve<T(const vec3<T>&)>(&math::minimum),
|
|
||||||
"maximum", sol::resolve<T(const vec3<T>&)>(&math::maximum),
|
|
||||||
|
|
||||||
"minimized", sol::resolve<vec3<T>(const vec3<T>&, const vec3<T>&)>(&math::minimized),
|
|
||||||
"maximized", sol::resolve<vec3<T>(const vec3<T>&, const vec3<T>&)>(&math::maximized),
|
|
||||||
"clamped", sol::resolve<vec3<T>(const vec3<T>&, const vec3<T>&, const vec3<T>&)>(&math::clamped),
|
|
||||||
"saturated", sol::resolve<vec3<T>(const vec3<T>&)>(&math::saturated),
|
|
||||||
|
|
||||||
"lerp", sol::resolve<vec3<T>(const vec3<T>&, const vec3<T>&, T)>(&math::lerp),
|
|
||||||
"lerp", sol::resolve<vec3<T>(const vec3<T>&, const vec3<T>&, const vec3<T>&)>(&math::lerp),
|
|
||||||
"inverse_lerp", sol::resolve<vec3<T>(const vec3<T>&, const vec3<T>&, const vec3<T>&)>(&math::inverse_lerp),
|
|
||||||
|
|
||||||
"contains_nan", sol::resolve<bool(const vec3<T>&)>(&math::contains_nan));
|
|
||||||
}
|
|
||||||
|
|
||||||
template < typename T >
|
|
||||||
void bind_vec4(const str& name, sol::state& l) {
|
|
||||||
l.new_usertype<vec4<T>>(name,
|
|
||||||
sol::constructors<
|
|
||||||
vec4<T>(),
|
|
||||||
vec4<T>(T),
|
|
||||||
vec4<T>(T,T,T,T),
|
|
||||||
vec4<T>(vec2<T>,T,T),
|
|
||||||
vec4<T>(vec3<T>,T),
|
|
||||||
vec4<T>(vec4<T>)>(),
|
|
||||||
|
|
||||||
"zero", &vec4<T>::zero,
|
|
||||||
"unit", &vec4<T>::unit,
|
|
||||||
"unit_x", &vec4<T>::unit_x,
|
|
||||||
"unit_y", &vec4<T>::unit_y,
|
|
||||||
"unit_z", &vec4<T>::unit_z,
|
|
||||||
"unit_w", &vec4<T>::unit_w,
|
|
||||||
|
|
||||||
"x", &vec4<T>::x,
|
|
||||||
"y", &vec4<T>::y,
|
|
||||||
"z", &vec4<T>::z,
|
|
||||||
"w", &vec4<T>::w,
|
|
||||||
|
|
||||||
sol::meta_function::equal_to, sol::resolve<bool(const vec4<T>&, const vec4<T>&)>(::operator==),
|
|
||||||
sol::meta_function::less_than, sol::resolve<bool(const vec4<T>&, const vec4<T>&)>(::operator<),
|
|
||||||
sol::meta_function::less_than_or_equal_to, sol::resolve<bool(const vec4<T>&, const vec4<T>&)>(::operator<=),
|
|
||||||
|
|
||||||
sol::meta_function::unary_minus, sol::resolve<vec4<T>(const vec4<T>&)>(::operator-),
|
|
||||||
|
|
||||||
sol::meta_function::addition, sol::overload(
|
|
||||||
sol::resolve<vec4<T>(T, const vec4<T>&)>(::operator+),
|
|
||||||
sol::resolve<vec4<T>(const vec4<T>&, T)>(::operator+),
|
|
||||||
sol::resolve<vec4<T>(const vec4<T>&, const vec4<T>&)>(::operator+)),
|
|
||||||
|
|
||||||
sol::meta_function::subtraction, sol::overload(
|
|
||||||
sol::resolve<vec4<T>(T, const vec4<T>&)>(::operator-),
|
|
||||||
sol::resolve<vec4<T>(const vec4<T>&, T)>(::operator-),
|
|
||||||
sol::resolve<vec4<T>(const vec4<T>&, const vec4<T>&)>(::operator-)),
|
|
||||||
|
|
||||||
sol::meta_function::multiplication, sol::overload(
|
|
||||||
sol::resolve<vec4<T>(T, const vec4<T>&)>(::operator*),
|
|
||||||
sol::resolve<vec4<T>(const vec4<T>&, T)>(::operator*),
|
|
||||||
sol::resolve<vec4<T>(const vec4<T>&, const vec4<T>&)>(::operator*),
|
|
||||||
sol::resolve<vec4<T>(const vec4<T>&, const mat4<T>&)>(::operator*)),
|
|
||||||
|
|
||||||
sol::meta_function::division, sol::overload(
|
|
||||||
sol::resolve<vec4<T>(T, const vec4<T>&)>(::operator/),
|
|
||||||
sol::resolve<vec4<T>(const vec4<T>&, T)>(::operator/),
|
|
||||||
sol::resolve<vec4<T>(const vec4<T>&, const vec4<T>&)>(::operator/)),
|
|
||||||
|
|
||||||
"approximately", [](const vec4<T>& l, const vec4<T>& r){ return math::approximately(l,r); },
|
|
||||||
|
|
||||||
"dot", sol::resolve<T(const vec4<T>&, const vec4<T>&)>(&math::dot),
|
|
||||||
"abs_dot", sol::resolve<T(const vec4<T>&, const vec4<T>&)>(&math::abs_dot),
|
|
||||||
|
|
||||||
"length_squared", sol::resolve<T(const vec4<T>&)>(&math::length_squared),
|
|
||||||
"length", sol::resolve<T(const vec4<T>&)>(&math::length),
|
|
||||||
|
|
||||||
"distance_squared", sol::resolve<math::make_distance_t<T>(const vec4<T>&, const vec4<T>&)>(&math::distance_squared),
|
|
||||||
"distance", sol::resolve<T(const vec4<T>&, const vec4<T>&)>(&math::distance),
|
|
||||||
|
|
||||||
"normalized", [](const vec4<T>& v){ return math::normalized(v); },
|
|
||||||
|
|
||||||
"minimum", sol::resolve<T(const vec4<T>&)>(&math::minimum),
|
|
||||||
"maximum", sol::resolve<T(const vec4<T>&)>(&math::maximum),
|
|
||||||
|
|
||||||
"minimized", sol::resolve<vec4<T>(const vec4<T>&, const vec4<T>&)>(&math::minimized),
|
|
||||||
"maximized", sol::resolve<vec4<T>(const vec4<T>&, const vec4<T>&)>(&math::maximized),
|
|
||||||
"clamped", sol::resolve<vec4<T>(const vec4<T>&, const vec4<T>&, const vec4<T>&)>(&math::clamped),
|
|
||||||
"saturated", sol::resolve<vec4<T>(const vec4<T>&)>(&math::saturated),
|
|
||||||
|
|
||||||
"lerp", sol::resolve<vec4<T>(const vec4<T>&, const vec4<T>&, T)>(&math::lerp),
|
|
||||||
"lerp", sol::resolve<vec4<T>(const vec4<T>&, const vec4<T>&, const vec4<T>&)>(&math::lerp),
|
|
||||||
"inverse_lerp", sol::resolve<vec4<T>(const vec4<T>&, const vec4<T>&, const vec4<T>&)>(&math::inverse_lerp),
|
|
||||||
|
|
||||||
"contains_nan", sol::resolve<bool(const vec4<T>&)>(&math::contains_nan));
|
|
||||||
}
|
|
||||||
|
|
||||||
template < typename T >
|
|
||||||
void bind_quat(const str& name, sol::state& l) {
|
|
||||||
l.new_usertype<quat<T>>(name,
|
|
||||||
sol::constructors<
|
|
||||||
quat<T>(),
|
|
||||||
quat<T>(quat<T>),
|
|
||||||
quat<T>(T,T,T,T),
|
|
||||||
quat<T>(vec4<T>)>(),
|
|
||||||
|
|
||||||
"x", &quat<T>::x,
|
|
||||||
"y", &quat<T>::y,
|
|
||||||
"z", &quat<T>::z,
|
|
||||||
"w", &quat<T>::w,
|
|
||||||
|
|
||||||
sol::meta_function::equal_to, sol::resolve<bool(const quat<T>&, const quat<T>&)>(::operator==),
|
|
||||||
sol::meta_function::less_than, sol::resolve<bool(const quat<T>&, const quat<T>&)>(::operator<),
|
|
||||||
sol::meta_function::less_than_or_equal_to, sol::resolve<bool(const quat<T>&, const quat<T>&)>(::operator<=),
|
|
||||||
|
|
||||||
sol::meta_function::addition, sol::overload(
|
|
||||||
sol::resolve<quat<T>(T, const quat<T>&)>(::operator+),
|
|
||||||
sol::resolve<quat<T>(const quat<T>&, T)>(::operator+),
|
|
||||||
sol::resolve<quat<T>(const quat<T>&, const quat<T>&)>(::operator+)),
|
|
||||||
|
|
||||||
sol::meta_function::multiplication, sol::overload(
|
|
||||||
sol::resolve<quat<T>(T, const quat<T>&)>(::operator*),
|
|
||||||
sol::resolve<quat<T>(const quat<T>&, T)>(::operator*),
|
|
||||||
sol::resolve<quat<T>(const quat<T>&, const quat<T>&)>(::operator*)),
|
|
||||||
|
|
||||||
"make_quat_from_axis_angle", sol::overload(
|
|
||||||
sol::resolve<quat<T>(const deg<T>&, const vec3<T>&)>(&math::make_quat_from_axis_angle),
|
|
||||||
sol::resolve<quat<T>(const rad<T>&, const vec3<T>&)>(&math::make_quat_from_axis_angle)),
|
|
||||||
|
|
||||||
"make_quat_from_euler_angles", sol::overload(
|
|
||||||
sol::resolve<quat<T>(const deg<T>&, const deg<T>&, const deg<T>&)>(&math::make_quat_from_euler_angles),
|
|
||||||
sol::resolve<quat<T>(const rad<T>&, const rad<T>&, const rad<T>&)>(&math::make_quat_from_euler_angles)),
|
|
||||||
|
|
||||||
"approximately", [](const quat<T>& l, const quat<T>& r){ return math::approximately(l,r); },
|
|
||||||
|
|
||||||
"dot", sol::resolve<T(const quat<T>&, const quat<T>&)>(&math::dot),
|
|
||||||
"abs_dot", sol::resolve<T(const quat<T>&, const quat<T>&)>(&math::abs_dot),
|
|
||||||
|
|
||||||
"length_squared", sol::resolve<T(const quat<T>&)>(&math::length_squared),
|
|
||||||
"length", sol::resolve<T(const quat<T>&)>(&math::length),
|
|
||||||
|
|
||||||
"normalized", [](const quat<T>& v){ return math::normalized(v); },
|
|
||||||
|
|
||||||
"lerp", sol::resolve<quat<T>(const quat<T>&, const quat<T>&, T)>(&math::lerp),
|
|
||||||
|
|
||||||
"inversed", [](const quat<T>& v){ return math::inversed(v); },
|
|
||||||
"conjugated", [](const quat<T>& v){ return math::conjugated(v); },
|
|
||||||
|
|
||||||
"contains_nan", sol::resolve<bool(const quat<T>&)>(&math::contains_nan));
|
|
||||||
}
|
|
||||||
|
|
||||||
template < typename T, typename Tag >
|
|
||||||
void bind_unit(const str& name, sol::state& l) {
|
|
||||||
l.new_usertype<unit<T,Tag>>(name,
|
|
||||||
sol::constructors<
|
|
||||||
unit<T,Tag>(),
|
|
||||||
unit<T,Tag>(T),
|
|
||||||
unit<T,Tag>(unit<T,Tag>)>(),
|
|
||||||
|
|
||||||
"value", &unit<T,Tag>::value,
|
|
||||||
|
|
||||||
sol::meta_function::equal_to, sol::resolve<bool(const unit<T,Tag>&, const unit<T,Tag>&)>(::operator==),
|
|
||||||
sol::meta_function::less_than, sol::resolve<bool(const unit<T,Tag>&, const unit<T,Tag>&)>(::operator<),
|
|
||||||
sol::meta_function::less_than_or_equal_to, sol::resolve<bool(const unit<T,Tag>&, const unit<T,Tag>&)>(::operator<=),
|
|
||||||
|
|
||||||
sol::meta_function::unary_minus, sol::resolve<unit<T,Tag>(const unit<T,Tag>&)>(::operator-),
|
|
||||||
|
|
||||||
sol::meta_function::multiplication, sol::overload(
|
|
||||||
sol::resolve<unit<T,Tag>(T, const unit<T,Tag>&)>(::operator*),
|
|
||||||
sol::resolve<unit<T,Tag>(const unit<T,Tag>&, T)>(::operator*)),
|
|
||||||
|
|
||||||
sol::meta_function::division, sol::overload(
|
|
||||||
sol::resolve<unit<T,Tag>(T, const unit<T,Tag>&)>(::operator/),
|
|
||||||
sol::resolve<unit<T,Tag>(const unit<T,Tag>&, T)>(::operator/)),
|
|
||||||
|
|
||||||
sol::meta_function::addition, sol::resolve<unit<T,Tag>(const unit<T,Tag>&, const unit<T,Tag>&)>(::operator+),
|
|
||||||
sol::meta_function::subtraction, sol::resolve<unit<T,Tag>(const unit<T,Tag>&, const unit<T,Tag>&)>(::operator-),
|
|
||||||
|
|
||||||
"approximately", [](const unit<T,Tag>& l, const unit<T,Tag>& r){ return math::approximately(l,r); },
|
|
||||||
|
|
||||||
"minimized", sol::resolve<unit<T,Tag>(const unit<T,Tag>&, const unit<T,Tag>&)>(&math::minimized),
|
|
||||||
"maximized", sol::resolve<unit<T,Tag>(const unit<T,Tag>&, const unit<T,Tag>&)>(&math::maximized),
|
|
||||||
"clamped", sol::resolve<unit<T,Tag>(const unit<T,Tag>&, const unit<T,Tag>&, const unit<T,Tag>&)>(&math::clamped),
|
|
||||||
"saturated", sol::resolve<unit<T,Tag>(const unit<T,Tag>&)>(&math::saturated),
|
|
||||||
|
|
||||||
"contains_nan", sol::resolve<bool(const unit<T,Tag>&)>(&math::contains_nan));
|
|
||||||
}
|
|
||||||
|
|
||||||
template < typename T >
|
|
||||||
void bind_mat2(const str& name, sol::state& l) {
|
|
||||||
l.new_usertype<mat2<T>>(name,
|
|
||||||
sol::constructors<
|
|
||||||
mat2<T>(),
|
|
||||||
mat2<T>(const vec2<T>&, const vec2<T>&)
|
|
||||||
>(),
|
|
||||||
|
|
||||||
"zero", &mat2<T>::zero,
|
|
||||||
"identity", &mat2<T>::identity,
|
|
||||||
|
|
||||||
"rows", &mat2<T>::rows,
|
|
||||||
|
|
||||||
sol::meta_function::equal_to, sol::resolve<bool(const mat2<T>&, const mat2<T>&)>(::operator==),
|
|
||||||
sol::meta_function::unary_minus, sol::resolve<mat2<T>(const mat2<T>&)>(::operator-),
|
|
||||||
|
|
||||||
sol::meta_function::addition, sol::overload(
|
|
||||||
sol::resolve<mat2<T>(T, const mat2<T>&)>(::operator+),
|
|
||||||
sol::resolve<mat2<T>(const mat2<T>&, T)>(::operator+),
|
|
||||||
sol::resolve<mat2<T>(const mat2<T>&, const mat2<T>&)>(::operator+)),
|
|
||||||
|
|
||||||
sol::meta_function::multiplication, sol::overload(
|
|
||||||
sol::resolve<mat2<T>(T, const mat2<T>&)>(::operator*),
|
|
||||||
sol::resolve<mat2<T>(const mat2<T>&, T)>(::operator*),
|
|
||||||
sol::resolve<mat2<T>(const mat2<T>&, const mat2<T>&)>(::operator*)),
|
|
||||||
|
|
||||||
"make_scale_matrix2", sol::overload(
|
|
||||||
sol::resolve<mat2<T>(T,T)>(&math::make_scale_matrix2),
|
|
||||||
sol::resolve<mat2<T>(const vec4<T>&)>(&math::make_scale_matrix2),
|
|
||||||
sol::resolve<mat2<T>(const vec3<T>&)>(&math::make_scale_matrix2),
|
|
||||||
sol::resolve<mat2<T>(const vec2<T>&)>(&math::make_scale_matrix2)),
|
|
||||||
|
|
||||||
"make_rotation_matrix2", sol::overload(
|
|
||||||
sol::resolve<mat2<T>(const deg<T>&)>(&math::make_rotation_matrix2),
|
|
||||||
sol::resolve<mat2<T>(const rad<T>&)>(&math::make_rotation_matrix2)),
|
|
||||||
|
|
||||||
"approximately", [](const mat2<T>& l, const mat2<T>& r){ return math::approximately(l,r); },
|
|
||||||
|
|
||||||
"inversed", [](const mat2<T>& m){ return math::inversed(m); },
|
|
||||||
"transposed", [](const mat2<T>& m){ return math::transposed(m); },
|
|
||||||
|
|
||||||
"contains_nan", sol::resolve<bool(const mat2<T>&)>(&math::contains_nan));
|
|
||||||
}
|
|
||||||
|
|
||||||
template < typename T >
|
|
||||||
void bind_mat3(const str& name, sol::state& l) {
|
|
||||||
l.new_usertype<mat3<T>>(name,
|
|
||||||
sol::constructors<
|
|
||||||
mat3<T>(),
|
|
||||||
mat3<T>(const vec3<T>&, const vec3<T>&, const vec3<T>&)
|
|
||||||
>(),
|
|
||||||
|
|
||||||
"zero", &mat3<T>::zero,
|
|
||||||
"identity", &mat3<T>::identity,
|
|
||||||
|
|
||||||
"rows", &mat3<T>::rows,
|
|
||||||
|
|
||||||
sol::meta_function::equal_to, sol::resolve<bool(const mat3<T>&, const mat3<T>&)>(::operator==),
|
|
||||||
sol::meta_function::unary_minus, sol::resolve<mat3<T>(const mat3<T>&)>(::operator-),
|
|
||||||
|
|
||||||
sol::meta_function::addition, sol::overload(
|
|
||||||
sol::resolve<mat3<T>(T, const mat3<T>&)>(::operator+),
|
|
||||||
sol::resolve<mat3<T>(const mat3<T>&, T)>(::operator+),
|
|
||||||
sol::resolve<mat3<T>(const mat3<T>&, const mat3<T>&)>(::operator+)),
|
|
||||||
|
|
||||||
sol::meta_function::multiplication, sol::overload(
|
|
||||||
sol::resolve<mat3<T>(T, const mat3<T>&)>(::operator*),
|
|
||||||
sol::resolve<mat3<T>(const mat3<T>&, T)>(::operator*),
|
|
||||||
sol::resolve<mat3<T>(const mat3<T>&, const mat3<T>&)>(::operator*)),
|
|
||||||
|
|
||||||
"make_scale_matrix3", sol::overload(
|
|
||||||
sol::resolve<mat3<T>(T,T,T)>(&math::make_scale_matrix3),
|
|
||||||
sol::resolve<mat3<T>(const vec4<T>&)>(&math::make_scale_matrix3),
|
|
||||||
sol::resolve<mat3<T>(const vec3<T>&)>(&math::make_scale_matrix3),
|
|
||||||
sol::resolve<mat3<T>(const vec2<T>&, T)>(&math::make_scale_matrix3)),
|
|
||||||
|
|
||||||
"make_rotation_matrix3", sol::overload(
|
|
||||||
sol::resolve<mat3<T>(const deg<T>&,T,T,T)>(&math::make_rotation_matrix3),
|
|
||||||
sol::resolve<mat3<T>(const deg<T>&,const vec4<T>&)>(&math::make_rotation_matrix3),
|
|
||||||
sol::resolve<mat3<T>(const deg<T>&,const vec3<T>&)>(&math::make_rotation_matrix3),
|
|
||||||
sol::resolve<mat3<T>(const deg<T>&,const vec2<T>&,T)>(&math::make_rotation_matrix3),
|
|
||||||
sol::resolve<mat3<T>(const rad<T>&,T,T,T)>(&math::make_rotation_matrix3),
|
|
||||||
sol::resolve<mat3<T>(const rad<T>&,const vec4<T>&)>(&math::make_rotation_matrix3),
|
|
||||||
sol::resolve<mat3<T>(const rad<T>&,const vec3<T>&)>(&math::make_rotation_matrix3),
|
|
||||||
sol::resolve<mat3<T>(const rad<T>&,const vec2<T>&,T)>(&math::make_rotation_matrix3),
|
|
||||||
sol::resolve<mat3<T>(const quat<T>&)>(&math::make_rotation_matrix3)),
|
|
||||||
|
|
||||||
"approximately", [](const mat3<T>& l, const mat3<T>& r){ return math::approximately(l,r); },
|
|
||||||
|
|
||||||
"inversed", [](const mat3<T>& m){ return math::inversed(m); },
|
|
||||||
"transposed", [](const mat3<T>& m){ return math::transposed(m); },
|
|
||||||
|
|
||||||
"contains_nan", sol::resolve<bool(const mat3<T>&)>(&math::contains_nan));
|
|
||||||
}
|
|
||||||
|
|
||||||
template < typename T >
|
|
||||||
void bind_mat4(const str& name, sol::state& l) {
|
|
||||||
l.new_usertype<mat4<T>>(name,
|
|
||||||
sol::constructors<
|
|
||||||
mat4<T>(),
|
|
||||||
mat4<T>(const vec4<T>&, const vec4<T>&, const vec4<T>&, const vec4<T>&)
|
|
||||||
>(),
|
|
||||||
|
|
||||||
"zero", &mat4<T>::zero,
|
|
||||||
"identity", &mat4<T>::identity,
|
|
||||||
|
|
||||||
"rows", &mat4<T>::rows,
|
|
||||||
|
|
||||||
sol::meta_function::equal_to, sol::resolve<bool(const mat4<T>&, const mat4<T>&)>(::operator==),
|
|
||||||
sol::meta_function::unary_minus, sol::resolve<mat4<T>(const mat4<T>&)>(::operator-),
|
|
||||||
|
|
||||||
sol::meta_function::addition, sol::overload(
|
|
||||||
sol::resolve<mat4<T>(T, const mat4<T>&)>(::operator+),
|
|
||||||
sol::resolve<mat4<T>(const mat4<T>&, T)>(::operator+),
|
|
||||||
sol::resolve<mat4<T>(const mat4<T>&, const mat4<T>&)>(::operator+)),
|
|
||||||
|
|
||||||
sol::meta_function::multiplication, sol::overload(
|
|
||||||
sol::resolve<mat4<T>(T, const mat4<T>&)>(::operator*),
|
|
||||||
sol::resolve<mat4<T>(const mat4<T>&, T)>(::operator*),
|
|
||||||
sol::resolve<mat4<T>(const mat4<T>&, const mat4<T>&)>(::operator*)),
|
|
||||||
|
|
||||||
"make_scale_matrix4", sol::overload(
|
|
||||||
sol::resolve<mat4<T>(T,T,T)>(&math::make_scale_matrix4),
|
|
||||||
sol::resolve<mat4<T>(const vec4<T>&)>(&math::make_scale_matrix4),
|
|
||||||
sol::resolve<mat4<T>(const vec3<T>&)>(&math::make_scale_matrix4),
|
|
||||||
sol::resolve<mat4<T>(const vec2<T>&, T)>(&math::make_scale_matrix4)),
|
|
||||||
|
|
||||||
"make_translation_matrix4", sol::overload(
|
|
||||||
sol::resolve<mat4<T>(T,T,T)>(&math::make_translation_matrix4),
|
|
||||||
sol::resolve<mat4<T>(const vec4<T>&)>(&math::make_translation_matrix4),
|
|
||||||
sol::resolve<mat4<T>(const vec3<T>&)>(&math::make_translation_matrix4),
|
|
||||||
sol::resolve<mat4<T>(const vec2<T>&, T)>(&math::make_translation_matrix4)),
|
|
||||||
|
|
||||||
"make_rotation_matrix4", sol::overload(
|
|
||||||
sol::resolve<mat4<T>(const deg<T>&,T,T,T)>(&math::make_rotation_matrix4),
|
|
||||||
sol::resolve<mat4<T>(const deg<T>&,const vec4<T>&)>(&math::make_rotation_matrix4),
|
|
||||||
sol::resolve<mat4<T>(const deg<T>&,const vec3<T>&)>(&math::make_rotation_matrix4),
|
|
||||||
sol::resolve<mat4<T>(const deg<T>&,const vec2<T>&,T)>(&math::make_rotation_matrix4),
|
|
||||||
sol::resolve<mat4<T>(const rad<T>&,T,T,T)>(&math::make_rotation_matrix4),
|
|
||||||
sol::resolve<mat4<T>(const rad<T>&,const vec4<T>&)>(&math::make_rotation_matrix4),
|
|
||||||
sol::resolve<mat4<T>(const rad<T>&,const vec3<T>&)>(&math::make_rotation_matrix4),
|
|
||||||
sol::resolve<mat4<T>(const rad<T>&,const vec2<T>&,T)>(&math::make_rotation_matrix4),
|
|
||||||
sol::resolve<mat4<T>(const quat<T>&)>(&math::make_rotation_matrix4)),
|
|
||||||
|
|
||||||
"approximately", [](const mat4<T>& l, const mat4<T>& r){ return math::approximately(l,r); },
|
|
||||||
|
|
||||||
"inversed", [](const mat4<T>& m){ return math::inversed(m); },
|
|
||||||
"transposed", [](const mat4<T>& m){ return math::transposed(m); },
|
|
||||||
|
|
||||||
"contains_nan", sol::resolve<bool(const mat4<T>&)>(&math::contains_nan));
|
|
||||||
}
|
|
||||||
|
|
||||||
template < typename T >
|
|
||||||
void bind_rect(const str& name, sol::state& l) {
|
|
||||||
l.new_usertype<rect<T>>(name,
|
|
||||||
sol::constructors<
|
|
||||||
rect<T>(),
|
|
||||||
rect<T>(rect<T>),
|
|
||||||
rect<T>(T,T),
|
|
||||||
rect<T>(T,T,T,T),
|
|
||||||
rect<T>(vec2<T>),
|
|
||||||
rect<T>(vec2<T>,vec2<T>)>(),
|
|
||||||
|
|
||||||
"zero", &rect<T>::zero,
|
|
||||||
"unit", &rect<T>::unit,
|
|
||||||
|
|
||||||
"position", &rect<T>::position,
|
|
||||||
"size", &rect<T>::size,
|
|
||||||
|
|
||||||
sol::meta_function::equal_to, sol::resolve<bool(const rect<T>&, const rect<T>&)>(::operator==),
|
|
||||||
sol::meta_function::less_than, sol::resolve<bool(const rect<T>&, const rect<T>&)>(::operator<),
|
|
||||||
sol::meta_function::less_than_or_equal_to, sol::resolve<bool(const rect<T>&, const rect<T>&)>(::operator<=),
|
|
||||||
|
|
||||||
sol::meta_function::addition, sol::overload(
|
|
||||||
sol::resolve<rect<T>(const rect<T>&, T)>(::operator+),
|
|
||||||
sol::resolve<rect<T>(const rect<T>&, const vec2<T>&)>(::operator+)),
|
|
||||||
|
|
||||||
sol::meta_function::subtraction, sol::overload(
|
|
||||||
sol::resolve<rect<T>(const rect<T>&, T)>(::operator-),
|
|
||||||
sol::resolve<rect<T>(const rect<T>&, const vec2<T>&)>(::operator-)),
|
|
||||||
|
|
||||||
sol::meta_function::multiplication, sol::overload(
|
|
||||||
sol::resolve<rect<T>(const rect<T>&, T)>(::operator*),
|
|
||||||
sol::resolve<rect<T>(const rect<T>&, const vec2<T>&)>(::operator*)),
|
|
||||||
|
|
||||||
sol::meta_function::division, sol::overload(
|
|
||||||
sol::resolve<rect<T>(const rect<T>&, T)>(::operator/),
|
|
||||||
sol::resolve<rect<T>(const rect<T>&, const vec2<T>&)>(::operator/)),
|
|
||||||
|
|
||||||
"make_minmax_rect", sol::overload(
|
|
||||||
sol::resolve<rect<T>(T,T,T,T)>(&math::make_minmax_rect),
|
|
||||||
sol::resolve<rect<T>(const vec2<T>&,const vec2<T>&)>(&math::make_minmax_rect),
|
|
||||||
sol::resolve<rect<T>(const rect<T>&)>(&math::make_minmax_rect)),
|
|
||||||
|
|
||||||
"approximately", [](const rect<T>& l, const rect<T>& r){ return math::approximately(l,r); },
|
|
||||||
|
|
||||||
"minimum", sol::resolve<vec2<T>(const rect<T>&)>(&math::minimum),
|
|
||||||
"maximum", sol::resolve<vec2<T>(const rect<T>&)>(&math::maximum),
|
|
||||||
|
|
||||||
"area", sol::resolve<T(const rect<T>&)>(&math::area),
|
|
||||||
"abs_area", sol::resolve<T(const rect<T>&)>(&math::abs_area),
|
|
||||||
|
|
||||||
"merged", sol::resolve<rect<T>(const rect<T>&,const rect<T>&)>(&math::merged),
|
|
||||||
"inside", sol::resolve<bool(const rect<T>&,const vec2<T>&)>(&math::inside),
|
|
||||||
"overlaps", sol::resolve<bool(const rect<T>&,const rect<T>&)>(&math::overlaps),
|
|
||||||
|
|
||||||
"normalized_to_point", sol::resolve<vec2<T>(const rect<T>&,const vec2<T>&)>(&math::normalized_to_point),
|
|
||||||
"point_to_normalized", sol::resolve<vec2<T>(const rect<T>&,const vec2<T>&)>(&math::point_to_normalized),
|
|
||||||
|
|
||||||
"contains_nan", sol::resolve<bool(const rect<T>&)>(&math::contains_nan));
|
|
||||||
}
|
|
||||||
|
|
||||||
template < typename T >
|
|
||||||
void bind_aabb(const str& name, sol::state& l) {
|
|
||||||
l.new_usertype<aabb<T>>(name,
|
|
||||||
sol::constructors<
|
|
||||||
aabb<T>(),
|
|
||||||
aabb<T>(aabb<T>),
|
|
||||||
aabb<T>(T,T,T),
|
|
||||||
aabb<T>(T,T,T,T,T,T),
|
|
||||||
aabb<T>(vec3<T>),
|
|
||||||
aabb<T>(vec3<T>,vec3<T>)>(),
|
|
||||||
|
|
||||||
"zero", &aabb<T>::zero,
|
|
||||||
"unit", &aabb<T>::unit,
|
|
||||||
|
|
||||||
"position", &aabb<T>::position,
|
|
||||||
"size", &aabb<T>::size,
|
|
||||||
|
|
||||||
sol::meta_function::equal_to, sol::resolve<bool(const aabb<T>&, const aabb<T>&)>(::operator==),
|
|
||||||
sol::meta_function::less_than, sol::resolve<bool(const aabb<T>&, const aabb<T>&)>(::operator<),
|
|
||||||
sol::meta_function::less_than_or_equal_to, sol::resolve<bool(const aabb<T>&, const aabb<T>&)>(::operator<=),
|
|
||||||
|
|
||||||
sol::meta_function::addition, sol::overload(
|
|
||||||
sol::resolve<aabb<T>(const aabb<T>&, T)>(::operator+),
|
|
||||||
sol::resolve<aabb<T>(const aabb<T>&, const vec3<T>&)>(::operator+)),
|
|
||||||
|
|
||||||
sol::meta_function::subtraction, sol::overload(
|
|
||||||
sol::resolve<aabb<T>(const aabb<T>&, T)>(::operator-),
|
|
||||||
sol::resolve<aabb<T>(const aabb<T>&, const vec3<T>&)>(::operator-)),
|
|
||||||
|
|
||||||
sol::meta_function::multiplication, sol::overload(
|
|
||||||
sol::resolve<aabb<T>(const aabb<T>&, T)>(::operator*),
|
|
||||||
sol::resolve<aabb<T>(const aabb<T>&, const vec3<T>&)>(::operator*)),
|
|
||||||
|
|
||||||
sol::meta_function::division, sol::overload(
|
|
||||||
sol::resolve<aabb<T>(const aabb<T>&, T)>(::operator/),
|
|
||||||
sol::resolve<aabb<T>(const aabb<T>&, const vec3<T>&)>(::operator/)),
|
|
||||||
|
|
||||||
"make_minmax_rect", sol::overload(
|
|
||||||
sol::resolve<aabb<T>(T,T,T,T,T,T)>(&math::make_minmax_aabb),
|
|
||||||
sol::resolve<aabb<T>(const vec3<T>&,const vec3<T>&)>(&math::make_minmax_aabb),
|
|
||||||
sol::resolve<aabb<T>(const aabb<T>&)>(&math::make_minmax_aabb)),
|
|
||||||
|
|
||||||
"approximately", [](const aabb<T>& l, const aabb<T>& r){ return math::approximately(l,r); },
|
|
||||||
|
|
||||||
"minimum", sol::resolve<vec3<T>(const aabb<T>&)>(&math::minimum),
|
|
||||||
"maximum", sol::resolve<vec3<T>(const aabb<T>&)>(&math::maximum),
|
|
||||||
|
|
||||||
"volume", sol::resolve<T(const aabb<T>&)>(&math::volume),
|
|
||||||
"abs_volume", sol::resolve<T(const aabb<T>&)>(&math::abs_volume),
|
|
||||||
|
|
||||||
"merged", sol::resolve<aabb<T>(const aabb<T>&,const aabb<T>&)>(&math::merged),
|
|
||||||
"inside", sol::resolve<bool(const aabb<T>&,const vec3<T>&)>(&math::inside),
|
|
||||||
"overlaps", sol::resolve<bool(const aabb<T>&,const aabb<T>&)>(&math::overlaps),
|
|
||||||
|
|
||||||
"normalized_to_point", sol::resolve<vec3<T>(const aabb<T>&,const vec3<T>&)>(&math::normalized_to_point),
|
|
||||||
"point_to_normalized", sol::resolve<vec3<T>(const aabb<T>&,const vec3<T>&)>(&math::point_to_normalized),
|
|
||||||
|
|
||||||
"contains_nan", sol::resolve<bool(const aabb<T>&)>(&math::contains_nan));
|
|
||||||
}
|
|
||||||
|
|
||||||
template < typename T >
|
|
||||||
void bind_trs2(const str& name, sol::state& l) {
|
|
||||||
l.new_usertype<trs2<T>>(name,
|
|
||||||
sol::constructors<
|
|
||||||
trs2<T>(),
|
|
||||||
trs2<T>(trs2<T>),
|
|
||||||
trs2<T>(vec2<T>,deg<T>,vec2<T>),
|
|
||||||
trs2<T>(vec2<T>,rad<T>,vec2<T>)>(),
|
|
||||||
|
|
||||||
"zero", &trs2<T>::zero,
|
|
||||||
"unit", &trs2<T>::identity,
|
|
||||||
|
|
||||||
"translation", &trs2<T>::translation,
|
|
||||||
"rotation", &trs2<T>::rotation,
|
|
||||||
"scale", &trs2<T>::scale,
|
|
||||||
|
|
||||||
sol::meta_function::equal_to, sol::resolve<bool(const trs2<T>&, const trs2<T>&)>(::operator==),
|
|
||||||
|
|
||||||
"make_translation_trs2", sol::resolve<trs2<T>(const vec2<T>&)>(&math::make_translation_trs2),
|
|
||||||
"make_rotation_trs2", sol::overload(
|
|
||||||
sol::resolve<trs2<T>(const deg<T>&)>(&math::make_rotation_trs2),
|
|
||||||
sol::resolve<trs2<T>(const rad<T>&)>(&math::make_rotation_trs2)),
|
|
||||||
"make_scale_trs2", sol::resolve<trs2<T>(const vec2<T>&)>(&math::make_scale_trs2),
|
|
||||||
|
|
||||||
"approximately", [](const trs2<T>& l, const trs2<T>& r){ return math::approximately(l,r); },
|
|
||||||
"contains_nan", sol::resolve<bool(const trs2<T>&)>(&math::contains_nan));
|
|
||||||
}
|
|
||||||
|
|
||||||
template < typename T >
|
|
||||||
void bind_trs3(const str& name, sol::state& l) {
|
|
||||||
l.new_usertype<trs3<T>>(name,
|
|
||||||
sol::constructors<
|
|
||||||
trs3<T>(),
|
|
||||||
trs3<T>(trs3<T>),
|
|
||||||
trs3<T>(vec3<T>,quat<T>,vec3<T>)>(),
|
|
||||||
|
|
||||||
"zero", &trs3<T>::zero,
|
|
||||||
"unit", &trs3<T>::identity,
|
|
||||||
|
|
||||||
"translation", &trs3<T>::translation,
|
|
||||||
"rotation", &trs3<T>::rotation,
|
|
||||||
"scale", &trs3<T>::scale,
|
|
||||||
|
|
||||||
sol::meta_function::equal_to, sol::resolve<bool(const trs3<T>&, const trs3<T>&)>(::operator==),
|
|
||||||
|
|
||||||
"make_translation_trs3", sol::resolve<trs3<T>(const vec3<T>&)>(&math::make_translation_trs3),
|
|
||||||
"make_rotation_trs3", sol::resolve<trs3<T>(const quat<T>&)>(&math::make_rotation_trs3),
|
|
||||||
"make_scale_trs3", sol::resolve<trs3<T>(const vec3<T>&)>(&math::make_scale_trs3),
|
|
||||||
|
|
||||||
"approximately", [](const trs3<T>& l, const trs3<T>& r){ return math::approximately(l,r); },
|
|
||||||
"contains_nan", sol::resolve<bool(const trs3<T>&)>(&math::contains_nan));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace e2d::bindings
|
|
||||||
{
|
|
||||||
void bind_math(sol::state& l) {
|
|
||||||
bind_vec2<f32>("v2f", l);
|
|
||||||
bind_vec3<f32>("v3f", l);
|
|
||||||
bind_vec4<f32>("v4f", l);
|
|
||||||
bind_quat<f32>("q4f", l);
|
|
||||||
bind_unit<f32, deg_tag>("degf", l);
|
|
||||||
bind_unit<f32, rad_tag>("radf", l);
|
|
||||||
bind_mat2<f32>("m2f", l);
|
|
||||||
bind_mat3<f32>("m3f", l);
|
|
||||||
bind_mat4<f32>("m4f", l);
|
|
||||||
bind_rect<f32>("b2f", l);
|
|
||||||
bind_aabb<f32>("b3f", l);
|
|
||||||
bind_trs2<f32>("t2f", l);
|
|
||||||
bind_trs3<f32>("t3f", l);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
53
sources/enduro2d/high/bindings/math_binds/_math_binds.hpp
Normal file
53
sources/enduro2d/high/bindings/math_binds/_math_binds.hpp
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "Enduro2D"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "../bindings.hpp"
|
||||||
|
|
||||||
|
namespace e2d::bindings::math
|
||||||
|
{
|
||||||
|
void bind_vec2(sol::state& l);
|
||||||
|
void bind_vec3(sol::state& l);
|
||||||
|
void bind_vec4(sol::state& l);
|
||||||
|
|
||||||
|
void bind_mat2(sol::state& l);
|
||||||
|
void bind_mat3(sol::state& l);
|
||||||
|
void bind_mat4(sol::state& l);
|
||||||
|
|
||||||
|
void bind_quat(sol::state& l);
|
||||||
|
|
||||||
|
void bind_rect(sol::state& l);
|
||||||
|
void bind_aabb(sol::state& l);
|
||||||
|
|
||||||
|
void bind_trs2(sol::state& l);
|
||||||
|
void bind_trs3(sol::state& l);
|
||||||
|
|
||||||
|
void bind_unit(sol::state& l);
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace e2d::bindings
|
||||||
|
{
|
||||||
|
inline void bind_math(sol::state& l) {
|
||||||
|
math::bind_vec2(l);
|
||||||
|
math::bind_vec3(l);
|
||||||
|
math::bind_vec4(l);
|
||||||
|
|
||||||
|
math::bind_mat2(l);
|
||||||
|
math::bind_mat3(l);
|
||||||
|
math::bind_mat4(l);
|
||||||
|
|
||||||
|
math::bind_quat(l);
|
||||||
|
|
||||||
|
math::bind_rect(l);
|
||||||
|
math::bind_aabb(l);
|
||||||
|
|
||||||
|
math::bind_trs2(l);
|
||||||
|
math::bind_trs3(l);
|
||||||
|
|
||||||
|
math::bind_unit(l);
|
||||||
|
}
|
||||||
|
}
|
||||||
80
sources/enduro2d/high/bindings/math_binds/aabb_binds.cpp
Normal file
80
sources/enduro2d/high/bindings/math_binds/aabb_binds.cpp
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "Enduro2D"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "_math_binds.hpp"
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
using namespace e2d;
|
||||||
|
|
||||||
|
template < typename T >
|
||||||
|
void bind_aabb_t(const str& name, sol::state& l) {
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<aabb<T>>(name,
|
||||||
|
sol::constructors<
|
||||||
|
aabb<T>(),
|
||||||
|
aabb<T>(aabb<T>),
|
||||||
|
aabb<T>(T,T,T),
|
||||||
|
aabb<T>(T,T,T,T,T,T),
|
||||||
|
aabb<T>(vec3<T>),
|
||||||
|
aabb<T>(vec3<T>,vec3<T>)>(),
|
||||||
|
|
||||||
|
"zero", &aabb<T>::zero,
|
||||||
|
"unit", &aabb<T>::unit,
|
||||||
|
|
||||||
|
"position", &aabb<T>::position,
|
||||||
|
"size", &aabb<T>::size,
|
||||||
|
|
||||||
|
sol::meta_function::equal_to, sol::resolve<bool(const aabb<T>&, const aabb<T>&)>(::operator==),
|
||||||
|
sol::meta_function::less_than, sol::resolve<bool(const aabb<T>&, const aabb<T>&)>(::operator<),
|
||||||
|
sol::meta_function::less_than_or_equal_to, sol::resolve<bool(const aabb<T>&, const aabb<T>&)>(::operator<=),
|
||||||
|
|
||||||
|
sol::meta_function::addition, sol::overload(
|
||||||
|
sol::resolve<aabb<T>(const aabb<T>&, T)>(::operator+),
|
||||||
|
sol::resolve<aabb<T>(const aabb<T>&, const vec3<T>&)>(::operator+)),
|
||||||
|
|
||||||
|
sol::meta_function::subtraction, sol::overload(
|
||||||
|
sol::resolve<aabb<T>(const aabb<T>&, T)>(::operator-),
|
||||||
|
sol::resolve<aabb<T>(const aabb<T>&, const vec3<T>&)>(::operator-)),
|
||||||
|
|
||||||
|
sol::meta_function::multiplication, sol::overload(
|
||||||
|
sol::resolve<aabb<T>(const aabb<T>&, T)>(::operator*),
|
||||||
|
sol::resolve<aabb<T>(const aabb<T>&, const vec3<T>&)>(::operator*)),
|
||||||
|
|
||||||
|
sol::meta_function::division, sol::overload(
|
||||||
|
sol::resolve<aabb<T>(const aabb<T>&, T)>(::operator/),
|
||||||
|
sol::resolve<aabb<T>(const aabb<T>&, const vec3<T>&)>(::operator/)),
|
||||||
|
|
||||||
|
"make_minmax_rect", sol::overload(
|
||||||
|
sol::resolve<aabb<T>(T,T,T,T,T,T)>(&math::make_minmax_aabb),
|
||||||
|
sol::resolve<aabb<T>(const vec3<T>&,const vec3<T>&)>(&math::make_minmax_aabb),
|
||||||
|
sol::resolve<aabb<T>(const aabb<T>&)>(&math::make_minmax_aabb)),
|
||||||
|
|
||||||
|
"approximately", [](const aabb<T>& l, const aabb<T>& r){ return math::approximately(l,r); },
|
||||||
|
|
||||||
|
"minimum", sol::resolve<vec3<T>(const aabb<T>&)>(&math::minimum),
|
||||||
|
"maximum", sol::resolve<vec3<T>(const aabb<T>&)>(&math::maximum),
|
||||||
|
|
||||||
|
"volume", sol::resolve<T(const aabb<T>&)>(&math::volume),
|
||||||
|
"abs_volume", sol::resolve<T(const aabb<T>&)>(&math::abs_volume),
|
||||||
|
|
||||||
|
"merged", sol::resolve<aabb<T>(const aabb<T>&,const aabb<T>&)>(&math::merged),
|
||||||
|
"inside", sol::resolve<bool(const aabb<T>&,const vec3<T>&)>(&math::inside),
|
||||||
|
"overlaps", sol::resolve<bool(const aabb<T>&,const aabb<T>&)>(&math::overlaps),
|
||||||
|
|
||||||
|
"normalized_to_point", sol::resolve<vec3<T>(const aabb<T>&,const vec3<T>&)>(&math::normalized_to_point),
|
||||||
|
"point_to_normalized", sol::resolve<vec3<T>(const aabb<T>&,const vec3<T>&)>(&math::point_to_normalized),
|
||||||
|
|
||||||
|
"contains_nan", sol::resolve<bool(const aabb<T>&)>(&math::contains_nan));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace e2d::bindings::math
|
||||||
|
{
|
||||||
|
void bind_aabb(sol::state& l) {
|
||||||
|
bind_aabb_t<f32>("b3f", l);
|
||||||
|
}
|
||||||
|
}
|
||||||
64
sources/enduro2d/high/bindings/math_binds/mat2_binds.cpp
Normal file
64
sources/enduro2d/high/bindings/math_binds/mat2_binds.cpp
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "Enduro2D"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "_math_binds.hpp"
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
using namespace e2d;
|
||||||
|
|
||||||
|
template < typename T >
|
||||||
|
void bind_mat2_t(const str& name, sol::state& l) {
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<mat2<T>>(name,
|
||||||
|
sol::constructors<
|
||||||
|
mat2<T>(),
|
||||||
|
mat2<T>(const vec2<T>&, const vec2<T>&)
|
||||||
|
>(),
|
||||||
|
|
||||||
|
"zero", &mat2<T>::zero,
|
||||||
|
"identity", &mat2<T>::identity,
|
||||||
|
|
||||||
|
"rows", &mat2<T>::rows,
|
||||||
|
|
||||||
|
sol::meta_function::equal_to, sol::resolve<bool(const mat2<T>&, const mat2<T>&)>(::operator==),
|
||||||
|
sol::meta_function::unary_minus, sol::resolve<mat2<T>(const mat2<T>&)>(::operator-),
|
||||||
|
|
||||||
|
sol::meta_function::addition, sol::overload(
|
||||||
|
sol::resolve<mat2<T>(T, const mat2<T>&)>(::operator+),
|
||||||
|
sol::resolve<mat2<T>(const mat2<T>&, T)>(::operator+),
|
||||||
|
sol::resolve<mat2<T>(const mat2<T>&, const mat2<T>&)>(::operator+)),
|
||||||
|
|
||||||
|
sol::meta_function::multiplication, sol::overload(
|
||||||
|
sol::resolve<mat2<T>(T, const mat2<T>&)>(::operator*),
|
||||||
|
sol::resolve<mat2<T>(const mat2<T>&, T)>(::operator*),
|
||||||
|
sol::resolve<mat2<T>(const mat2<T>&, const mat2<T>&)>(::operator*)),
|
||||||
|
|
||||||
|
"make_scale_matrix2", sol::overload(
|
||||||
|
sol::resolve<mat2<T>(T,T)>(&math::make_scale_matrix2),
|
||||||
|
sol::resolve<mat2<T>(const vec4<T>&)>(&math::make_scale_matrix2),
|
||||||
|
sol::resolve<mat2<T>(const vec3<T>&)>(&math::make_scale_matrix2),
|
||||||
|
sol::resolve<mat2<T>(const vec2<T>&)>(&math::make_scale_matrix2)),
|
||||||
|
|
||||||
|
"make_rotation_matrix2", sol::overload(
|
||||||
|
sol::resolve<mat2<T>(const deg<T>&)>(&math::make_rotation_matrix2),
|
||||||
|
sol::resolve<mat2<T>(const rad<T>&)>(&math::make_rotation_matrix2)),
|
||||||
|
|
||||||
|
"approximately", [](const mat2<T>& l, const mat2<T>& r){ return math::approximately(l,r); },
|
||||||
|
|
||||||
|
"inversed", [](const mat2<T>& m){ return math::inversed(m); },
|
||||||
|
"transposed", [](const mat2<T>& m){ return math::transposed(m); },
|
||||||
|
|
||||||
|
"contains_nan", sol::resolve<bool(const mat2<T>&)>(&math::contains_nan));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace e2d::bindings::math
|
||||||
|
{
|
||||||
|
void bind_mat2(sol::state& l) {
|
||||||
|
bind_mat2_t<f32>("m2f", l);
|
||||||
|
}
|
||||||
|
}
|
||||||
71
sources/enduro2d/high/bindings/math_binds/mat3_binds.cpp
Normal file
71
sources/enduro2d/high/bindings/math_binds/mat3_binds.cpp
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "Enduro2D"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "_math_binds.hpp"
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
using namespace e2d;
|
||||||
|
|
||||||
|
template < typename T >
|
||||||
|
void bind_mat3_t(const str& name, sol::state& l) {
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<mat3<T>>(name,
|
||||||
|
sol::constructors<
|
||||||
|
mat3<T>(),
|
||||||
|
mat3<T>(const vec3<T>&, const vec3<T>&, const vec3<T>&)
|
||||||
|
>(),
|
||||||
|
|
||||||
|
"zero", &mat3<T>::zero,
|
||||||
|
"identity", &mat3<T>::identity,
|
||||||
|
|
||||||
|
"rows", &mat3<T>::rows,
|
||||||
|
|
||||||
|
sol::meta_function::equal_to, sol::resolve<bool(const mat3<T>&, const mat3<T>&)>(::operator==),
|
||||||
|
sol::meta_function::unary_minus, sol::resolve<mat3<T>(const mat3<T>&)>(::operator-),
|
||||||
|
|
||||||
|
sol::meta_function::addition, sol::overload(
|
||||||
|
sol::resolve<mat3<T>(T, const mat3<T>&)>(::operator+),
|
||||||
|
sol::resolve<mat3<T>(const mat3<T>&, T)>(::operator+),
|
||||||
|
sol::resolve<mat3<T>(const mat3<T>&, const mat3<T>&)>(::operator+)),
|
||||||
|
|
||||||
|
sol::meta_function::multiplication, sol::overload(
|
||||||
|
sol::resolve<mat3<T>(T, const mat3<T>&)>(::operator*),
|
||||||
|
sol::resolve<mat3<T>(const mat3<T>&, T)>(::operator*),
|
||||||
|
sol::resolve<mat3<T>(const mat3<T>&, const mat3<T>&)>(::operator*)),
|
||||||
|
|
||||||
|
"make_scale_matrix3", sol::overload(
|
||||||
|
sol::resolve<mat3<T>(T,T,T)>(&math::make_scale_matrix3),
|
||||||
|
sol::resolve<mat3<T>(const vec4<T>&)>(&math::make_scale_matrix3),
|
||||||
|
sol::resolve<mat3<T>(const vec3<T>&)>(&math::make_scale_matrix3),
|
||||||
|
sol::resolve<mat3<T>(const vec2<T>&, T)>(&math::make_scale_matrix3)),
|
||||||
|
|
||||||
|
"make_rotation_matrix3", sol::overload(
|
||||||
|
sol::resolve<mat3<T>(const deg<T>&,T,T,T)>(&math::make_rotation_matrix3),
|
||||||
|
sol::resolve<mat3<T>(const deg<T>&,const vec4<T>&)>(&math::make_rotation_matrix3),
|
||||||
|
sol::resolve<mat3<T>(const deg<T>&,const vec3<T>&)>(&math::make_rotation_matrix3),
|
||||||
|
sol::resolve<mat3<T>(const deg<T>&,const vec2<T>&,T)>(&math::make_rotation_matrix3),
|
||||||
|
sol::resolve<mat3<T>(const rad<T>&,T,T,T)>(&math::make_rotation_matrix3),
|
||||||
|
sol::resolve<mat3<T>(const rad<T>&,const vec4<T>&)>(&math::make_rotation_matrix3),
|
||||||
|
sol::resolve<mat3<T>(const rad<T>&,const vec3<T>&)>(&math::make_rotation_matrix3),
|
||||||
|
sol::resolve<mat3<T>(const rad<T>&,const vec2<T>&,T)>(&math::make_rotation_matrix3),
|
||||||
|
sol::resolve<mat3<T>(const quat<T>&)>(&math::make_rotation_matrix3)),
|
||||||
|
|
||||||
|
"approximately", [](const mat3<T>& l, const mat3<T>& r){ return math::approximately(l,r); },
|
||||||
|
|
||||||
|
"inversed", [](const mat3<T>& m){ return math::inversed(m); },
|
||||||
|
"transposed", [](const mat3<T>& m){ return math::transposed(m); },
|
||||||
|
|
||||||
|
"contains_nan", sol::resolve<bool(const mat3<T>&)>(&math::contains_nan));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace e2d::bindings::math
|
||||||
|
{
|
||||||
|
void bind_mat3(sol::state& l) {
|
||||||
|
bind_mat3_t<f32>("m3f", l);
|
||||||
|
}
|
||||||
|
}
|
||||||
77
sources/enduro2d/high/bindings/math_binds/mat4_binds.cpp
Normal file
77
sources/enduro2d/high/bindings/math_binds/mat4_binds.cpp
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "Enduro2D"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "_math_binds.hpp"
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
using namespace e2d;
|
||||||
|
|
||||||
|
template < typename T >
|
||||||
|
void bind_mat4_t(const str& name, sol::state& l) {
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<mat4<T>>(name,
|
||||||
|
sol::constructors<
|
||||||
|
mat4<T>(),
|
||||||
|
mat4<T>(const vec4<T>&, const vec4<T>&, const vec4<T>&, const vec4<T>&)
|
||||||
|
>(),
|
||||||
|
|
||||||
|
"zero", &mat4<T>::zero,
|
||||||
|
"identity", &mat4<T>::identity,
|
||||||
|
|
||||||
|
"rows", &mat4<T>::rows,
|
||||||
|
|
||||||
|
sol::meta_function::equal_to, sol::resolve<bool(const mat4<T>&, const mat4<T>&)>(::operator==),
|
||||||
|
sol::meta_function::unary_minus, sol::resolve<mat4<T>(const mat4<T>&)>(::operator-),
|
||||||
|
|
||||||
|
sol::meta_function::addition, sol::overload(
|
||||||
|
sol::resolve<mat4<T>(T, const mat4<T>&)>(::operator+),
|
||||||
|
sol::resolve<mat4<T>(const mat4<T>&, T)>(::operator+),
|
||||||
|
sol::resolve<mat4<T>(const mat4<T>&, const mat4<T>&)>(::operator+)),
|
||||||
|
|
||||||
|
sol::meta_function::multiplication, sol::overload(
|
||||||
|
sol::resolve<mat4<T>(T, const mat4<T>&)>(::operator*),
|
||||||
|
sol::resolve<mat4<T>(const mat4<T>&, T)>(::operator*),
|
||||||
|
sol::resolve<mat4<T>(const mat4<T>&, const mat4<T>&)>(::operator*)),
|
||||||
|
|
||||||
|
"make_scale_matrix4", sol::overload(
|
||||||
|
sol::resolve<mat4<T>(T,T,T)>(&math::make_scale_matrix4),
|
||||||
|
sol::resolve<mat4<T>(const vec4<T>&)>(&math::make_scale_matrix4),
|
||||||
|
sol::resolve<mat4<T>(const vec3<T>&)>(&math::make_scale_matrix4),
|
||||||
|
sol::resolve<mat4<T>(const vec2<T>&, T)>(&math::make_scale_matrix4)),
|
||||||
|
|
||||||
|
"make_translation_matrix4", sol::overload(
|
||||||
|
sol::resolve<mat4<T>(T,T,T)>(&math::make_translation_matrix4),
|
||||||
|
sol::resolve<mat4<T>(const vec4<T>&)>(&math::make_translation_matrix4),
|
||||||
|
sol::resolve<mat4<T>(const vec3<T>&)>(&math::make_translation_matrix4),
|
||||||
|
sol::resolve<mat4<T>(const vec2<T>&, T)>(&math::make_translation_matrix4)),
|
||||||
|
|
||||||
|
"make_rotation_matrix4", sol::overload(
|
||||||
|
sol::resolve<mat4<T>(const deg<T>&,T,T,T)>(&math::make_rotation_matrix4),
|
||||||
|
sol::resolve<mat4<T>(const deg<T>&,const vec4<T>&)>(&math::make_rotation_matrix4),
|
||||||
|
sol::resolve<mat4<T>(const deg<T>&,const vec3<T>&)>(&math::make_rotation_matrix4),
|
||||||
|
sol::resolve<mat4<T>(const deg<T>&,const vec2<T>&,T)>(&math::make_rotation_matrix4),
|
||||||
|
sol::resolve<mat4<T>(const rad<T>&,T,T,T)>(&math::make_rotation_matrix4),
|
||||||
|
sol::resolve<mat4<T>(const rad<T>&,const vec4<T>&)>(&math::make_rotation_matrix4),
|
||||||
|
sol::resolve<mat4<T>(const rad<T>&,const vec3<T>&)>(&math::make_rotation_matrix4),
|
||||||
|
sol::resolve<mat4<T>(const rad<T>&,const vec2<T>&,T)>(&math::make_rotation_matrix4),
|
||||||
|
sol::resolve<mat4<T>(const quat<T>&)>(&math::make_rotation_matrix4)),
|
||||||
|
|
||||||
|
"approximately", [](const mat4<T>& l, const mat4<T>& r){ return math::approximately(l,r); },
|
||||||
|
|
||||||
|
"inversed", [](const mat4<T>& m){ return math::inversed(m); },
|
||||||
|
"transposed", [](const mat4<T>& m){ return math::transposed(m); },
|
||||||
|
|
||||||
|
"contains_nan", sol::resolve<bool(const mat4<T>&)>(&math::contains_nan));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace e2d::bindings::math
|
||||||
|
{
|
||||||
|
void bind_mat4(sol::state& l) {
|
||||||
|
bind_mat4_t<f32>("m4f", l);
|
||||||
|
}
|
||||||
|
}
|
||||||
74
sources/enduro2d/high/bindings/math_binds/quat_binds.cpp
Normal file
74
sources/enduro2d/high/bindings/math_binds/quat_binds.cpp
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "Enduro2D"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "_math_binds.hpp"
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
using namespace e2d;
|
||||||
|
|
||||||
|
template < typename T >
|
||||||
|
void bind_quat_t(const str& name, sol::state& l) {
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<quat<T>>(name,
|
||||||
|
sol::constructors<
|
||||||
|
quat<T>(),
|
||||||
|
quat<T>(quat<T>),
|
||||||
|
quat<T>(T,T,T,T),
|
||||||
|
quat<T>(vec4<T>)>(),
|
||||||
|
|
||||||
|
"x", &quat<T>::x,
|
||||||
|
"y", &quat<T>::y,
|
||||||
|
"z", &quat<T>::z,
|
||||||
|
"w", &quat<T>::w,
|
||||||
|
|
||||||
|
sol::meta_function::equal_to, sol::resolve<bool(const quat<T>&, const quat<T>&)>(::operator==),
|
||||||
|
sol::meta_function::less_than, sol::resolve<bool(const quat<T>&, const quat<T>&)>(::operator<),
|
||||||
|
sol::meta_function::less_than_or_equal_to, sol::resolve<bool(const quat<T>&, const quat<T>&)>(::operator<=),
|
||||||
|
|
||||||
|
sol::meta_function::addition, sol::overload(
|
||||||
|
sol::resolve<quat<T>(T, const quat<T>&)>(::operator+),
|
||||||
|
sol::resolve<quat<T>(const quat<T>&, T)>(::operator+),
|
||||||
|
sol::resolve<quat<T>(const quat<T>&, const quat<T>&)>(::operator+)),
|
||||||
|
|
||||||
|
sol::meta_function::multiplication, sol::overload(
|
||||||
|
sol::resolve<quat<T>(T, const quat<T>&)>(::operator*),
|
||||||
|
sol::resolve<quat<T>(const quat<T>&, T)>(::operator*),
|
||||||
|
sol::resolve<quat<T>(const quat<T>&, const quat<T>&)>(::operator*)),
|
||||||
|
|
||||||
|
"make_quat_from_axis_angle", sol::overload(
|
||||||
|
sol::resolve<quat<T>(const deg<T>&, const vec3<T>&)>(&math::make_quat_from_axis_angle),
|
||||||
|
sol::resolve<quat<T>(const rad<T>&, const vec3<T>&)>(&math::make_quat_from_axis_angle)),
|
||||||
|
|
||||||
|
"make_quat_from_euler_angles", sol::overload(
|
||||||
|
sol::resolve<quat<T>(const deg<T>&, const deg<T>&, const deg<T>&)>(&math::make_quat_from_euler_angles),
|
||||||
|
sol::resolve<quat<T>(const rad<T>&, const rad<T>&, const rad<T>&)>(&math::make_quat_from_euler_angles)),
|
||||||
|
|
||||||
|
"approximately", [](const quat<T>& l, const quat<T>& r){ return math::approximately(l,r); },
|
||||||
|
|
||||||
|
"dot", sol::resolve<T(const quat<T>&, const quat<T>&)>(&math::dot),
|
||||||
|
"abs_dot", sol::resolve<T(const quat<T>&, const quat<T>&)>(&math::abs_dot),
|
||||||
|
|
||||||
|
"length_squared", sol::resolve<T(const quat<T>&)>(&math::length_squared),
|
||||||
|
"length", sol::resolve<T(const quat<T>&)>(&math::length),
|
||||||
|
|
||||||
|
"normalized", [](const quat<T>& v){ return math::normalized(v); },
|
||||||
|
|
||||||
|
"lerp", sol::resolve<quat<T>(const quat<T>&, const quat<T>&, T)>(&math::lerp),
|
||||||
|
|
||||||
|
"inversed", [](const quat<T>& v){ return math::inversed(v); },
|
||||||
|
"conjugated", [](const quat<T>& v){ return math::conjugated(v); },
|
||||||
|
|
||||||
|
"contains_nan", sol::resolve<bool(const quat<T>&)>(&math::contains_nan));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace e2d::bindings::math
|
||||||
|
{
|
||||||
|
void bind_quat(sol::state& l) {
|
||||||
|
bind_quat_t<f32>("q4f", l);
|
||||||
|
}
|
||||||
|
}
|
||||||
80
sources/enduro2d/high/bindings/math_binds/rect_binds.cpp
Normal file
80
sources/enduro2d/high/bindings/math_binds/rect_binds.cpp
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "Enduro2D"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "_math_binds.hpp"
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
using namespace e2d;
|
||||||
|
|
||||||
|
template < typename T >
|
||||||
|
void bind_rect_t(const str& name, sol::state& l) {
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<rect<T>>(name,
|
||||||
|
sol::constructors<
|
||||||
|
rect<T>(),
|
||||||
|
rect<T>(rect<T>),
|
||||||
|
rect<T>(T,T),
|
||||||
|
rect<T>(T,T,T,T),
|
||||||
|
rect<T>(vec2<T>),
|
||||||
|
rect<T>(vec2<T>,vec2<T>)>(),
|
||||||
|
|
||||||
|
"zero", &rect<T>::zero,
|
||||||
|
"unit", &rect<T>::unit,
|
||||||
|
|
||||||
|
"position", &rect<T>::position,
|
||||||
|
"size", &rect<T>::size,
|
||||||
|
|
||||||
|
sol::meta_function::equal_to, sol::resolve<bool(const rect<T>&, const rect<T>&)>(::operator==),
|
||||||
|
sol::meta_function::less_than, sol::resolve<bool(const rect<T>&, const rect<T>&)>(::operator<),
|
||||||
|
sol::meta_function::less_than_or_equal_to, sol::resolve<bool(const rect<T>&, const rect<T>&)>(::operator<=),
|
||||||
|
|
||||||
|
sol::meta_function::addition, sol::overload(
|
||||||
|
sol::resolve<rect<T>(const rect<T>&, T)>(::operator+),
|
||||||
|
sol::resolve<rect<T>(const rect<T>&, const vec2<T>&)>(::operator+)),
|
||||||
|
|
||||||
|
sol::meta_function::subtraction, sol::overload(
|
||||||
|
sol::resolve<rect<T>(const rect<T>&, T)>(::operator-),
|
||||||
|
sol::resolve<rect<T>(const rect<T>&, const vec2<T>&)>(::operator-)),
|
||||||
|
|
||||||
|
sol::meta_function::multiplication, sol::overload(
|
||||||
|
sol::resolve<rect<T>(const rect<T>&, T)>(::operator*),
|
||||||
|
sol::resolve<rect<T>(const rect<T>&, const vec2<T>&)>(::operator*)),
|
||||||
|
|
||||||
|
sol::meta_function::division, sol::overload(
|
||||||
|
sol::resolve<rect<T>(const rect<T>&, T)>(::operator/),
|
||||||
|
sol::resolve<rect<T>(const rect<T>&, const vec2<T>&)>(::operator/)),
|
||||||
|
|
||||||
|
"make_minmax_rect", sol::overload(
|
||||||
|
sol::resolve<rect<T>(T,T,T,T)>(&math::make_minmax_rect),
|
||||||
|
sol::resolve<rect<T>(const vec2<T>&,const vec2<T>&)>(&math::make_minmax_rect),
|
||||||
|
sol::resolve<rect<T>(const rect<T>&)>(&math::make_minmax_rect)),
|
||||||
|
|
||||||
|
"approximately", [](const rect<T>& l, const rect<T>& r){ return math::approximately(l,r); },
|
||||||
|
|
||||||
|
"minimum", sol::resolve<vec2<T>(const rect<T>&)>(&math::minimum),
|
||||||
|
"maximum", sol::resolve<vec2<T>(const rect<T>&)>(&math::maximum),
|
||||||
|
|
||||||
|
"area", sol::resolve<T(const rect<T>&)>(&math::area),
|
||||||
|
"abs_area", sol::resolve<T(const rect<T>&)>(&math::abs_area),
|
||||||
|
|
||||||
|
"merged", sol::resolve<rect<T>(const rect<T>&,const rect<T>&)>(&math::merged),
|
||||||
|
"inside", sol::resolve<bool(const rect<T>&,const vec2<T>&)>(&math::inside),
|
||||||
|
"overlaps", sol::resolve<bool(const rect<T>&,const rect<T>&)>(&math::overlaps),
|
||||||
|
|
||||||
|
"normalized_to_point", sol::resolve<vec2<T>(const rect<T>&,const vec2<T>&)>(&math::normalized_to_point),
|
||||||
|
"point_to_normalized", sol::resolve<vec2<T>(const rect<T>&,const vec2<T>&)>(&math::point_to_normalized),
|
||||||
|
|
||||||
|
"contains_nan", sol::resolve<bool(const rect<T>&)>(&math::contains_nan));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace e2d::bindings::math
|
||||||
|
{
|
||||||
|
void bind_rect(sol::state& l) {
|
||||||
|
bind_rect_t<f32>("b2f", l);
|
||||||
|
}
|
||||||
|
}
|
||||||
48
sources/enduro2d/high/bindings/math_binds/trs2_binds.cpp
Normal file
48
sources/enduro2d/high/bindings/math_binds/trs2_binds.cpp
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "Enduro2D"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "_math_binds.hpp"
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
using namespace e2d;
|
||||||
|
|
||||||
|
template < typename T >
|
||||||
|
void bind_trs2_t(const str& name, sol::state& l) {
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<trs2<T>>(name,
|
||||||
|
sol::constructors<
|
||||||
|
trs2<T>(),
|
||||||
|
trs2<T>(trs2<T>),
|
||||||
|
trs2<T>(vec2<T>,deg<T>,vec2<T>),
|
||||||
|
trs2<T>(vec2<T>,rad<T>,vec2<T>)>(),
|
||||||
|
|
||||||
|
"zero", &trs2<T>::zero,
|
||||||
|
"unit", &trs2<T>::identity,
|
||||||
|
|
||||||
|
"translation", &trs2<T>::translation,
|
||||||
|
"rotation", &trs2<T>::rotation,
|
||||||
|
"scale", &trs2<T>::scale,
|
||||||
|
|
||||||
|
sol::meta_function::equal_to, sol::resolve<bool(const trs2<T>&, const trs2<T>&)>(::operator==),
|
||||||
|
|
||||||
|
"make_translation_trs2", sol::resolve<trs2<T>(const vec2<T>&)>(&math::make_translation_trs2),
|
||||||
|
"make_rotation_trs2", sol::overload(
|
||||||
|
sol::resolve<trs2<T>(const deg<T>&)>(&math::make_rotation_trs2),
|
||||||
|
sol::resolve<trs2<T>(const rad<T>&)>(&math::make_rotation_trs2)),
|
||||||
|
"make_scale_trs2", sol::resolve<trs2<T>(const vec2<T>&)>(&math::make_scale_trs2),
|
||||||
|
|
||||||
|
"approximately", [](const trs2<T>& l, const trs2<T>& r){ return math::approximately(l,r); },
|
||||||
|
"contains_nan", sol::resolve<bool(const trs2<T>&)>(&math::contains_nan));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace e2d::bindings::math
|
||||||
|
{
|
||||||
|
void bind_trs2(sol::state& l) {
|
||||||
|
bind_trs2_t<f32>("t2f", l);
|
||||||
|
}
|
||||||
|
}
|
||||||
45
sources/enduro2d/high/bindings/math_binds/trs3_binds.cpp
Normal file
45
sources/enduro2d/high/bindings/math_binds/trs3_binds.cpp
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "Enduro2D"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "_math_binds.hpp"
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
using namespace e2d;
|
||||||
|
|
||||||
|
template < typename T >
|
||||||
|
void bind_trs3_t(const str& name, sol::state& l) {
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<trs3<T>>(name,
|
||||||
|
sol::constructors<
|
||||||
|
trs3<T>(),
|
||||||
|
trs3<T>(trs3<T>),
|
||||||
|
trs3<T>(vec3<T>,quat<T>,vec3<T>)>(),
|
||||||
|
|
||||||
|
"zero", &trs3<T>::zero,
|
||||||
|
"unit", &trs3<T>::identity,
|
||||||
|
|
||||||
|
"translation", &trs3<T>::translation,
|
||||||
|
"rotation", &trs3<T>::rotation,
|
||||||
|
"scale", &trs3<T>::scale,
|
||||||
|
|
||||||
|
sol::meta_function::equal_to, sol::resolve<bool(const trs3<T>&, const trs3<T>&)>(::operator==),
|
||||||
|
|
||||||
|
"make_translation_trs3", sol::resolve<trs3<T>(const vec3<T>&)>(&math::make_translation_trs3),
|
||||||
|
"make_rotation_trs3", sol::resolve<trs3<T>(const quat<T>&)>(&math::make_rotation_trs3),
|
||||||
|
"make_scale_trs3", sol::resolve<trs3<T>(const vec3<T>&)>(&math::make_scale_trs3),
|
||||||
|
|
||||||
|
"approximately", [](const trs3<T>& l, const trs3<T>& r){ return math::approximately(l,r); },
|
||||||
|
"contains_nan", sol::resolve<bool(const trs3<T>&)>(&math::contains_nan));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace e2d::bindings::math
|
||||||
|
{
|
||||||
|
void bind_trs3(sol::state& l) {
|
||||||
|
bind_trs3_t<f32>("t3f", l);
|
||||||
|
}
|
||||||
|
}
|
||||||
58
sources/enduro2d/high/bindings/math_binds/unit_binds.cpp
Normal file
58
sources/enduro2d/high/bindings/math_binds/unit_binds.cpp
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "Enduro2D"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "_math_binds.hpp"
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
using namespace e2d;
|
||||||
|
|
||||||
|
template < typename T, typename Tag >
|
||||||
|
void bind_unit_t(const str& name, sol::state& l) {
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<unit<T,Tag>>(name,
|
||||||
|
sol::constructors<
|
||||||
|
unit<T,Tag>(),
|
||||||
|
unit<T,Tag>(T),
|
||||||
|
unit<T,Tag>(unit<T,Tag>)>(),
|
||||||
|
|
||||||
|
"value", &unit<T,Tag>::value,
|
||||||
|
|
||||||
|
sol::meta_function::equal_to, sol::resolve<bool(const unit<T,Tag>&, const unit<T,Tag>&)>(::operator==),
|
||||||
|
sol::meta_function::less_than, sol::resolve<bool(const unit<T,Tag>&, const unit<T,Tag>&)>(::operator<),
|
||||||
|
sol::meta_function::less_than_or_equal_to, sol::resolve<bool(const unit<T,Tag>&, const unit<T,Tag>&)>(::operator<=),
|
||||||
|
|
||||||
|
sol::meta_function::unary_minus, sol::resolve<unit<T,Tag>(const unit<T,Tag>&)>(::operator-),
|
||||||
|
|
||||||
|
sol::meta_function::multiplication, sol::overload(
|
||||||
|
sol::resolve<unit<T,Tag>(T, const unit<T,Tag>&)>(::operator*),
|
||||||
|
sol::resolve<unit<T,Tag>(const unit<T,Tag>&, T)>(::operator*)),
|
||||||
|
|
||||||
|
sol::meta_function::division, sol::overload(
|
||||||
|
sol::resolve<unit<T,Tag>(T, const unit<T,Tag>&)>(::operator/),
|
||||||
|
sol::resolve<unit<T,Tag>(const unit<T,Tag>&, T)>(::operator/)),
|
||||||
|
|
||||||
|
sol::meta_function::addition, sol::resolve<unit<T,Tag>(const unit<T,Tag>&, const unit<T,Tag>&)>(::operator+),
|
||||||
|
sol::meta_function::subtraction, sol::resolve<unit<T,Tag>(const unit<T,Tag>&, const unit<T,Tag>&)>(::operator-),
|
||||||
|
|
||||||
|
"approximately", [](const unit<T,Tag>& l, const unit<T,Tag>& r){ return math::approximately(l,r); },
|
||||||
|
|
||||||
|
"minimized", sol::resolve<unit<T,Tag>(const unit<T,Tag>&, const unit<T,Tag>&)>(&math::minimized),
|
||||||
|
"maximized", sol::resolve<unit<T,Tag>(const unit<T,Tag>&, const unit<T,Tag>&)>(&math::maximized),
|
||||||
|
"clamped", sol::resolve<unit<T,Tag>(const unit<T,Tag>&, const unit<T,Tag>&, const unit<T,Tag>&)>(&math::clamped),
|
||||||
|
"saturated", sol::resolve<unit<T,Tag>(const unit<T,Tag>&)>(&math::saturated),
|
||||||
|
|
||||||
|
"contains_nan", sol::resolve<bool(const unit<T,Tag>&)>(&math::contains_nan));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace e2d::bindings::math
|
||||||
|
{
|
||||||
|
void bind_unit(sol::state& l) {
|
||||||
|
bind_unit_t<f32, deg_tag>("degf", l);
|
||||||
|
bind_unit_t<f32, rad_tag>("radf", l);
|
||||||
|
}
|
||||||
|
}
|
||||||
94
sources/enduro2d/high/bindings/math_binds/vec2_binds.cpp
Normal file
94
sources/enduro2d/high/bindings/math_binds/vec2_binds.cpp
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "Enduro2D"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "_math_binds.hpp"
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
using namespace e2d;
|
||||||
|
|
||||||
|
template < typename T >
|
||||||
|
void bind_vec2_t(const str& name, sol::state& l) {
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<vec2<T>>(name,
|
||||||
|
sol::constructors<
|
||||||
|
vec2<T>(),
|
||||||
|
vec2<T>(T),
|
||||||
|
vec2<T>(T,T),
|
||||||
|
vec2<T>(vec2<T>),
|
||||||
|
vec2<T>(vec3<T>),
|
||||||
|
vec2<T>(vec4<T>)>(),
|
||||||
|
|
||||||
|
"zero", &vec2<T>::zero,
|
||||||
|
"unit", &vec2<T>::unit,
|
||||||
|
"unit_x", &vec2<T>::unit_x,
|
||||||
|
"unit_y", &vec2<T>::unit_y,
|
||||||
|
|
||||||
|
"x", &vec2<T>::x,
|
||||||
|
"y", &vec2<T>::y,
|
||||||
|
|
||||||
|
sol::meta_function::equal_to, sol::resolve<bool(const vec2<T>&, const vec2<T>&)>(::operator==),
|
||||||
|
sol::meta_function::less_than, sol::resolve<bool(const vec2<T>&, const vec2<T>&)>(::operator<),
|
||||||
|
sol::meta_function::less_than_or_equal_to, sol::resolve<bool(const vec2<T>&, const vec2<T>&)>(::operator<=),
|
||||||
|
|
||||||
|
sol::meta_function::unary_minus, sol::resolve<vec2<T>(const vec2<T>&)>(::operator-),
|
||||||
|
|
||||||
|
sol::meta_function::addition, sol::overload(
|
||||||
|
sol::resolve<vec2<T>(T, const vec2<T>&)>(::operator+),
|
||||||
|
sol::resolve<vec2<T>(const vec2<T>&, T)>(::operator+),
|
||||||
|
sol::resolve<vec2<T>(const vec2<T>&, const vec2<T>&)>(::operator+)),
|
||||||
|
|
||||||
|
sol::meta_function::subtraction, sol::overload(
|
||||||
|
sol::resolve<vec2<T>(T, const vec2<T>&)>(::operator-),
|
||||||
|
sol::resolve<vec2<T>(const vec2<T>&, T)>(::operator-),
|
||||||
|
sol::resolve<vec2<T>(const vec2<T>&, const vec2<T>&)>(::operator-)),
|
||||||
|
|
||||||
|
sol::meta_function::multiplication, sol::overload(
|
||||||
|
sol::resolve<vec2<T>(T, const vec2<T>&)>(::operator*),
|
||||||
|
sol::resolve<vec2<T>(const vec2<T>&, T)>(::operator*),
|
||||||
|
sol::resolve<vec2<T>(const vec2<T>&, const vec2<T>&)>(::operator*),
|
||||||
|
sol::resolve<vec2<T>(const vec2<T>&, const mat2<T>&)>(::operator*)),
|
||||||
|
|
||||||
|
sol::meta_function::division, sol::overload(
|
||||||
|
sol::resolve<vec2<T>(T, const vec2<T>&)>(::operator/),
|
||||||
|
sol::resolve<vec2<T>(const vec2<T>&, T)>(::operator/),
|
||||||
|
sol::resolve<vec2<T>(const vec2<T>&, const vec2<T>&)>(::operator/)),
|
||||||
|
|
||||||
|
"approximately", [](const vec2<T>& l, const vec2<T>& r){ return math::approximately(l,r); },
|
||||||
|
|
||||||
|
"dot", sol::resolve<T(const vec2<T>&, const vec2<T>&)>(&math::dot),
|
||||||
|
"abs_dot", sol::resolve<T(const vec2<T>&, const vec2<T>&)>(&math::abs_dot),
|
||||||
|
|
||||||
|
"length_squared", sol::resolve<T(const vec2<T>&)>(&math::length_squared),
|
||||||
|
"length", sol::resolve<T(const vec2<T>&)>(&math::length),
|
||||||
|
|
||||||
|
"distance_squared", sol::resolve<math::make_distance_t<T>(const vec2<T>&, const vec2<T>&)>(&math::distance_squared),
|
||||||
|
"distance", sol::resolve<T(const vec2<T>&, const vec2<T>&)>(&math::distance),
|
||||||
|
|
||||||
|
"normalized", [](const vec2<T>& v){ return math::normalized(v); },
|
||||||
|
|
||||||
|
"minimum", sol::resolve<T(const vec2<T>&)>(&math::minimum),
|
||||||
|
"maximum", sol::resolve<T(const vec2<T>&)>(&math::maximum),
|
||||||
|
|
||||||
|
"minimized", sol::resolve<vec2<T>(const vec2<T>&, const vec2<T>&)>(&math::minimized),
|
||||||
|
"maximized", sol::resolve<vec2<T>(const vec2<T>&, const vec2<T>&)>(&math::maximized),
|
||||||
|
"clamped", sol::resolve<vec2<T>(const vec2<T>&, const vec2<T>&, const vec2<T>&)>(&math::clamped),
|
||||||
|
"saturated", sol::resolve<vec2<T>(const vec2<T>&)>(&math::saturated),
|
||||||
|
|
||||||
|
"lerp", sol::resolve<vec2<T>(const vec2<T>&, const vec2<T>&, T)>(&math::lerp),
|
||||||
|
"lerp", sol::resolve<vec2<T>(const vec2<T>&, const vec2<T>&, const vec2<T>&)>(&math::lerp),
|
||||||
|
"inverse_lerp", sol::resolve<vec2<T>(const vec2<T>&, const vec2<T>&, const vec2<T>&)>(&math::inverse_lerp),
|
||||||
|
|
||||||
|
"contains_nan", sol::resolve<bool(const vec2<T>&)>(&math::contains_nan));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace e2d::bindings::math
|
||||||
|
{
|
||||||
|
void bind_vec2(sol::state& l) {
|
||||||
|
bind_vec2_t<f32>("v2f", l);
|
||||||
|
}
|
||||||
|
}
|
||||||
99
sources/enduro2d/high/bindings/math_binds/vec3_binds.cpp
Normal file
99
sources/enduro2d/high/bindings/math_binds/vec3_binds.cpp
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "Enduro2D"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "_math_binds.hpp"
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
using namespace e2d;
|
||||||
|
|
||||||
|
template < typename T >
|
||||||
|
void bind_vec3_t(const str& name, sol::state& l) {
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<vec3<T>>(name,
|
||||||
|
sol::constructors<
|
||||||
|
vec3<T>(),
|
||||||
|
vec3<T>(T),
|
||||||
|
vec3<T>(T,T,T),
|
||||||
|
vec3<T>(vec2<T>,T),
|
||||||
|
vec3<T>(vec3<T>),
|
||||||
|
vec3<T>(vec4<T>)>(),
|
||||||
|
|
||||||
|
"zero", &vec3<T>::zero,
|
||||||
|
"unit", &vec3<T>::unit,
|
||||||
|
"unit_x", &vec3<T>::unit_x,
|
||||||
|
"unit_y", &vec3<T>::unit_y,
|
||||||
|
"unit_z", &vec3<T>::unit_z,
|
||||||
|
|
||||||
|
"x", &vec3<T>::x,
|
||||||
|
"y", &vec3<T>::y,
|
||||||
|
"z", &vec3<T>::z,
|
||||||
|
|
||||||
|
sol::meta_function::equal_to, sol::resolve<bool(const vec3<T>&, const vec3<T>&)>(::operator==),
|
||||||
|
sol::meta_function::less_than, sol::resolve<bool(const vec3<T>&, const vec3<T>&)>(::operator<),
|
||||||
|
sol::meta_function::less_than_or_equal_to, sol::resolve<bool(const vec3<T>&, const vec3<T>&)>(::operator<=),
|
||||||
|
|
||||||
|
sol::meta_function::unary_minus, sol::resolve<vec3<T>(const vec3<T>&)>(::operator-),
|
||||||
|
|
||||||
|
sol::meta_function::addition, sol::overload(
|
||||||
|
sol::resolve<vec3<T>(T, const vec3<T>&)>(::operator+),
|
||||||
|
sol::resolve<vec3<T>(const vec3<T>&, T)>(::operator+),
|
||||||
|
sol::resolve<vec3<T>(const vec3<T>&, const vec3<T>&)>(::operator+)),
|
||||||
|
|
||||||
|
sol::meta_function::subtraction, sol::overload(
|
||||||
|
sol::resolve<vec3<T>(T, const vec3<T>&)>(::operator-),
|
||||||
|
sol::resolve<vec3<T>(const vec3<T>&, T)>(::operator-),
|
||||||
|
sol::resolve<vec3<T>(const vec3<T>&, const vec3<T>&)>(::operator-)),
|
||||||
|
|
||||||
|
sol::meta_function::multiplication, sol::overload(
|
||||||
|
sol::resolve<vec3<T>(T, const vec3<T>&)>(::operator*),
|
||||||
|
sol::resolve<vec3<T>(const vec3<T>&, T)>(::operator*),
|
||||||
|
sol::resolve<vec3<T>(const vec3<T>&, const vec3<T>&)>(::operator*),
|
||||||
|
sol::resolve<vec3<T>(const vec3<T>&, const mat3<T>&)>(::operator*),
|
||||||
|
sol::resolve<vec3<T>(const vec3<T>&, const quat<T>&)>(::operator*)),
|
||||||
|
|
||||||
|
sol::meta_function::division, sol::overload(
|
||||||
|
sol::resolve<vec3<T>(T, const vec3<T>&)>(::operator/),
|
||||||
|
sol::resolve<vec3<T>(const vec3<T>&, T)>(::operator/),
|
||||||
|
sol::resolve<vec3<T>(const vec3<T>&, const vec3<T>&)>(::operator/)),
|
||||||
|
|
||||||
|
"approximately", [](const vec3<T>& l, const vec3<T>& r){ return math::approximately(l,r); },
|
||||||
|
|
||||||
|
"dot", sol::resolve<T(const vec3<T>&, const vec3<T>&)>(&math::dot),
|
||||||
|
"abs_dot", sol::resolve<T(const vec3<T>&, const vec3<T>&)>(&math::abs_dot),
|
||||||
|
|
||||||
|
"cross", sol::resolve<vec3<T>(const vec3<T>&, const vec3<T>&)>(&math::cross),
|
||||||
|
|
||||||
|
"length_squared", sol::resolve<T(const vec3<T>&)>(&math::length_squared),
|
||||||
|
"length", sol::resolve<T(const vec3<T>&)>(&math::length),
|
||||||
|
|
||||||
|
"distance_squared", sol::resolve<math::make_distance_t<T>(const vec3<T>&, const vec3<T>&)>(&math::distance_squared),
|
||||||
|
"distance", sol::resolve<T(const vec3<T>&, const vec3<T>&)>(&math::distance),
|
||||||
|
|
||||||
|
"normalized", [](const vec3<T>& v){ return math::normalized(v); },
|
||||||
|
|
||||||
|
"minimum", sol::resolve<T(const vec3<T>&)>(&math::minimum),
|
||||||
|
"maximum", sol::resolve<T(const vec3<T>&)>(&math::maximum),
|
||||||
|
|
||||||
|
"minimized", sol::resolve<vec3<T>(const vec3<T>&, const vec3<T>&)>(&math::minimized),
|
||||||
|
"maximized", sol::resolve<vec3<T>(const vec3<T>&, const vec3<T>&)>(&math::maximized),
|
||||||
|
"clamped", sol::resolve<vec3<T>(const vec3<T>&, const vec3<T>&, const vec3<T>&)>(&math::clamped),
|
||||||
|
"saturated", sol::resolve<vec3<T>(const vec3<T>&)>(&math::saturated),
|
||||||
|
|
||||||
|
"lerp", sol::resolve<vec3<T>(const vec3<T>&, const vec3<T>&, T)>(&math::lerp),
|
||||||
|
"lerp", sol::resolve<vec3<T>(const vec3<T>&, const vec3<T>&, const vec3<T>&)>(&math::lerp),
|
||||||
|
"inverse_lerp", sol::resolve<vec3<T>(const vec3<T>&, const vec3<T>&, const vec3<T>&)>(&math::inverse_lerp),
|
||||||
|
|
||||||
|
"contains_nan", sol::resolve<bool(const vec3<T>&)>(&math::contains_nan));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace e2d::bindings::math
|
||||||
|
{
|
||||||
|
void bind_vec3(sol::state& l) {
|
||||||
|
bind_vec3_t<f32>("v3f", l);
|
||||||
|
}
|
||||||
|
}
|
||||||
98
sources/enduro2d/high/bindings/math_binds/vec4_binds.cpp
Normal file
98
sources/enduro2d/high/bindings/math_binds/vec4_binds.cpp
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "Enduro2D"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "_math_binds.hpp"
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
using namespace e2d;
|
||||||
|
|
||||||
|
template < typename T >
|
||||||
|
void bind_vec4_t(const str& name, sol::state& l) {
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<vec4<T>>(name,
|
||||||
|
sol::constructors<
|
||||||
|
vec4<T>(),
|
||||||
|
vec4<T>(T),
|
||||||
|
vec4<T>(T,T,T,T),
|
||||||
|
vec4<T>(vec2<T>,T,T),
|
||||||
|
vec4<T>(vec3<T>,T),
|
||||||
|
vec4<T>(vec4<T>)>(),
|
||||||
|
|
||||||
|
"zero", &vec4<T>::zero,
|
||||||
|
"unit", &vec4<T>::unit,
|
||||||
|
"unit_x", &vec4<T>::unit_x,
|
||||||
|
"unit_y", &vec4<T>::unit_y,
|
||||||
|
"unit_z", &vec4<T>::unit_z,
|
||||||
|
"unit_w", &vec4<T>::unit_w,
|
||||||
|
|
||||||
|
"x", &vec4<T>::x,
|
||||||
|
"y", &vec4<T>::y,
|
||||||
|
"z", &vec4<T>::z,
|
||||||
|
"w", &vec4<T>::w,
|
||||||
|
|
||||||
|
sol::meta_function::equal_to, sol::resolve<bool(const vec4<T>&, const vec4<T>&)>(::operator==),
|
||||||
|
sol::meta_function::less_than, sol::resolve<bool(const vec4<T>&, const vec4<T>&)>(::operator<),
|
||||||
|
sol::meta_function::less_than_or_equal_to, sol::resolve<bool(const vec4<T>&, const vec4<T>&)>(::operator<=),
|
||||||
|
|
||||||
|
sol::meta_function::unary_minus, sol::resolve<vec4<T>(const vec4<T>&)>(::operator-),
|
||||||
|
|
||||||
|
sol::meta_function::addition, sol::overload(
|
||||||
|
sol::resolve<vec4<T>(T, const vec4<T>&)>(::operator+),
|
||||||
|
sol::resolve<vec4<T>(const vec4<T>&, T)>(::operator+),
|
||||||
|
sol::resolve<vec4<T>(const vec4<T>&, const vec4<T>&)>(::operator+)),
|
||||||
|
|
||||||
|
sol::meta_function::subtraction, sol::overload(
|
||||||
|
sol::resolve<vec4<T>(T, const vec4<T>&)>(::operator-),
|
||||||
|
sol::resolve<vec4<T>(const vec4<T>&, T)>(::operator-),
|
||||||
|
sol::resolve<vec4<T>(const vec4<T>&, const vec4<T>&)>(::operator-)),
|
||||||
|
|
||||||
|
sol::meta_function::multiplication, sol::overload(
|
||||||
|
sol::resolve<vec4<T>(T, const vec4<T>&)>(::operator*),
|
||||||
|
sol::resolve<vec4<T>(const vec4<T>&, T)>(::operator*),
|
||||||
|
sol::resolve<vec4<T>(const vec4<T>&, const vec4<T>&)>(::operator*),
|
||||||
|
sol::resolve<vec4<T>(const vec4<T>&, const mat4<T>&)>(::operator*)),
|
||||||
|
|
||||||
|
sol::meta_function::division, sol::overload(
|
||||||
|
sol::resolve<vec4<T>(T, const vec4<T>&)>(::operator/),
|
||||||
|
sol::resolve<vec4<T>(const vec4<T>&, T)>(::operator/),
|
||||||
|
sol::resolve<vec4<T>(const vec4<T>&, const vec4<T>&)>(::operator/)),
|
||||||
|
|
||||||
|
"approximately", [](const vec4<T>& l, const vec4<T>& r){ return math::approximately(l,r); },
|
||||||
|
|
||||||
|
"dot", sol::resolve<T(const vec4<T>&, const vec4<T>&)>(&math::dot),
|
||||||
|
"abs_dot", sol::resolve<T(const vec4<T>&, const vec4<T>&)>(&math::abs_dot),
|
||||||
|
|
||||||
|
"length_squared", sol::resolve<T(const vec4<T>&)>(&math::length_squared),
|
||||||
|
"length", sol::resolve<T(const vec4<T>&)>(&math::length),
|
||||||
|
|
||||||
|
"distance_squared", sol::resolve<math::make_distance_t<T>(const vec4<T>&, const vec4<T>&)>(&math::distance_squared),
|
||||||
|
"distance", sol::resolve<T(const vec4<T>&, const vec4<T>&)>(&math::distance),
|
||||||
|
|
||||||
|
"normalized", [](const vec4<T>& v){ return math::normalized(v); },
|
||||||
|
|
||||||
|
"minimum", sol::resolve<T(const vec4<T>&)>(&math::minimum),
|
||||||
|
"maximum", sol::resolve<T(const vec4<T>&)>(&math::maximum),
|
||||||
|
|
||||||
|
"minimized", sol::resolve<vec4<T>(const vec4<T>&, const vec4<T>&)>(&math::minimized),
|
||||||
|
"maximized", sol::resolve<vec4<T>(const vec4<T>&, const vec4<T>&)>(&math::maximized),
|
||||||
|
"clamped", sol::resolve<vec4<T>(const vec4<T>&, const vec4<T>&, const vec4<T>&)>(&math::clamped),
|
||||||
|
"saturated", sol::resolve<vec4<T>(const vec4<T>&)>(&math::saturated),
|
||||||
|
|
||||||
|
"lerp", sol::resolve<vec4<T>(const vec4<T>&, const vec4<T>&, T)>(&math::lerp),
|
||||||
|
"lerp", sol::resolve<vec4<T>(const vec4<T>&, const vec4<T>&, const vec4<T>&)>(&math::lerp),
|
||||||
|
"inverse_lerp", sol::resolve<vec4<T>(const vec4<T>&, const vec4<T>&, const vec4<T>&)>(&math::inverse_lerp),
|
||||||
|
|
||||||
|
"contains_nan", sol::resolve<bool(const vec4<T>&)>(&math::contains_nan));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace e2d::bindings::math
|
||||||
|
{
|
||||||
|
void bind_vec4(sol::state& l) {
|
||||||
|
bind_vec4_t<f32>("v4f", l);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,146 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* This file is part of the "Enduro2D"
|
|
||||||
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
|
||||||
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
|
||||||
******************************************************************************/
|
|
||||||
|
|
||||||
#include "bindings.hpp"
|
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
using namespace e2d;
|
|
||||||
|
|
||||||
void bind_color(sol::state& l) {
|
|
||||||
l.new_usertype<color>("color",
|
|
||||||
sol::constructors<
|
|
||||||
color(),
|
|
||||||
color(color),
|
|
||||||
color(color32),
|
|
||||||
color(vec4<f32>),
|
|
||||||
color(vec3<f32>, f32),
|
|
||||||
color(f32,f32,f32,f32)>(),
|
|
||||||
|
|
||||||
"clear", &color::clear,
|
|
||||||
"black", &color::black,
|
|
||||||
"white", &color::white,
|
|
||||||
"red", &color::red,
|
|
||||||
"green", &color::green,
|
|
||||||
"blue", &color::blue,
|
|
||||||
"yellow", &color::yellow,
|
|
||||||
"magenta", &color::magenta,
|
|
||||||
"cyan", &color::cyan,
|
|
||||||
|
|
||||||
"r", &color::r,
|
|
||||||
"g", &color::g,
|
|
||||||
"b", &color::b,
|
|
||||||
"a", &color::a,
|
|
||||||
|
|
||||||
sol::meta_function::equal_to, sol::resolve<bool(const color&, const color&)>(::operator==),
|
|
||||||
sol::meta_function::less_than, sol::resolve<bool(const color&, const color&)>(::operator<),
|
|
||||||
|
|
||||||
sol::meta_function::addition, sol::overload(
|
|
||||||
sol::resolve<color(f32, const color&)>(::operator+),
|
|
||||||
sol::resolve<color(color, f32)>(::operator+),
|
|
||||||
sol::resolve<color(color, const color&)>(::operator+)),
|
|
||||||
|
|
||||||
sol::meta_function::subtraction, sol::overload(
|
|
||||||
sol::resolve<color(f32, const color&)>(::operator-),
|
|
||||||
sol::resolve<color(color, f32)>(::operator-),
|
|
||||||
sol::resolve<color(color, const color&)>(::operator-)),
|
|
||||||
|
|
||||||
sol::meta_function::multiplication, sol::overload(
|
|
||||||
sol::resolve<color(f32, const color&)>(::operator*),
|
|
||||||
sol::resolve<color(color, f32)>(::operator*),
|
|
||||||
sol::resolve<color(color, const color&)>(::operator*)),
|
|
||||||
|
|
||||||
sol::meta_function::division, sol::overload(
|
|
||||||
sol::resolve<color(f32, const color&)>(::operator/),
|
|
||||||
sol::resolve<color(color, f32)>(::operator/),
|
|
||||||
sol::resolve<color(color, const color&)>(::operator/)),
|
|
||||||
|
|
||||||
"approximately", [](const color& l, const color& r){ return math::approximately(l,r); },
|
|
||||||
|
|
||||||
"minimum", sol::resolve<f32(const color&)>(&math::minimum),
|
|
||||||
"maximum", sol::resolve<f32(const color&)>(&math::maximum),
|
|
||||||
|
|
||||||
"minimized", sol::resolve<color(const color&, const color&)>(&math::minimized),
|
|
||||||
"maximized", sol::resolve<color(const color&, const color&)>(&math::maximized),
|
|
||||||
"clamped", sol::resolve<color(const color&, const color&, const color&)>(&math::clamped),
|
|
||||||
|
|
||||||
"contains_nan", sol::resolve<bool(const color&)>(&math::contains_nan),
|
|
||||||
|
|
||||||
"pack_color", sol::resolve<u32(const color&)>(&colors::pack_color),
|
|
||||||
"unpack_color", sol::resolve<color(u32)>(&colors::unpack_color));
|
|
||||||
}
|
|
||||||
|
|
||||||
void bind_color32(sol::state& l) {
|
|
||||||
l.new_usertype<color32>("color32",
|
|
||||||
sol::constructors<
|
|
||||||
color32(),
|
|
||||||
color32(color),
|
|
||||||
color32(color32),
|
|
||||||
color32(vec4<u8>),
|
|
||||||
color32(vec3<u8>, u8),
|
|
||||||
color32(u8,u8,u8,u8)>(),
|
|
||||||
|
|
||||||
"clear", &color32::clear,
|
|
||||||
"black", &color32::black,
|
|
||||||
"white", &color32::white,
|
|
||||||
"red", &color32::red,
|
|
||||||
"green", &color32::green,
|
|
||||||
"blue", &color32::blue,
|
|
||||||
"yellow", &color32::yellow,
|
|
||||||
"magenta", &color32::magenta,
|
|
||||||
"cyan", &color32::cyan,
|
|
||||||
|
|
||||||
"r", &color32::r,
|
|
||||||
"g", &color32::g,
|
|
||||||
"b", &color32::b,
|
|
||||||
"a", &color32::a,
|
|
||||||
|
|
||||||
sol::meta_function::equal_to, sol::resolve<bool(const color32&, const color32&)>(::operator==),
|
|
||||||
sol::meta_function::less_than, sol::resolve<bool(const color32&, const color32&)>(::operator<),
|
|
||||||
|
|
||||||
sol::meta_function::addition, sol::overload(
|
|
||||||
sol::resolve<color32(u8, const color32&)>(::operator+),
|
|
||||||
sol::resolve<color32(color32, u8)>(::operator+),
|
|
||||||
sol::resolve<color32(color32, const color32&)>(::operator+)),
|
|
||||||
|
|
||||||
sol::meta_function::subtraction, sol::overload(
|
|
||||||
sol::resolve<color32(u8, const color32&)>(::operator-),
|
|
||||||
sol::resolve<color32(color32, u8)>(::operator-),
|
|
||||||
sol::resolve<color32(color32, const color32&)>(::operator-)),
|
|
||||||
|
|
||||||
sol::meta_function::multiplication, sol::overload(
|
|
||||||
sol::resolve<color32(u8, const color32&)>(::operator*),
|
|
||||||
sol::resolve<color32(color32, u8)>(::operator*),
|
|
||||||
sol::resolve<color32(color32, const color32&)>(::operator*)),
|
|
||||||
|
|
||||||
sol::meta_function::division, sol::overload(
|
|
||||||
sol::resolve<color32(u8, const color32&)>(::operator/),
|
|
||||||
sol::resolve<color32(color32, u8)>(::operator/),
|
|
||||||
sol::resolve<color32(color32, const color32&)>(::operator/)),
|
|
||||||
|
|
||||||
"approximately", [](const color32& l, const color32& r){ return math::approximately(l,r); },
|
|
||||||
|
|
||||||
"minimum", sol::resolve<u8(const color32&)>(&math::minimum),
|
|
||||||
"maximum", sol::resolve<u8(const color32&)>(&math::maximum),
|
|
||||||
|
|
||||||
"minimized", sol::resolve<color32(const color32&, const color32&)>(&math::minimized),
|
|
||||||
"maximized", sol::resolve<color32(const color32&, const color32&)>(&math::maximized),
|
|
||||||
"clamped", sol::resolve<color32(const color32&, const color32&, const color32&)>(&math::clamped),
|
|
||||||
|
|
||||||
"contains_nan", sol::resolve<bool(const color32&)>(&math::contains_nan),
|
|
||||||
|
|
||||||
"pack_color", sol::resolve<u32(const color32&)>(&colors::pack_color32),
|
|
||||||
"unpack_color", sol::resolve<color32(u32)>(&colors::unpack_color32));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace e2d::bindings
|
|
||||||
{
|
|
||||||
void bind_utils(sol::state& l) {
|
|
||||||
bind_color(l);
|
|
||||||
bind_color32(l);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
25
sources/enduro2d/high/bindings/utils_binds/_utils_binds.hpp
Normal file
25
sources/enduro2d/high/bindings/utils_binds/_utils_binds.hpp
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "Enduro2D"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "../bindings.hpp"
|
||||||
|
|
||||||
|
namespace e2d::bindings::utils
|
||||||
|
{
|
||||||
|
void bind_color(sol::state& l);
|
||||||
|
void bind_color32(sol::state& l);
|
||||||
|
void bind_str_hash(sol::state& l);
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace e2d::bindings
|
||||||
|
{
|
||||||
|
inline void bind_utils(sol::state& l) {
|
||||||
|
utils::bind_color(l);
|
||||||
|
utils::bind_color32(l);
|
||||||
|
utils::bind_str_hash(l);
|
||||||
|
}
|
||||||
|
}
|
||||||
76
sources/enduro2d/high/bindings/utils_binds/color32_binds.cpp
Normal file
76
sources/enduro2d/high/bindings/utils_binds/color32_binds.cpp
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "Enduro2D"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "_utils_binds.hpp"
|
||||||
|
|
||||||
|
using namespace e2d;
|
||||||
|
|
||||||
|
namespace e2d::bindings::utils
|
||||||
|
{
|
||||||
|
void bind_color32(sol::state& l) {
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<color32>("color32",
|
||||||
|
sol::constructors<
|
||||||
|
color32(),
|
||||||
|
color32(color),
|
||||||
|
color32(color32),
|
||||||
|
color32(vec4<u8>),
|
||||||
|
color32(vec3<u8>, u8),
|
||||||
|
color32(u8,u8,u8,u8)>(),
|
||||||
|
|
||||||
|
"clear", &color32::clear,
|
||||||
|
"black", &color32::black,
|
||||||
|
"white", &color32::white,
|
||||||
|
"red", &color32::red,
|
||||||
|
"green", &color32::green,
|
||||||
|
"blue", &color32::blue,
|
||||||
|
"yellow", &color32::yellow,
|
||||||
|
"magenta", &color32::magenta,
|
||||||
|
"cyan", &color32::cyan,
|
||||||
|
|
||||||
|
"r", &color32::r,
|
||||||
|
"g", &color32::g,
|
||||||
|
"b", &color32::b,
|
||||||
|
"a", &color32::a,
|
||||||
|
|
||||||
|
sol::meta_function::equal_to, sol::resolve<bool(const color32&, const color32&)>(::operator==),
|
||||||
|
sol::meta_function::less_than, sol::resolve<bool(const color32&, const color32&)>(::operator<),
|
||||||
|
|
||||||
|
sol::meta_function::addition, sol::overload(
|
||||||
|
sol::resolve<color32(u8, const color32&)>(::operator+),
|
||||||
|
sol::resolve<color32(color32, u8)>(::operator+),
|
||||||
|
sol::resolve<color32(color32, const color32&)>(::operator+)),
|
||||||
|
|
||||||
|
sol::meta_function::subtraction, sol::overload(
|
||||||
|
sol::resolve<color32(u8, const color32&)>(::operator-),
|
||||||
|
sol::resolve<color32(color32, u8)>(::operator-),
|
||||||
|
sol::resolve<color32(color32, const color32&)>(::operator-)),
|
||||||
|
|
||||||
|
sol::meta_function::multiplication, sol::overload(
|
||||||
|
sol::resolve<color32(u8, const color32&)>(::operator*),
|
||||||
|
sol::resolve<color32(color32, u8)>(::operator*),
|
||||||
|
sol::resolve<color32(color32, const color32&)>(::operator*)),
|
||||||
|
|
||||||
|
sol::meta_function::division, sol::overload(
|
||||||
|
sol::resolve<color32(u8, const color32&)>(::operator/),
|
||||||
|
sol::resolve<color32(color32, u8)>(::operator/),
|
||||||
|
sol::resolve<color32(color32, const color32&)>(::operator/)),
|
||||||
|
|
||||||
|
"approximately", sol::resolve<bool(const color32&, const color32&)>(&math::approximately),
|
||||||
|
|
||||||
|
"minimum", sol::resolve<u8(const color32&)>(&math::minimum),
|
||||||
|
"maximum", sol::resolve<u8(const color32&)>(&math::maximum),
|
||||||
|
|
||||||
|
"minimized", sol::resolve<color32(const color32&, const color32&)>(&math::minimized),
|
||||||
|
"maximized", sol::resolve<color32(const color32&, const color32&)>(&math::maximized),
|
||||||
|
"clamped", sol::resolve<color32(const color32&, const color32&, const color32&)>(&math::clamped),
|
||||||
|
|
||||||
|
"contains_nan", sol::resolve<bool(const color32&)>(&math::contains_nan),
|
||||||
|
|
||||||
|
"pack_color", sol::resolve<u32(const color32&)>(&colors::pack_color32),
|
||||||
|
"unpack_color", sol::resolve<color32(u32)>(&colors::unpack_color32));
|
||||||
|
}
|
||||||
|
}
|
||||||
76
sources/enduro2d/high/bindings/utils_binds/color_binds.cpp
Normal file
76
sources/enduro2d/high/bindings/utils_binds/color_binds.cpp
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "Enduro2D"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "_utils_binds.hpp"
|
||||||
|
|
||||||
|
using namespace e2d;
|
||||||
|
|
||||||
|
namespace e2d::bindings::utils
|
||||||
|
{
|
||||||
|
void bind_color(sol::state& l) {
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<color>("color",
|
||||||
|
sol::constructors<
|
||||||
|
color(),
|
||||||
|
color(color),
|
||||||
|
color(color32),
|
||||||
|
color(vec4<f32>),
|
||||||
|
color(vec3<f32>, f32),
|
||||||
|
color(f32,f32,f32,f32)>(),
|
||||||
|
|
||||||
|
"clear", &color::clear,
|
||||||
|
"black", &color::black,
|
||||||
|
"white", &color::white,
|
||||||
|
"red", &color::red,
|
||||||
|
"green", &color::green,
|
||||||
|
"blue", &color::blue,
|
||||||
|
"yellow", &color::yellow,
|
||||||
|
"magenta", &color::magenta,
|
||||||
|
"cyan", &color::cyan,
|
||||||
|
|
||||||
|
"r", &color::r,
|
||||||
|
"g", &color::g,
|
||||||
|
"b", &color::b,
|
||||||
|
"a", &color::a,
|
||||||
|
|
||||||
|
sol::meta_function::equal_to, sol::resolve<bool(const color&, const color&)>(::operator==),
|
||||||
|
sol::meta_function::less_than, sol::resolve<bool(const color&, const color&)>(::operator<),
|
||||||
|
|
||||||
|
sol::meta_function::addition, sol::overload(
|
||||||
|
sol::resolve<color(f32, const color&)>(::operator+),
|
||||||
|
sol::resolve<color(color, f32)>(::operator+),
|
||||||
|
sol::resolve<color(color, const color&)>(::operator+)),
|
||||||
|
|
||||||
|
sol::meta_function::subtraction, sol::overload(
|
||||||
|
sol::resolve<color(f32, const color&)>(::operator-),
|
||||||
|
sol::resolve<color(color, f32)>(::operator-),
|
||||||
|
sol::resolve<color(color, const color&)>(::operator-)),
|
||||||
|
|
||||||
|
sol::meta_function::multiplication, sol::overload(
|
||||||
|
sol::resolve<color(f32, const color&)>(::operator*),
|
||||||
|
sol::resolve<color(color, f32)>(::operator*),
|
||||||
|
sol::resolve<color(color, const color&)>(::operator*)),
|
||||||
|
|
||||||
|
sol::meta_function::division, sol::overload(
|
||||||
|
sol::resolve<color(f32, const color&)>(::operator/),
|
||||||
|
sol::resolve<color(color, f32)>(::operator/),
|
||||||
|
sol::resolve<color(color, const color&)>(::operator/)),
|
||||||
|
|
||||||
|
"approximately", sol::resolve<bool(const color&, const color&)>(&math::approximately),
|
||||||
|
|
||||||
|
"minimum", sol::resolve<f32(const color&)>(&math::minimum),
|
||||||
|
"maximum", sol::resolve<f32(const color&)>(&math::maximum),
|
||||||
|
|
||||||
|
"minimized", sol::resolve<color(const color&, const color&)>(&math::minimized),
|
||||||
|
"maximized", sol::resolve<color(const color&, const color&)>(&math::maximized),
|
||||||
|
"clamped", sol::resolve<color(const color&, const color&, const color&)>(&math::clamped),
|
||||||
|
|
||||||
|
"contains_nan", sol::resolve<bool(const color&)>(&math::contains_nan),
|
||||||
|
|
||||||
|
"pack_color", sol::resolve<u32(const color&)>(&colors::pack_color),
|
||||||
|
"unpack_color", sol::resolve<color(u32)>(&colors::unpack_color));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "Enduro2D"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "_utils_binds.hpp"
|
||||||
|
|
||||||
|
using namespace e2d;
|
||||||
|
|
||||||
|
namespace e2d::bindings::utils
|
||||||
|
{
|
||||||
|
void bind_str_hash(sol::state& l) {
|
||||||
|
l["e2d"].get_or_create<sol::table>()
|
||||||
|
.new_usertype<str_hash>("str_hash",
|
||||||
|
sol::constructors<
|
||||||
|
str_hash(),
|
||||||
|
str_hash(const char*),
|
||||||
|
str_hash(str_view)>(),
|
||||||
|
|
||||||
|
sol::meta_function::equal_to, sol::resolve<bool(str_hash, str_hash)>(::operator==),
|
||||||
|
sol::meta_function::less_than, sol::resolve<bool(str_hash, str_hash)>(::operator<),
|
||||||
|
|
||||||
|
"clear", &str_hash::clear,
|
||||||
|
"empty", sol::property(&str_hash::empty),
|
||||||
|
"hash", sol::property(&str_hash::hash));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,7 +6,10 @@
|
|||||||
|
|
||||||
#include <enduro2d/high/luasol.hpp>
|
#include <enduro2d/high/luasol.hpp>
|
||||||
|
|
||||||
#include "bindings/bindings.hpp"
|
#include "bindings/math_binds/_math_binds.hpp"
|
||||||
|
#include "bindings/utils_binds/_utils_binds.hpp"
|
||||||
|
#include "bindings/core_binds/_core_binds.hpp"
|
||||||
|
#include "bindings/high_binds/_high_binds.hpp"
|
||||||
|
|
||||||
namespace e2d
|
namespace e2d
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,19 +16,17 @@ namespace
|
|||||||
|
|
||||||
void init_core_table(sol::state& s) {
|
void init_core_table(sol::state& s) {
|
||||||
auto e2d_table = s["e2d"].get_or_create<sol::table>();
|
auto e2d_table = s["e2d"].get_or_create<sol::table>();
|
||||||
e2d_table["core"] = s.create_table_with(
|
e2d_table["debug"] = &the<debug>();
|
||||||
"debug", &the<debug>(),
|
e2d_table["engine"] = &the<engine>();
|
||||||
"engine", &the<engine>(),
|
e2d_table["input"] = &the<input>();
|
||||||
"input", &the<input>(),
|
e2d_table["window"] = &the<window>();
|
||||||
"window", &the<window>());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void init_high_table(sol::state& s) {
|
void init_high_table(sol::state& s) {
|
||||||
auto e2d_table = s["e2d"].get_or_create<sol::table>();
|
auto e2d_table = s["e2d"].get_or_create<sol::table>();
|
||||||
e2d_table["high"] = s.create_table_with(
|
e2d_table["library"] = &the<library>();
|
||||||
"library", &the<library>(),
|
e2d_table["luasol"] = &the<luasol>();
|
||||||
"luasol", &the<luasol>(),
|
e2d_table["world"] = &the<world>();
|
||||||
"world", &the<world>());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
6
support/components/actor.md
Normal file
6
support/components/actor.md
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
# Actor
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
- `node: node, RO`
|
||||||
|
|
||||||
6
support/components/behaviour.md
Normal file
6
support/components/behaviour.md
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
# Behaviour
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
- `meta: table, RW`
|
||||||
|
|
||||||
10
support/components/camera.md
Normal file
10
support/components/camera.md
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
# Camera
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
- `depth: number, RW`
|
||||||
|
- `viewport: b2f, RW`
|
||||||
|
- `projection: m4f, RW`
|
||||||
|
- `target: render_target, RW`
|
||||||
|
- `background: color, RW`
|
||||||
|
|
||||||
19
support/components/flipbook_player.md
Normal file
19
support/components/flipbook_player.md
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
# Flipbook Player
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
- `time: number, RW`
|
||||||
|
- `speed: number, RW`
|
||||||
|
- `looped: boolean, RW`
|
||||||
|
- `stopped: boolean, RW`
|
||||||
|
- `playing: boolean, RW`
|
||||||
|
- `sequence: str_hash, RW`
|
||||||
|
- `flipbook: flipbook_asset, RW`
|
||||||
|
|
||||||
|
## Function
|
||||||
|
|
||||||
|
- `stop(time: number)`
|
||||||
|
- `stop(sequence: str_hash)`
|
||||||
|
- `play(time: number)`
|
||||||
|
- `play(sequence: str_hash)`
|
||||||
|
|
||||||
28
support/components/label.md
Normal file
28
support/components/label.md
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
# Label
|
||||||
|
|
||||||
|
## Enums
|
||||||
|
|
||||||
|
```lua
|
||||||
|
e2d.label.haligns = {
|
||||||
|
left, center, right
|
||||||
|
}
|
||||||
|
|
||||||
|
e2d.label.valigns = {
|
||||||
|
top, center, bottom, baseline
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
- `text: string, RW`
|
||||||
|
- `font: font_asset, RW`
|
||||||
|
- `tint: color32, RW`
|
||||||
|
- `halign: haligns, RW`
|
||||||
|
- `valign: valigns, RW`
|
||||||
|
- `leading: number, RW`
|
||||||
|
- `tracking: number, RW`
|
||||||
|
- `text_width: number, RW`
|
||||||
|
- `glyph_dilate: number, RW`
|
||||||
|
- `outline_width: number, RW`
|
||||||
|
- `outline_color: color32, RW`
|
||||||
|
|
||||||
6
support/components/model_renderer.md
Normal file
6
support/components/model_renderer.md
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
# Model Renderer
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
- `model: model_asset, RW`
|
||||||
|
|
||||||
6
support/components/named.md
Normal file
6
support/components/named.md
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
# Named
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
- `name: string, RW`
|
||||||
|
|
||||||
2
support/components/renderer.md
Normal file
2
support/components/renderer.md
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# Renderer
|
||||||
|
|
||||||
6
support/components/scene.md
Normal file
6
support/components/scene.md
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
# Scene
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
- `depth: number, RW`
|
||||||
|
|
||||||
92
support/components/spine_player.md
Normal file
92
support/components/spine_player.md
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
# Spine Player
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
- `spine: spine_asset, RW`
|
||||||
|
|
||||||
|
## Functions
|
||||||
|
|
||||||
|
- `skin(name: string) -> void`
|
||||||
|
- `attachment(slot: string, name: string) -> void`
|
||||||
|
- `has_skin(name: string) -> boolean`
|
||||||
|
- `has_animation(name: string) -> boolean`
|
||||||
|
- `add_command(command: commands) -> void`
|
||||||
|
|
||||||
|
## Commands
|
||||||
|
|
||||||
|
- `clear_track_cmd(track: number)`
|
||||||
|
- `track: number, RO`
|
||||||
|
|
||||||
|
- `set_anim_cmd(track: number, name: string)`
|
||||||
|
- `track: number, RO`
|
||||||
|
- `name: string, RO`
|
||||||
|
- `loop: boolean, RW`
|
||||||
|
- `end_message: string, RW`
|
||||||
|
- `complete_messsage: string, RW`
|
||||||
|
|
||||||
|
- `add_anim_cmd(track: number, name: string)`
|
||||||
|
- `track: number, RO`
|
||||||
|
- `name: string, RO`
|
||||||
|
- `loop: boolean, RW`
|
||||||
|
- `delay: secf, RW`
|
||||||
|
- `end_message: string, RW`
|
||||||
|
- `complete_messsage: string, RW`
|
||||||
|
|
||||||
|
- `set_empty_anim_cmd(track: number)`
|
||||||
|
- `track: number, RO`
|
||||||
|
- `mix_duration: secf, RW`
|
||||||
|
- `end_message: string, RW`
|
||||||
|
- `complete_messsage: string, RW`
|
||||||
|
|
||||||
|
- `add_empty_anim_cmd(track: number)`
|
||||||
|
- `track: number, RO`
|
||||||
|
- `delay: secf, RW`
|
||||||
|
- `mix_duration: secf, RW`
|
||||||
|
- `end_message: string, RW`
|
||||||
|
- `complete_messsage: string, RW`
|
||||||
|
|
||||||
|
## Events
|
||||||
|
|
||||||
|
- `custom_evt(name: str_hash)`
|
||||||
|
- `name: str_hash, RO`
|
||||||
|
- `int_value: number, RW`
|
||||||
|
- `float_value: number, RW`
|
||||||
|
- `string_value: string, RW`
|
||||||
|
|
||||||
|
- `end_evt(message: string)`
|
||||||
|
- `message: string, RO`
|
||||||
|
|
||||||
|
- `complete_evt(message: string)`
|
||||||
|
- `message: string, RO`
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
```lua
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
local keyboard = e2d.input.keyboard
|
||||||
|
local roar_key = e2d.keyboard_key.r
|
||||||
|
|
||||||
|
function M:on_update(go)
|
||||||
|
local roar = keyboard:is_key_just_pressed(roar_key)
|
||||||
|
if roar then
|
||||||
|
local cmd = e2d.spine_player.set_anim_cmd.new(0, "roar")
|
||||||
|
cmd.complete_message = "to_walk"
|
||||||
|
go.spine_player:add_command(cmd)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:on_event(go, type, event)
|
||||||
|
local to_walk =
|
||||||
|
type == "spine_player.complete_evt" and
|
||||||
|
event.message == "to_walk"
|
||||||
|
if to_walk then
|
||||||
|
local cmd = e2d.spine_player.add_anim_cmd.new(0, "walk")
|
||||||
|
cmd.loop = true
|
||||||
|
go.spine_player:add_command(cmd)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
```
|
||||||
|
|
||||||
17
support/components/sprite_renderer.md
Normal file
17
support/components/sprite_renderer.md
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# Sprite Renderer
|
||||||
|
|
||||||
|
## Enums
|
||||||
|
|
||||||
|
```lua
|
||||||
|
e2d.sprite_renderer.blendings = {
|
||||||
|
normal, additive, multiply, screen
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
- `tint: color32, RW`
|
||||||
|
- `blending: blendings, RW`
|
||||||
|
- `filtering: boolean, RW`
|
||||||
|
- `sprite: sprite_asset, RW`
|
||||||
|
|
||||||
42
support/gobject.md
Normal file
42
support/gobject.md
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
# GObject
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
- `alive: boolean, RO`
|
||||||
|
- `valid: boolean, RO`
|
||||||
|
|
||||||
|
## Functions
|
||||||
|
|
||||||
|
- `destroy() -> void`
|
||||||
|
|
||||||
|
## Components
|
||||||
|
|
||||||
|
- `actor: actor, RO`
|
||||||
|
- `behaviour: behaviour, RO`
|
||||||
|
- `camera: camera, RO`
|
||||||
|
- `flipbook_player: flipbook_player, RO`
|
||||||
|
- `label: label, RO`
|
||||||
|
- `model_renderer: model_renderer, RO`
|
||||||
|
- `renderer: renderer, RO`
|
||||||
|
- `scene: scene, RO`
|
||||||
|
- `spine_player: spine_player, RO`
|
||||||
|
- `sprite_renderer: sprite_renderer, RO`
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
```lua
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
function M:on_init(go)
|
||||||
|
self.life = 2
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:on_update(go)
|
||||||
|
self.life = self.life - e2d.engine.delta_time
|
||||||
|
if self.life <= 0 then
|
||||||
|
go:destroy()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
```
|
||||||
18
support/modules/dbgui.md
Normal file
18
support/modules/dbgui.md
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Dbgui
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
- `visible: boolean, RW`
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
```lua
|
||||||
|
local d = e2d.dbgui
|
||||||
|
local k = e2d.input.keyboard
|
||||||
|
|
||||||
|
local toggle_dbgui_key = e2d.keyboard_key.f12
|
||||||
|
if k:is_key_just_pressed(toggle_dbgui_key) then
|
||||||
|
d.visible = not d.visible
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
16
support/modules/debug.md
Normal file
16
support/modules/debug.md
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# Debug
|
||||||
|
|
||||||
|
## Functions
|
||||||
|
|
||||||
|
- `trace(message: string) -> void`
|
||||||
|
- `warning(message: string) -> void`
|
||||||
|
- `error(message: string) -> void`
|
||||||
|
- `fatal(message: string) -> void`
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
```lua
|
||||||
|
local d = e2d.debug
|
||||||
|
d:warning("Hello World")
|
||||||
|
```
|
||||||
|
|
||||||
18
support/modules/engine.md
Normal file
18
support/modules/engine.md
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Engine
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
- `time: number, RO`
|
||||||
|
- `delta_time: number, RO`
|
||||||
|
- `frame_rate: number, RO`
|
||||||
|
- `frame_count: number, RO`
|
||||||
|
- `realtime_time: number, RO`
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
```lua
|
||||||
|
local d = e2d.debug
|
||||||
|
local e = e2d.engine
|
||||||
|
d:trace("FPS: " .. e.frame_rate)
|
||||||
|
```
|
||||||
|
|
||||||
122
support/modules/input.md
Normal file
122
support/modules/input.md
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
# Input
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
- `mouse: mouse, RO`
|
||||||
|
- `keyboard: keyboard, RO`
|
||||||
|
|
||||||
|
# Mouse
|
||||||
|
|
||||||
|
## Enums
|
||||||
|
|
||||||
|
```lua
|
||||||
|
e2d.mouse_button = {
|
||||||
|
left, right, middle, x1, x2
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
- `cursor_pos: v2f, RO`
|
||||||
|
- `scroll_delta: v2f, RO`
|
||||||
|
|
||||||
|
- `is_any_button_pressed: boolean, RO`
|
||||||
|
- `is_any_button_just_pressed: boolean, RO`
|
||||||
|
- `is_any_button_just_released: boolean, RO`
|
||||||
|
|
||||||
|
- `pressed_buttons: [mouse_button], RO`
|
||||||
|
- `just_pressed_buttons: [mouse_button], RO`
|
||||||
|
- `just_released_buttons: [mouse_button], RO`
|
||||||
|
|
||||||
|
## Functions
|
||||||
|
|
||||||
|
- `is_button_pressed(button: mouse_button) -> boolean`
|
||||||
|
- `is_button_just_pressed(button: mouse_button) -> boolean`
|
||||||
|
- `is_button_just_released(button: mouse_button) -> boolean`
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
```lua
|
||||||
|
local d = e2d.debug
|
||||||
|
local m = e2d.input.mouse
|
||||||
|
|
||||||
|
d:trace("Cursor position: " .. m.cursor_pos)
|
||||||
|
|
||||||
|
local left_button = e2d.mouse_button.left
|
||||||
|
if m:is_button_just_pressed(left_button) then
|
||||||
|
d:trace("Mouse just pressed")
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
# Keyboard
|
||||||
|
|
||||||
|
## Enums
|
||||||
|
|
||||||
|
```lua
|
||||||
|
e2d.keyboard_key = {
|
||||||
|
_0, _1, _2, _3, _4, _5, _6, _7, _8, _9,
|
||||||
|
|
||||||
|
a, b, c, d, e, f, g, h, i, j, k, l, m,
|
||||||
|
n, o, p, q, r, s, t, u, v, w, x, y, z,
|
||||||
|
|
||||||
|
f1, f2, f3, f4, f5,
|
||||||
|
f6, f7, f8, f9, f10,
|
||||||
|
f11, f12, f13, f14, f15,
|
||||||
|
f16, f17, f18, f19, f20,
|
||||||
|
f21, f22, f23, f24, f25,
|
||||||
|
|
||||||
|
minus, equal, backspace, section_sign, grave_accent,
|
||||||
|
|
||||||
|
lbracket, rbracket, semicolon, apostrophe, backslash,
|
||||||
|
|
||||||
|
comma, period, slash,
|
||||||
|
|
||||||
|
escape, tab, caps_lock, space, enter,
|
||||||
|
|
||||||
|
lshift, rshift, lcontrol, rcontrol,
|
||||||
|
lalt, ralt, lsuper, rsuper, menu,
|
||||||
|
|
||||||
|
print_screen, scroll_lock, pause,
|
||||||
|
|
||||||
|
insert, del, home, end, page_up, page_down,
|
||||||
|
|
||||||
|
left, up, right, down,
|
||||||
|
|
||||||
|
kp_0, kp_1, kp_2, kp_3, kp_4,
|
||||||
|
kp_5, kp_6, kp_7, kp_8, kp_9,
|
||||||
|
|
||||||
|
kp_num_lock, kp_divide, kp_multiply, kp_subtract,
|
||||||
|
kp_add, kp_enter, kp_equal, kp_decimal
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
- `input_text: string, RO`
|
||||||
|
|
||||||
|
- `is_any_key_pressed: boolean, RO`
|
||||||
|
- `is_any_key_just_pressed: boolean, RO`
|
||||||
|
- `is_any_key_just_released: boolean, RO`
|
||||||
|
|
||||||
|
- `pressed_keys: [keyboard_key], RO`
|
||||||
|
- `just_pressed_keys: [keyboard_key], RO`
|
||||||
|
- `just_released_keys: [keyboard_key], RO`
|
||||||
|
|
||||||
|
## Functions
|
||||||
|
|
||||||
|
- `is_key_pressed(key: keyboard_key) -> boolean`
|
||||||
|
- `is_key_just_pressed(key: keyboard_key) -> boolean`
|
||||||
|
- `is_key_just_released(key: keyboard_key) -> boolean`
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
```lua
|
||||||
|
local d = e2d.debug
|
||||||
|
local k = e2d.input.keyboard
|
||||||
|
|
||||||
|
local forward_key = e2d.keyboard_key.w
|
||||||
|
if k:is_key_pressed(forward_key) then
|
||||||
|
d:trace("Move forward")
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
1
support/modules/library.md
Normal file
1
support/modules/library.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
# Library
|
||||||
1
support/modules/luasol.md
Normal file
1
support/modules/luasol.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
# Luasol
|
||||||
46
support/modules/window.md
Normal file
46
support/modules/window.md
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
# Window
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
- `enabled: boolean, RO`
|
||||||
|
- `visible: boolean, RO`
|
||||||
|
- `focused: boolean, RO`
|
||||||
|
- `minimized: boolean, RO`
|
||||||
|
|
||||||
|
- `fullscreen: boolean, RW`
|
||||||
|
- `cursor_hidden: boolean, RW`
|
||||||
|
|
||||||
|
- `real_size: v2f, RO`
|
||||||
|
- `virtual_size: v2f, RO`
|
||||||
|
- `framebuffer_size: v2f, RO`
|
||||||
|
|
||||||
|
- `title: string, RW`
|
||||||
|
- `should_close: boolean, RW`
|
||||||
|
|
||||||
|
## Functions
|
||||||
|
|
||||||
|
- `hide() -> void`
|
||||||
|
- `show() -> void`
|
||||||
|
- `restore() -> void`
|
||||||
|
- `minimize() -> void`
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
```lua
|
||||||
|
local w = e2d.window
|
||||||
|
local k = e2d.input.keyboard
|
||||||
|
|
||||||
|
local close_window =
|
||||||
|
k:is_key_just_pressed(e2d.keyboard_key.f32)
|
||||||
|
|
||||||
|
local toggle_fullscreen =
|
||||||
|
k:is_key_pressed(e2d.keyboard_key.lsuper) and
|
||||||
|
k:is_key_just_released(e2d.keyboard_key.enter)
|
||||||
|
|
||||||
|
if close_window then
|
||||||
|
w.should_close = true
|
||||||
|
elseif toggle_fullscreen then
|
||||||
|
w.fullscreen = not w.fullscreen
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
2
support/modules/world.md
Normal file
2
support/modules/world.md
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# World
|
||||||
|
|
||||||
44
support/node.md
Normal file
44
support/node.md
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
# Node
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
- `owner: gobject, RO`
|
||||||
|
|
||||||
|
- `transform: t3f, RW`
|
||||||
|
- `translation: v3f, RW`
|
||||||
|
- `rotation: q4f, RW`
|
||||||
|
- `scale: v3f, RW`
|
||||||
|
|
||||||
|
- `local_matrix: m4f, RO`
|
||||||
|
- `world_matrix: m4f, RO`
|
||||||
|
|
||||||
|
- `root: node, RO`
|
||||||
|
- `parent: node, RO`
|
||||||
|
|
||||||
|
- `child_count: number, RO`
|
||||||
|
- `child_count_recursive: number, RO`
|
||||||
|
|
||||||
|
- `first_child: node, RO`
|
||||||
|
- `last_child: node, RO`
|
||||||
|
- `prev_sibling: node, RO`
|
||||||
|
- `next_sibling: node, RO`
|
||||||
|
|
||||||
|
## Functions
|
||||||
|
|
||||||
|
- `remove_from_parent() -> boolean`
|
||||||
|
- `remove_all_children() -> number`
|
||||||
|
|
||||||
|
- `add_child(child: node) -> boolean`
|
||||||
|
- `add_child_to_back(child: node) -> boolean`
|
||||||
|
- `add_child_to_front(child: node) -> boolean`
|
||||||
|
- `add_child_before(before: node, child: node) -> boolean`
|
||||||
|
- `add_child_after(after: node, child: node) -> boolean`
|
||||||
|
- `add_sibling_before(sibling: node) -> boolean`
|
||||||
|
- `add_sibling_after(sibling: node) -> boolean`
|
||||||
|
- `remove_child(child: node) -> boolean`
|
||||||
|
|
||||||
|
- `send_backward() -> boolean`
|
||||||
|
- `bring_to_back() -> boolean`
|
||||||
|
- `send_forward() -> boolean`
|
||||||
|
- `bring_to_front() -> boolean`
|
||||||
|
|
||||||
Reference in New Issue
Block a user