mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 12:27:08 +02:00
Translation, etc.
This commit is contained in:
parent
436727dfdb
commit
496f4a184e
4 changed files with 25 additions and 9 deletions
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include <AttributeRegistry.h>
|
||||
#include <MetavoxelMessages.h>
|
||||
#include <MetavoxelUtil.h>
|
||||
|
||||
#include "Application.h"
|
||||
#include "MetavoxelEditor.h"
|
||||
|
@ -902,15 +903,16 @@ ImportHeightfieldTool::ImportHeightfieldTool(MetavoxelEditor* editor) :
|
|||
widget->setLayout(form);
|
||||
layout()->addWidget(widget);
|
||||
|
||||
form->addRow("Height:", _height = new QPushButton());
|
||||
connect(_height, &QAbstractButton::clicked, this, &ImportHeightfieldTool::selectHeightFile);
|
||||
form->addRow("Color:", _color = new QPushButton());
|
||||
connect(_color, &QAbstractButton::clicked, this, &ImportHeightfieldTool::selectColorFile);
|
||||
form->addRow("Translation:", _translation = new Vec3Editor(widget));
|
||||
form->addRow("Scale:", _scale = new QDoubleSpinBox());
|
||||
_scale->setMinimum(-FLT_MAX);
|
||||
_scale->setMaximum(FLT_MAX);
|
||||
_scale->setPrefix("2^");
|
||||
_scale->setValue(1.0);
|
||||
form->addRow("Height:", _height = new QPushButton());
|
||||
connect(_height, &QAbstractButton::clicked, this, &ImportHeightfieldTool::selectHeightFile);
|
||||
form->addRow("Color:", _color = new QPushButton());
|
||||
connect(_color, &QAbstractButton::clicked, this, &ImportHeightfieldTool::selectColorFile);
|
||||
}
|
||||
|
||||
bool ImportHeightfieldTool::appliesTo(const AttributePointer& attribute) const {
|
||||
|
@ -918,7 +920,11 @@ bool ImportHeightfieldTool::appliesTo(const AttributePointer& attribute) const {
|
|||
}
|
||||
|
||||
void ImportHeightfieldTool::render() {
|
||||
_preview.render(glm::vec3(), pow(2.0, _scale->value()));
|
||||
float scale = pow(2.0, _scale->value());
|
||||
_translation->setSingleStep(scale);
|
||||
glm::vec3 quantizedTranslation = scale * glm::floor(_translation->getValue() / scale);
|
||||
_translation->setValue(quantizedTranslation);
|
||||
_preview.render(quantizedTranslation, scale);
|
||||
}
|
||||
|
||||
void ImportHeightfieldTool::selectHeightFile() {
|
||||
|
|
|
@ -26,6 +26,7 @@ class QPushButton;
|
|||
class QScrollArea;
|
||||
|
||||
class MetavoxelTool;
|
||||
class Vec3Editor;
|
||||
|
||||
/// Allows editing metavoxels.
|
||||
class MetavoxelEditor : public QWidget {
|
||||
|
@ -245,9 +246,10 @@ private:
|
|||
|
||||
void updatePreview();
|
||||
|
||||
Vec3Editor* _translation;
|
||||
QDoubleSpinBox* _scale;
|
||||
QPushButton* _height;
|
||||
QPushButton* _color;
|
||||
QDoubleSpinBox* _scale;
|
||||
|
||||
QImage _heightImage;
|
||||
QImage _colorImage;
|
||||
|
|
|
@ -401,6 +401,12 @@ BaseVec3Editor::BaseVec3Editor(QWidget* parent) : QWidget(parent) {
|
|||
layout->addWidget(_z = createComponentBox());
|
||||
}
|
||||
|
||||
void BaseVec3Editor::setSingleStep(double singleStep) {
|
||||
_x->setSingleStep(singleStep);
|
||||
_y->setSingleStep(singleStep);
|
||||
_z->setSingleStep(singleStep);
|
||||
}
|
||||
|
||||
QDoubleSpinBox* BaseVec3Editor::createComponentBox() {
|
||||
QDoubleSpinBox* box = new QDoubleSpinBox();
|
||||
box->setMinimum(-FLT_MAX);
|
||||
|
@ -411,9 +417,7 @@ QDoubleSpinBox* BaseVec3Editor::createComponentBox() {
|
|||
}
|
||||
|
||||
Vec3Editor::Vec3Editor(QWidget* parent) : BaseVec3Editor(parent) {
|
||||
_x->setSingleStep(0.01);
|
||||
_y->setSingleStep(0.01);
|
||||
_z->setSingleStep(0.01);
|
||||
setSingleStep(0.01);
|
||||
}
|
||||
|
||||
static void setComponentValue(QDoubleSpinBox* box, double value) {
|
||||
|
|
|
@ -153,6 +153,8 @@ public:
|
|||
|
||||
BaseVec3Editor(QWidget* parent);
|
||||
|
||||
void setSingleStep(double singleStep);
|
||||
|
||||
protected slots:
|
||||
|
||||
virtual void updateValue() = 0;
|
||||
|
@ -175,6 +177,8 @@ public:
|
|||
|
||||
Vec3Editor(QWidget* parent);
|
||||
|
||||
const glm::vec3& getValue() const { return _value; }
|
||||
|
||||
signals:
|
||||
|
||||
void valueChanged(const glm::vec3& vector);
|
||||
|
|
Loading…
Reference in a new issue