|
|
@ -1,7 +1,10 @@ |
|
|
|
#include "glm/ext/vector_float2.hpp" // glm::vec2 |
|
|
|
#include "glm/ext/vector_float2.hpp" // glm::vec2 |
|
|
|
#include "glm/ext/vector_float3.hpp" // glm::vec3 |
|
|
|
#include "glm/ext/vector_float3.hpp" // glm::vec3 |
|
|
|
#include "glm/ext/vector_float4.hpp" // glm::vec4 |
|
|
|
#include "glm/ext/vector_float4.hpp" // glm::vec4 |
|
|
|
|
|
|
|
#include "glm/ext/matrix_transform.hpp" // glm::radians |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "inferno/input.h" |
|
|
|
|
|
|
|
#include "inferno/inputcodes.h" |
|
|
|
#include "inferno/scene/components.h" |
|
|
|
#include "inferno/scene/components.h" |
|
|
|
#include "inferno/script/registration.h" |
|
|
|
#include "inferno/script/registration.h" |
|
|
|
|
|
|
|
|
|
|
@ -11,13 +14,16 @@ namespace Inferno { |
|
|
|
{ |
|
|
|
{ |
|
|
|
glm(state); |
|
|
|
glm(state); |
|
|
|
component(state); |
|
|
|
component(state); |
|
|
|
|
|
|
|
input(state); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Registration::glm(sol::state_view& state) |
|
|
|
void Registration::glm(sol::state_view& state) |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto vec2 = state.new_usertype<glm::vec2>( |
|
|
|
auto glm = state["glm"].get_or_create<sol::table>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto vec2 = glm.new_usertype<glm::vec2>( |
|
|
|
"vec2", |
|
|
|
"vec2", |
|
|
|
sol::call_constructor, sol::constructors<glm::vec2(), glm::vec2(float), glm::vec2(float, float)>(), |
|
|
|
sol::call_constructor, sol::constructors<glm::vec2(), glm::vec2(glm::vec2), glm::vec2(float), glm::vec2(float, float)>(), |
|
|
|
"x", &glm::vec2::x, "y", &glm::vec2::y, |
|
|
|
"x", &glm::vec2::x, "y", &glm::vec2::y, |
|
|
|
"r", &glm::vec2::r, "g", &glm::vec2::g, |
|
|
|
"r", &glm::vec2::r, "g", &glm::vec2::g, |
|
|
|
"s", &glm::vec2::s, "t", &glm::vec2::t, |
|
|
|
"s", &glm::vec2::s, "t", &glm::vec2::t, |
|
|
@ -27,9 +33,9 @@ namespace Inferno { |
|
|
|
"__div", division<glm::vec2, float>() |
|
|
|
"__div", division<glm::vec2, float>() |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
auto vec3 = state.new_usertype<glm::vec3>( |
|
|
|
auto vec3 = glm.new_usertype<glm::vec3>( |
|
|
|
"vec3", |
|
|
|
"vec3", |
|
|
|
sol::call_constructor, sol::constructors<glm::vec3(), glm::vec3(float), glm::vec3(float, float, float)>(), |
|
|
|
sol::call_constructor, sol::constructors<glm::vec3(), glm::vec3(glm::vec3), glm::vec3(float), glm::vec3(float, float, float)>(), |
|
|
|
"x", &glm::vec3::x, "y", &glm::vec3::y, "z", &glm::vec3::z, |
|
|
|
"x", &glm::vec3::x, "y", &glm::vec3::y, "z", &glm::vec3::z, |
|
|
|
"r", &glm::vec3::r, "g", &glm::vec3::g, "b", &glm::vec3::b, |
|
|
|
"r", &glm::vec3::r, "g", &glm::vec3::g, "b", &glm::vec3::b, |
|
|
|
"s", &glm::vec3::s, "t", &glm::vec3::t, "p", &glm::vec3::p, |
|
|
|
"s", &glm::vec3::s, "t", &glm::vec3::t, "p", &glm::vec3::p, |
|
|
@ -40,9 +46,9 @@ namespace Inferno { |
|
|
|
// "__tostring", [](glm::vec3 self) { return self.x; } // Template!!! convert via logstream
|
|
|
|
// "__tostring", [](glm::vec3 self) { return self.x; } // Template!!! convert via logstream
|
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
auto vec4 = state.new_usertype<glm::vec4>( |
|
|
|
auto vec4 = glm.new_usertype<glm::vec4>( |
|
|
|
"vec4", |
|
|
|
"vec4", |
|
|
|
sol::call_constructor, sol::constructors<glm::vec4(), glm::vec4(float), glm::vec4(float, float, float, float)>(), |
|
|
|
sol::call_constructor, sol::constructors<glm::vec4(), glm::vec4(glm::vec4), glm::vec4(float), glm::vec4(float, float, float, float)>(), |
|
|
|
"x", &glm::vec4::x, "y", &glm::vec4::y, "z", &glm::vec4::z, "w", &glm::vec4::w, |
|
|
|
"x", &glm::vec4::x, "y", &glm::vec4::y, "z", &glm::vec4::z, "w", &glm::vec4::w, |
|
|
|
"r", &glm::vec4::r, "g", &glm::vec4::g, "b", &glm::vec4::b, "a", &glm::vec4::a, |
|
|
|
"r", &glm::vec4::r, "g", &glm::vec4::g, "b", &glm::vec4::b, "a", &glm::vec4::a, |
|
|
|
"s", &glm::vec4::s, "t", &glm::vec4::t, "p", &glm::vec4::p, "q", &glm::vec4::q, |
|
|
|
"s", &glm::vec4::s, "t", &glm::vec4::t, "p", &glm::vec4::p, "q", &glm::vec4::q, |
|
|
@ -51,6 +57,21 @@ namespace Inferno { |
|
|
|
"__mul", multiplication<glm::vec4, float>(), |
|
|
|
"__mul", multiplication<glm::vec4, float>(), |
|
|
|
"__div", division<glm::vec4, float>() |
|
|
|
"__div", division<glm::vec4, float>() |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
glm.set_function("radians", sol::overload( |
|
|
|
|
|
|
|
[](float v) { return glm::radians(v); }, |
|
|
|
|
|
|
|
[](const glm::vec2& v) { return glm::radians(v); }, |
|
|
|
|
|
|
|
[](const glm::vec3& v) { return glm::radians(v); }, |
|
|
|
|
|
|
|
[](const glm::vec4& v) { return glm::radians(v); } |
|
|
|
|
|
|
|
)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
glm.set_function("normalize", sol::overload( |
|
|
|
|
|
|
|
[](const glm::vec2& v) { return glm::normalize(v); }, |
|
|
|
|
|
|
|
[](const glm::vec3& v) { return glm::normalize(v); }, |
|
|
|
|
|
|
|
[](const glm::vec4& v) { return glm::normalize(v); } |
|
|
|
|
|
|
|
)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
glm.set_function("cross", [](const glm::vec3& x, const glm::vec3& y) { return glm::cross(x, y); }); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Registration::component(sol::state_view& state) |
|
|
|
void Registration::component(sol::state_view& state) |
|
|
@ -64,6 +85,10 @@ namespace Inferno { |
|
|
|
transformComponent["scale"] = &TransformComponent::scale; |
|
|
|
transformComponent["scale"] = &TransformComponent::scale; |
|
|
|
transformComponent["transform"] = &TransformComponent::transform; |
|
|
|
transformComponent["transform"] = &TransformComponent::transform; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto cameraType = state.new_enum("CameraType", |
|
|
|
|
|
|
|
"Orthographic", CameraType::Orthographic, |
|
|
|
|
|
|
|
"Perspective", CameraType::Perspective); |
|
|
|
|
|
|
|
|
|
|
|
auto cameraComponent = state.new_usertype<CameraComponent>("CameraComponent", sol::no_constructor); |
|
|
|
auto cameraComponent = state.new_usertype<CameraComponent>("CameraComponent", sol::no_constructor); |
|
|
|
cameraComponent["type"] = &CameraComponent::type; |
|
|
|
cameraComponent["type"] = &CameraComponent::type; |
|
|
|
cameraComponent["zoomLevel"] = &CameraComponent::zoomLevel; |
|
|
|
cameraComponent["zoomLevel"] = &CameraComponent::zoomLevel; |
|
|
@ -79,4 +104,14 @@ namespace Inferno { |
|
|
|
spriteComponent["texture"] = &SpriteComponent::texture; |
|
|
|
spriteComponent["texture"] = &SpriteComponent::texture; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Registration::input(sol::state_view& state) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
state.set_function("keyCode", &KeyCode); |
|
|
|
|
|
|
|
// state["keyCode"] = &KeyCode;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto input = state.new_usertype<Input>("Input", sol::no_constructor); |
|
|
|
|
|
|
|
input["isKeyPressed"] = &Input::isKeyPressed; |
|
|
|
|
|
|
|
input["getXOffset"] = &Input::getXOffset; |
|
|
|
|
|
|
|
input["getYOffset"] = &Input::getYOffset; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|