|
|
@@ -106,9 +106,10 @@ CE_EXPORT int camera_set_local_position(lua_State* L)
|
|
|
LuaStack stack(L);
|
|
|
|
|
|
Camera* camera = stack.get_camera(1);
|
|
|
- const Vector3 pos = stack.get_vector3(2);
|
|
|
+ Unit* unit = stack.get_unit(2);
|
|
|
+ const Vector3 pos = stack.get_vector3(3);
|
|
|
|
|
|
- camera->set_local_position(pos);
|
|
|
+ camera->set_local_position(unit, pos);
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
@@ -118,9 +119,10 @@ CE_EXPORT int camera_set_local_rotation(lua_State* L)
|
|
|
LuaStack stack(L);
|
|
|
|
|
|
Camera* camera = stack.get_camera(1);
|
|
|
- const Quaternion rot = stack.get_quaternion(2);
|
|
|
+ Unit* unit = stack.get_unit(2);
|
|
|
+ const Quaternion rot = stack.get_quaternion(3);
|
|
|
|
|
|
- camera->set_local_rotation(rot);
|
|
|
+ camera->set_local_rotation(unit, rot);
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
@@ -130,9 +132,10 @@ CE_EXPORT int camera_set_local_pose(lua_State* L)
|
|
|
LuaStack stack(L);
|
|
|
|
|
|
Camera* camera = stack.get_camera(1);
|
|
|
- const Matrix4x4 pose = stack.get_matrix4x4(2);
|
|
|
+ Unit* unit = stack.get_unit(2);
|
|
|
+ const Matrix4x4 pose = stack.get_matrix4x4(3);
|
|
|
|
|
|
- camera->set_local_pose(pose);
|
|
|
+ camera->set_local_pose(unit, pose);
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
@@ -251,18 +254,60 @@ CE_EXPORT int camera_set_far_clip_distance(lua_State* L)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+//-----------------------------------------------------------------------------
|
|
|
CE_EXPORT int camera_set_orthographic_metrics(lua_State* L)
|
|
|
{
|
|
|
LuaStack stack(L);
|
|
|
|
|
|
Camera* camera = stack.get_camera(1);
|
|
|
- const uint16_t width = stack.get_int(2);
|
|
|
- const uint16_t height = stack.get_int(3);
|
|
|
+ const float left = stack.get_float(2);
|
|
|
+ const float right = stack.get_float(3);
|
|
|
+ const float bottom = stack.get_float(4);
|
|
|
+ const float top = stack.get_float(5);
|
|
|
|
|
|
- camera->set_orthographic_metrics(width, height);
|
|
|
+ camera->set_orthographic_metrics(left, right, bottom, top);
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+//-----------------------------------------------------------------------------
|
|
|
+CE_EXPORT int camera_set_viewport_metrics(lua_State* L)
|
|
|
+{
|
|
|
+ LuaStack stack(L);
|
|
|
+
|
|
|
+ Camera* camera = stack.get_camera(1);
|
|
|
+ const int16_t x = stack.get_int(2);
|
|
|
+ const int16_t y = stack.get_int(3);
|
|
|
+ const int16_t width = stack.get_int(4);
|
|
|
+ const int16_t height = stack.get_int(5);
|
|
|
+
|
|
|
+ camera->set_viewport_metrics(x, y, width, height);
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+//-----------------------------------------------------------------------------
|
|
|
+CE_EXPORT int camera_screen_to_world(lua_State* L)
|
|
|
+{
|
|
|
+ LuaStack stack(L);
|
|
|
+
|
|
|
+ Camera* camera = stack.get_camera(1);
|
|
|
+ const Vector3 pos = stack.get_vector3(2);
|
|
|
+
|
|
|
+ stack.push_vector3(camera->screen_to_world(pos));
|
|
|
+ return 1;
|
|
|
+}
|
|
|
+
|
|
|
+//-----------------------------------------------------------------------------
|
|
|
+CE_EXPORT int camera_world_to_screen(lua_State* L)
|
|
|
+{
|
|
|
+ LuaStack stack(L);
|
|
|
+
|
|
|
+ Camera* camera = stack.get_camera(1);
|
|
|
+ const Vector3 pos = stack.get_vector3(2);
|
|
|
+
|
|
|
+ stack.push_vector3(camera->world_to_screen(pos));
|
|
|
+ return 1;
|
|
|
+}
|
|
|
+
|
|
|
//-----------------------------------------------------------------------------
|
|
|
void load_camera(LuaEnvironment& env)
|
|
|
{
|
|
|
@@ -285,7 +330,10 @@ void load_camera(LuaEnvironment& env)
|
|
|
env.load_module_function("Camera", "set_near_clip_distance", camera_set_near_clip_distance);
|
|
|
env.load_module_function("Camera", "far_clip_distance", camera_far_clip_distance);
|
|
|
env.load_module_function("Camera", "set_far_clip_distance", camera_set_far_clip_distance);
|
|
|
- env.load_module_function("Camera", "set_orthographic_metrics", camera_set_orthographic_metrics);
|
|
|
+ env.load_module_function("Camera", "set_orthographic_metrics", camera_set_orthographic_metrics);
|
|
|
+ env.load_module_function("Camera", "set_viewport_metrics", camera_set_viewport_metrics);
|
|
|
+ env.load_module_function("Camera", "screen_to_world", camera_screen_to_world);
|
|
|
+ env.load_module_function("Camera", "world_to_screen", camera_world_to_screen);
|
|
|
|
|
|
env.load_module_enum("Camera", "ORTHOGRAPHIC", ProjectionType::ORTHOGRAPHIC);
|
|
|
env.load_module_enum("Camera", "PERSPECTIVE", ProjectionType::PERSPECTIVE);
|