mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-02 02:42:46 +01:00
feat(editor): the EU07M window edits in 3D, holds vehicle parts and adds lights
The window of an EU07M model gets tabs: the tree of the nodes beside the properties of the node picked, the parts of the vehicle, the clips and channels, and the components of the model. The texts are Polish in lang/editor_pl.po. - With nothing selected, it shows the model of the vehicle driven (its body or its cab). - In the 3D view the node picked is framed and shows its axes and a gizmo to move or turn it. The light sources are marked in their colour, a spot with its axis, and a click on a mark picks its node. A press on the gizmo or a mark doesn't pick a scenery node, and the editor's own gizmo gives way. A double click in the tree flies the camera there. - The settings of a node: its position, rotation (degrees) and scale, and the distances it is drawn from and up to. - "Add a light source here" puts in a node light_<n> with a point or spot LGHT as the last child of the node. eu07m::insert_node moves every reference to the nodes after it, and eu07m::add_component appends a component; both have unit tests. - Changes show at once on the model the game has, through new TModel3d methods for the editor (ApplyEU07MLight, AddEditorLight, SetEditorTransform, SetEditorRange). The spot's cones are edited as half angles in degrees. - Parts of the vehicle: the editor holds the lamps, coupler hooks and hoses in their _off/_on/_xon state, and the pantographs up or down, whatever the vehicle does. A held pantograph moves at its own pace, in the editor too, up to the wire above it. Only the look changes: the electrics of the vehicle don't. - Neither the empty-scenery line nor the no-tracks hint shows in a scenery of models alone. - New editor self-test command: modelnode <name>.
This commit is contained in:
@@ -583,6 +583,7 @@ editor_mode::editor_mode() {
|
||||
ui()->set_new_scenery([this]() { m_newscenery_asked = true; });
|
||||
ui()->set_open_scenery([this]() { m_openscenery_asked = true; });
|
||||
ui()->set_memcell_focus([this](scene::basic_node *Node) { start_focus(Node); });
|
||||
ui()->set_model_focus([this](glm::dvec3 const &Point, double const Radius) { focus_sphere(Point, Radius); });
|
||||
ui()->set_edit_menu([this]() { render_edit_menu(); });
|
||||
ui()->set_tools_menu([this]() {
|
||||
render_track_presets_menu();
|
||||
@@ -753,10 +754,12 @@ void editor_mode::start_focus(scene::basic_node *node, double duration)
|
||||
if (!node)
|
||||
return;
|
||||
|
||||
glm::dvec3 const center = node->location();
|
||||
focus_sphere(node->location(), std::max(1.0, static_cast<double>(node->radius())), duration);
|
||||
}
|
||||
|
||||
void editor_mode::focus_sphere(glm::dvec3 const ¢er, double const radius, double const duration)
|
||||
{
|
||||
// distance that frames the object's bounding sphere within the vertical FOV, with some margin
|
||||
double const radius = std::max(1.0, static_cast<double>(node->radius()));
|
||||
double const fovy = glm::radians(static_cast<double>(Global.FieldOfView) / std::max(0.01, static_cast<double>(Global.ZoomFactor)));
|
||||
double distance = radius / std::tan(fovy * 0.5) * 1.6;
|
||||
distance = std::clamp(distance, radius * 1.5, static_cast<double>(kMaxPlacementDistance));
|
||||
@@ -7121,8 +7124,9 @@ void editor_mode::render_gizmo()
|
||||
return;
|
||||
}
|
||||
|
||||
// the transform gizmo is suppressed while editing terrain, so the brush/chunk tool owns the mouse
|
||||
if (!gizmo_shown() || terrain_brush() || terrain_clicking())
|
||||
// the transform gizmo is suppressed while editing terrain, so the brush/chunk tool owns the mouse; the window of an EU07M
|
||||
// model shows the gizmo of a node of the model instead
|
||||
if (!gizmo_shown() || terrain_brush() || terrain_clicking() || ui()->model_gizmo_shown())
|
||||
{
|
||||
m_gizmo_using = false;
|
||||
m_track_gizmo_using = false;
|
||||
@@ -8361,8 +8365,8 @@ void editor_mode::on_mouse_button(int const Button, int const Action, int const
|
||||
auto const additive{mode == nodebank_panel::MODIFY && (Mods & GLFW_MOD_SHIFT) != 0};
|
||||
GfxRenderer->Pick_Node_Callback(
|
||||
[this, mode, rotation_mode, fixed_rotation_value, additive](scene::basic_node *node) {
|
||||
// the press turned out to be meant for the UI
|
||||
if (!viewport_click())
|
||||
// the press turned out to be meant for the UI, or for the gizmo or a mark of a light of the model window
|
||||
if (!viewport_click() || ui()->model_took_press())
|
||||
return;
|
||||
|
||||
auto *const previous{m_node};
|
||||
|
||||
Reference in New Issue
Block a user