game view and new icons
This commit is contained in:
@@ -95,6 +95,22 @@ namespace Noggit
|
||||
position += direction() * sign * factor;
|
||||
}
|
||||
|
||||
void Camera::move_forward_normalized(float sign, float dt)
|
||||
{
|
||||
// does not work....
|
||||
glm::vec3 up(0.0f, 1.0f, 0.0f);
|
||||
|
||||
auto test = direction();
|
||||
test.y -= 0.5f;
|
||||
while (test.y < -1.0f)
|
||||
test.y += 2.0f;
|
||||
|
||||
auto cross = glm::cross(direction(), up);
|
||||
glm::vec3 right = glm::normalize(cross);
|
||||
|
||||
position += right * sign * move_speed * dt;
|
||||
}
|
||||
|
||||
void Camera::move_horizontal (float sign, float dt)
|
||||
{
|
||||
glm::vec3 up (0.0f, 1.0f, 0.0f);
|
||||
|
||||
@@ -36,6 +36,8 @@ namespace Noggit
|
||||
|
||||
void move_forward_factor (float sign, float factor);
|
||||
|
||||
void move_forward_normalized(float sign, float dt);
|
||||
|
||||
void reset(float x, float y, float z, float roll, float yaw, float pitch);
|
||||
|
||||
glm::vec3 position;
|
||||
|
||||
@@ -1932,6 +1932,8 @@ void MapView::setupViewMenu()
|
||||
//! \todo space+h in object mode
|
||||
ADD_TOGGLE_NS (view_menu, "Hidden models", _draw_hidden_models);
|
||||
|
||||
ADD_TOGGLE_NS(view_menu, "Game Mode", _game_mode_camera);
|
||||
|
||||
auto debug_menu (view_menu->addMenu ("Debug"));
|
||||
ADD_TOGGLE_NS (debug_menu, "Occlusion boxes", _draw_occlusion_boxes);
|
||||
|
||||
@@ -3947,20 +3949,54 @@ void MapView::tick (float dt)
|
||||
_camera.add_to_pitch(math::degrees(lookat));
|
||||
_camera_moved_since_last_draw = true;
|
||||
}
|
||||
if (moving)
|
||||
|
||||
if (_game_mode_camera.get())
|
||||
{
|
||||
_camera.move_forward(moving, dt);
|
||||
_camera_moved_since_last_draw = true;
|
||||
if (moving)
|
||||
{
|
||||
_camera.move_forward(moving, dt);
|
||||
// TODO use normalized speed (doesn't slow down when looking up)
|
||||
// _camera.move_forward_normalized(moving, dt);
|
||||
}
|
||||
if (strafing)
|
||||
{
|
||||
_camera.move_horizontal(strafing, dt);
|
||||
}
|
||||
|
||||
// get ground z position
|
||||
// can be optimized by calling this only when moving/strafing or changing camera mode.
|
||||
auto ground_pos = _world.get()->get_ground_height(_camera.position);
|
||||
_camera.position.y = ground_pos.y + 2;
|
||||
_camera_moved_since_last_draw = true;
|
||||
|
||||
}
|
||||
if (strafing)
|
||||
else
|
||||
{
|
||||
_camera.move_horizontal(strafing, dt);
|
||||
_camera_moved_since_last_draw = true;
|
||||
}
|
||||
if (updown)
|
||||
{
|
||||
_camera.move_vertical(updown, dt);
|
||||
_camera_moved_since_last_draw = true;
|
||||
|
||||
if (moving)
|
||||
{
|
||||
_camera.move_forward(moving, dt);
|
||||
_camera_moved_since_last_draw = true;
|
||||
}
|
||||
if (strafing)
|
||||
{
|
||||
_camera.move_horizontal(strafing, dt);
|
||||
_camera_moved_since_last_draw = true;
|
||||
}
|
||||
if (updown)
|
||||
{
|
||||
_camera.move_vertical(updown, dt);
|
||||
_camera_moved_since_last_draw = true;
|
||||
}
|
||||
// camera collision to ground
|
||||
/*
|
||||
auto ground_height = _world.get()->get_ground_height(_camera.position).y;
|
||||
if (_camera.position.y < ground_height)
|
||||
{
|
||||
_camera.position.y = ground_height + 3;
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -149,12 +149,16 @@ public:
|
||||
Noggit::BoolToggleProperty _draw_wmo_doodads = {true};
|
||||
Noggit::BoolToggleProperty _draw_wmo_exterior = { true };
|
||||
Noggit::BoolToggleProperty _draw_models = {true};
|
||||
Noggit::BoolToggleProperty _draw_model_animations = {false};
|
||||
Noggit::BoolToggleProperty _draw_model_animations = {true};
|
||||
Noggit::BoolToggleProperty _draw_hole_lines = {false};
|
||||
Noggit::BoolToggleProperty _draw_models_with_box = {false};
|
||||
Noggit::BoolToggleProperty _draw_fog = {false};
|
||||
Noggit::BoolToggleProperty _draw_hidden_models = {false};
|
||||
Noggit::BoolToggleProperty _draw_occlusion_boxes = {false};
|
||||
Noggit::BoolToggleProperty _game_mode_camera = { false };
|
||||
Noggit::BoolToggleProperty _draw_lights_zones = { false };
|
||||
Noggit::BoolToggleProperty _show_detail_info_window = { false };
|
||||
Noggit::BoolToggleProperty _show_minimap_window = { false };
|
||||
private:
|
||||
|
||||
int _selected_area_id = -1;
|
||||
@@ -385,8 +389,6 @@ private:
|
||||
Noggit::unsigned_int_property _displayed_water_layer = {0};
|
||||
Noggit::object_paste_params _object_paste_params;
|
||||
|
||||
Noggit::BoolToggleProperty _show_detail_info_window = {false};
|
||||
Noggit::BoolToggleProperty _show_minimap_window = {false};
|
||||
Noggit::BoolToggleProperty _show_node_editor = {false};
|
||||
Noggit::BoolToggleProperty _show_minimap_borders = {true};
|
||||
Noggit::BoolToggleProperty _show_minimap_skies = {false};
|
||||
|
||||
@@ -542,6 +542,34 @@ void World::delete_selected_models()
|
||||
reset_selection();
|
||||
}
|
||||
|
||||
glm::vec3 World::get_ground_height(glm::vec3 pos)
|
||||
{
|
||||
selection_result hits;
|
||||
|
||||
for_chunk_at(pos, [&](MapChunk* chunk)
|
||||
{
|
||||
{
|
||||
math::ray intersect_ray(pos, glm::vec3(0.f, -1.f, 0.f));
|
||||
chunk->intersect(intersect_ray, &hits);
|
||||
}
|
||||
// object is below ground
|
||||
if (hits.empty())
|
||||
{
|
||||
math::ray intersect_ray(pos, glm::vec3(0.f, 1.f, 0.f));
|
||||
chunk->intersect(intersect_ray, &hits);
|
||||
}
|
||||
});
|
||||
|
||||
// this should never happen
|
||||
if (hits.empty())
|
||||
{
|
||||
LogError << "Snap to ground ray intersection failed" << std::endl;
|
||||
return glm::vec3(0);
|
||||
}
|
||||
|
||||
return std::get<selected_chunk_type>(hits[0].second).position;
|
||||
}
|
||||
|
||||
void World::snap_selected_models_to_the_ground()
|
||||
{
|
||||
ZoneScoped;
|
||||
@@ -557,32 +585,8 @@ void World::snap_selected_models_to_the_ground()
|
||||
NOGGIT_CUR_ACTION->registerObjectTransformed(obj);
|
||||
glm::vec3& pos = obj->pos;
|
||||
|
||||
selection_result hits;
|
||||
|
||||
|
||||
for_chunk_at(pos, [&] (MapChunk* chunk)
|
||||
{
|
||||
{
|
||||
math::ray intersect_ray(pos, glm::vec3(0.f, -1.f, 0.f));
|
||||
chunk->intersect(intersect_ray, &hits);
|
||||
}
|
||||
// object is below ground
|
||||
if (hits.empty())
|
||||
{
|
||||
math::ray intersect_ray(pos, glm::vec3(0.f, 1.f, 0.f));
|
||||
chunk->intersect(intersect_ray, &hits);
|
||||
}
|
||||
});
|
||||
|
||||
// this should never happen
|
||||
if (hits.empty())
|
||||
{
|
||||
LogError << "Snap to ground ray intersection failed" << std::endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
// the ground can only be intersected once
|
||||
pos.y = std::get<selected_chunk_type>(hits[0].second).position.y;
|
||||
pos.y = get_ground_height(pos).y;
|
||||
|
||||
std::get<selected_object_type>(entry)->recalcExtents();
|
||||
|
||||
|
||||
@@ -132,6 +132,7 @@ public:
|
||||
void remove_from_selection(std::uint32_t uid);
|
||||
void reset_selection();
|
||||
void delete_selected_models();
|
||||
glm::vec3 get_ground_height(glm::vec3 pos);
|
||||
void range_add_to_selection(glm::vec3 const& pos, float radius, bool remove);
|
||||
Noggit::world_model_instances_storage& getModelInstanceStorage() { return _model_instance_storage; };
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ ViewToolbar::ViewToolbar(MapView* mapView)
|
||||
mapView->getWorld()->renderer()->markTerrainParamsUniformBlockDirty();
|
||||
});
|
||||
|
||||
SliderAction* climb_value = new SliderAction(tr("Configure climb maximum value"), 0, 1570, 856, tr("degrees"),
|
||||
SliderAction* climb_value = new SliderAction(tr("Climb maximum value"), 0, 1570, 856, tr("degrees"),
|
||||
std::function<int(int v)>() = [&](int v) {
|
||||
float radian = float(v) / 1000.f;
|
||||
float degrees = radian * (180.0 / 3.141592653589793238463);
|
||||
@@ -58,6 +58,30 @@ ViewToolbar::ViewToolbar(MapView* mapView)
|
||||
_climb_secondary_tool.push_back(climb_use_output_color_angle);
|
||||
_climb_secondary_tool.push_back(climb_value);
|
||||
_climb_secondary_tool.push_back(climb_reset_slider);
|
||||
|
||||
|
||||
// Time toolbar
|
||||
IconAction* time_icon = new IconAction(FontNoggitIcon{ FontNoggit::TIME_PAUSE });
|
||||
|
||||
PushButtonAction* pause_time = new PushButtonAction(tr("Pause Time"));
|
||||
connect(pause_time->pushbutton(), &QPushButton::clicked, [pause_time]()
|
||||
{
|
||||
|
||||
});
|
||||
|
||||
PushButtonAction* speed_up_time = new PushButtonAction(tr("Increase Time speed"));
|
||||
connect(climb_reset_slider->pushbutton(), &QPushButton::clicked, [pause_time]()
|
||||
{
|
||||
|
||||
});
|
||||
|
||||
_time_secondary_tool.push_back(time_icon);
|
||||
/*
|
||||
ADD_ACTION(view_menu, "Increase time speed", Qt::Key_N, [this] { mTimespeed += 90.0f; });
|
||||
ADD_ACTION(view_menu, "Decrease time speed", Qt::Key_B, [this] { mTimespeed = std::max(0.0f, mTimespeed - 90.0f); });
|
||||
ADD_ACTION(view_menu, "Pause time", Qt::Key_J, [this] { mTimespeed = 0.0f; });
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
ViewToolbar::ViewToolbar(MapView *mapView, ViewToolbar *tb)
|
||||
@@ -85,9 +109,10 @@ ViewToolbar::ViewToolbar(MapView *mapView, ViewToolbar *tb)
|
||||
|
||||
addSeparator();
|
||||
|
||||
// Animation
|
||||
add_tool_icon(mapView, &mapView->_draw_model_animations, tr("Animations"), FontNoggit::VISIBILITY_ANIMATION, tb);
|
||||
add_tool_icon(mapView, &mapView->_draw_fog, tr("Fog"), FontNoggit::VISIBILITY_FOG, tb);
|
||||
add_tool_icon(mapView, &mapView->_draw_mfbo, tr("Flight bounds"), FontNoggit::VISIBILITY_FLIGHT_BOUNDS, tb);
|
||||
// add_tool_icon(mapView, &mapView->_draw_lights_zones, tr("Light zones"), FontNoggit::VISIBILITY_LIGHT, tb);
|
||||
addSeparator();
|
||||
|
||||
// Hole lines always on
|
||||
@@ -100,6 +125,27 @@ ViewToolbar::ViewToolbar(MapView *mapView, ViewToolbar *tb)
|
||||
addWidget(tablet_sensitivity);
|
||||
*/
|
||||
|
||||
// some unused icons :
|
||||
// VISIBILITY_LIGHT VISIBILITY_GROUNDEFFECTS CAMERA_TURN CAMERA_SPEED_FASTER.. INFO TIME_NORMAL VIEW_AXIS VISIBILITY_UNUSED SETTINGS
|
||||
|
||||
// normal view mode icon, and make them only 1 at a time out of the 3 view modes?
|
||||
// add_tool_icon(mapView, &mapView->_game_mode_camera, tr("Normal view"), FontNoggit::VIEW_AXIS, tb);
|
||||
add_tool_icon(mapView, &mapView->_game_mode_camera, tr("Game view"), FontNoggit::VISIBILITY_UNUSED, tb);
|
||||
// add_tool_icon(mapView, &mapView->_game_mode_camera, tr("Tile view"), FontNoggit::VIEW_MODE_2D, tb);
|
||||
addSeparator();
|
||||
|
||||
add_tool_icon(mapView, &mapView->_show_detail_info_window, tr("Details info"), FontNoggit::INFO, tb);
|
||||
|
||||
// TODO : will open a panel with time controls, or use 2n toolbar
|
||||
//add_tool_icon(mapView, &mapView->_game_mode_camera, tr("Time speed"), FontNoggit::TIME_NORMAL, tb, _time_secondary_tool);
|
||||
|
||||
/*
|
||||
auto tile_view_btn = new QPushButton(this);
|
||||
tile_view_btn->setIcon(FontNoggitIcon{ FontNoggit::VIEW_MODE_2D });
|
||||
tile_view_btn->setToolTip("2D View");
|
||||
addWidget(tile_view_btn);
|
||||
*/
|
||||
|
||||
auto undo_stack_btn = new QPushButton(this);
|
||||
undo_stack_btn->setIcon(FontAwesomeIcon(FontAwesome::undo));
|
||||
undo_stack_btn->setToolTip("History");
|
||||
|
||||
@@ -28,6 +28,7 @@ namespace Noggit
|
||||
|
||||
/*secondary top tool*/
|
||||
QVector<QWidgetAction*> _climb_secondary_tool;
|
||||
QVector<QWidgetAction*> _time_secondary_tool;
|
||||
|
||||
/*secondary left tool*/
|
||||
QVector<QWidgetAction*> _flatten_secondary_tool;
|
||||
|
||||
Reference in New Issue
Block a user