asset browser: finalize asset browser overlay
This commit is contained in:
@@ -143,6 +143,26 @@ AssetBrowserWidget::AssetBrowserWidget(QWidget *parent)
|
||||
}
|
||||
);
|
||||
|
||||
connect(viewport_overlay_ui->cameraXButton, &QPushButton::clicked
|
||||
,[this]()
|
||||
{
|
||||
ui->viewport->resetCamera(0.f, 0.f, 0.f, 0.f, -90.f, 0.f);
|
||||
}
|
||||
);
|
||||
|
||||
connect(viewport_overlay_ui->cameraYButton, &QPushButton::clicked
|
||||
,[this]()
|
||||
{
|
||||
ui->viewport->resetCamera(0.f, 0.f, 0.f, 0.f, 0, 90.f);
|
||||
}
|
||||
);
|
||||
|
||||
connect(viewport_overlay_ui->cameraZButton, &QPushButton::clicked
|
||||
,[this]()
|
||||
{
|
||||
ui->viewport->resetCamera(0.f, 0.f, 0.f, 0.f, 0.f, 0.f);
|
||||
}
|
||||
);
|
||||
|
||||
_wmo_group_and_lod_regex = QRegularExpression(".+_\\d{3}(_lod.+)*.wmo");
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
|
||||
#include <QSettings>
|
||||
#include <QColor>
|
||||
#include <QMatrix4x4>
|
||||
#include <QVector3D>
|
||||
|
||||
|
||||
using namespace noggit::Red;
|
||||
@@ -105,9 +107,9 @@ void PreviewRenderer::setModelOffscreen(std::string const& filename)
|
||||
}
|
||||
|
||||
|
||||
void PreviewRenderer::resetCamera()
|
||||
void PreviewRenderer::resetCamera(float x, float y, float z, float roll, float yaw, float pitch)
|
||||
{
|
||||
_camera.reset();
|
||||
_camera.reset(x, y, z, roll, yaw, pitch);
|
||||
float radius = 0.f;
|
||||
|
||||
std::vector<math::vector_3d> extents = calcSceneExtents();
|
||||
@@ -416,4 +418,19 @@ QPixmap* PreviewRenderer::renderToPixmap()
|
||||
return &(_cache[curEntry] = std::move(result));
|
||||
}
|
||||
|
||||
void PreviewRenderer::setLightDirection(float y, float z)
|
||||
{
|
||||
_light_dir = {1.f, 0.f, 0.f};
|
||||
QMatrix4x4 matrix = QMatrix4x4();
|
||||
matrix.rotate(z, 1.f, 0.f, 0.f);
|
||||
matrix.rotate(y, 0.f, 1.f, 0.f);
|
||||
|
||||
QVector3D light_dir = {_light_dir.x, _light_dir.y, _light_dir.z};
|
||||
light_dir = matrix * light_dir;
|
||||
|
||||
_light_dir.x = light_dir.x();
|
||||
_light_dir.y = light_dir.y();
|
||||
_light_dir.z = light_dir.z();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -30,14 +30,14 @@ namespace noggit::Red
|
||||
public:
|
||||
explicit PreviewRenderer(int width, int height, noggit::NoggitRenderContext context, QWidget* parent = nullptr);
|
||||
|
||||
void resetCamera();
|
||||
void resetCamera(float x = 0.f, float y = 0.f, float z = 0.f, float roll = 0.f, float yaw = 120.f, float pitch = 20.f);
|
||||
QPixmap* renderToPixmap();
|
||||
|
||||
virtual void setModel(std::string const& filename);
|
||||
void setModelOffscreen(std::string const& filename);
|
||||
virtual void setPrefab(std::string const& filename) {};
|
||||
|
||||
void setLightDirection(float y, float z) { _light_dir.y = y / 180.0f; _light_dir.x = z / 180.0f; };
|
||||
void setLightDirection(float y, float z);
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -111,11 +111,11 @@ namespace noggit
|
||||
position += up * sign * move_speed * dt;
|
||||
}
|
||||
|
||||
void camera::reset()
|
||||
void camera::reset(float x, float y, float z, float roll, float yaw, float pitch)
|
||||
{
|
||||
position = {0.f, 0.f, 0.f};
|
||||
_roll = math::degrees(0.0f);
|
||||
_yaw = math::degrees(105.f);
|
||||
_pitch = math::degrees(20.f);
|
||||
position = {x, y, z};
|
||||
_roll = math::degrees(roll);
|
||||
_yaw = math::degrees(yaw);
|
||||
_pitch = math::degrees(pitch);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace noggit
|
||||
|
||||
void move_forward_factor (float sign, float factor);
|
||||
|
||||
void reset();
|
||||
void reset(float x, float y, float z, float roll, float yaw, float pitch);
|
||||
|
||||
math::vector_3d position;
|
||||
float move_speed;
|
||||
|
||||
@@ -291,7 +291,7 @@ namespace noggit
|
||||
_settings->setValue("assetBrowser/ambient_light", ui->assetBrowserAmbientLight->color());
|
||||
_settings->setValue("assetBrowser/copy_to_clipboard", ui->assetBrowserCopyToClipboard->isChecked());
|
||||
_settings->setValue("assetBrowser/default_model", ui->assetBrowserDefaultModel->text());
|
||||
_settings->setValue("assetBrowser/move_sensitivity", ui->assetBrowserMoveSensitivity->text());
|
||||
_settings->setValue("assetBrowser/move_sensitivity", ui->assetBrowserMoveSensitivity->value());
|
||||
|
||||
_settings->sync();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user