mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-05 21:00:39 +02:00
More spanner bits.
This commit is contained in:
parent
5513524705
commit
55e2ebd92f
8 changed files with 117 additions and 19 deletions
|
@ -1088,6 +1088,7 @@ void Menu::showMetavoxelEditor() {
|
||||||
_MetavoxelEditor = new MetavoxelEditor();
|
_MetavoxelEditor = new MetavoxelEditor();
|
||||||
}
|
}
|
||||||
_MetavoxelEditor->raise();
|
_MetavoxelEditor->raise();
|
||||||
|
_MetavoxelEditor->activateWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::audioMuteToggled() {
|
void Menu::audioMuteToggled() {
|
||||||
|
|
|
@ -276,7 +276,7 @@ bool Model::render(float alpha) {
|
||||||
// render opaque meshes with alpha testing
|
// render opaque meshes with alpha testing
|
||||||
|
|
||||||
glEnable(GL_ALPHA_TEST);
|
glEnable(GL_ALPHA_TEST);
|
||||||
glAlphaFunc(GL_GREATER, 0.5f);
|
glAlphaFunc(GL_GREATER, 0.5f * alpha);
|
||||||
|
|
||||||
renderMeshes(alpha, false);
|
renderMeshes(alpha, false);
|
||||||
|
|
||||||
|
@ -916,7 +916,7 @@ void Model::renderMeshes(float alpha, bool translucent) {
|
||||||
if (!mesh.colors.isEmpty()) {
|
if (!mesh.colors.isEmpty()) {
|
||||||
glEnableClientState(GL_COLOR_ARRAY);
|
glEnableClientState(GL_COLOR_ARRAY);
|
||||||
} else {
|
} else {
|
||||||
glColor3f(1.0f, 1.0f, 1.0f);
|
glColor4f(1.0f, 1.0f, 1.0f, alpha);
|
||||||
}
|
}
|
||||||
if (!mesh.texCoords.isEmpty()) {
|
if (!mesh.texCoords.isEmpty()) {
|
||||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
|
|
@ -29,7 +29,7 @@ enum GridPlane {
|
||||||
const glm::vec2 INVALID_VECTOR(FLT_MAX, FLT_MAX);
|
const glm::vec2 INVALID_VECTOR(FLT_MAX, FLT_MAX);
|
||||||
|
|
||||||
MetavoxelEditor::MetavoxelEditor() :
|
MetavoxelEditor::MetavoxelEditor() :
|
||||||
QDialog(Application::getInstance()->getGLWidget()) {
|
QWidget(Application::getInstance()->getGLWidget(), Qt::Tool | Qt::WindowStaysOnTopHint) {
|
||||||
|
|
||||||
setWindowTitle("Metavoxel Editor");
|
setWindowTitle("Metavoxel Editor");
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
@ -519,9 +519,20 @@ void InsertSpannerTool::simulate(float deltaTime) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void InsertSpannerTool::render() {
|
void InsertSpannerTool::render() {
|
||||||
SharedObjectPointer spanner = _editor->getValue().value<SharedObjectPointer>();
|
Spanner* spanner = static_cast<Spanner*>(_editor->getValue().value<SharedObjectPointer>().data());
|
||||||
const float SPANNER_ALPHA = 1.0f;
|
Transformable* transformable = qobject_cast<Transformable*>(spanner);
|
||||||
static_cast<Spanner*>(spanner.data())->getRenderer()->render(SPANNER_ALPHA);
|
if (transformable) {
|
||||||
|
// find the intersection of the mouse ray with the grid and place the transformable there
|
||||||
|
glm::quat rotation = _editor->getGridRotation();
|
||||||
|
glm::quat inverseRotation = glm::inverse(rotation);
|
||||||
|
glm::vec3 rayOrigin = inverseRotation * Application::getInstance()->getMouseRayOrigin();
|
||||||
|
glm::vec3 rayDirection = inverseRotation * Application::getInstance()->getMouseRayDirection();
|
||||||
|
float position = _editor->getGridPosition();
|
||||||
|
float distance = (position - rayOrigin.z) / rayDirection.z;
|
||||||
|
transformable->setTranslation(rotation * glm::vec3(glm::vec2(rayOrigin + rayDirection * distance), position));
|
||||||
|
}
|
||||||
|
const float SPANNER_ALPHA = 0.25f;
|
||||||
|
spanner->getRenderer()->render(SPANNER_ALPHA);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InsertSpannerTool::appliesTo(const AttributePointer& attribute) const {
|
bool InsertSpannerTool::appliesTo(const AttributePointer& attribute) const {
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
#ifndef __interface__MetavoxelEditor__
|
#ifndef __interface__MetavoxelEditor__
|
||||||
#define __interface__MetavoxelEditor__
|
#define __interface__MetavoxelEditor__
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
#include "renderer/ProgramObject.h"
|
#include "renderer/ProgramObject.h"
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ class QScrollArea;
|
||||||
class MetavoxelTool;
|
class MetavoxelTool;
|
||||||
|
|
||||||
/// Allows editing metavoxels.
|
/// Allows editing metavoxels.
|
||||||
class MetavoxelEditor : public QDialog {
|
class MetavoxelEditor : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
|
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QColorDialog>
|
#include <QColorDialog>
|
||||||
#include <QComboBox>
|
|
||||||
#include <QDoubleSpinBox>
|
#include <QDoubleSpinBox>
|
||||||
#include <QFormLayout>
|
#include <QFormLayout>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
@ -18,6 +17,7 @@
|
||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QScriptEngine>
|
#include <QScriptEngine>
|
||||||
|
#include <QSettings>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
|
@ -54,6 +54,7 @@ public:
|
||||||
|
|
||||||
DoubleEditor::DoubleEditor(QWidget* parent) : QDoubleSpinBox(parent) {
|
DoubleEditor::DoubleEditor(QWidget* parent) : QDoubleSpinBox(parent) {
|
||||||
setMinimum(-FLT_MAX);
|
setMinimum(-FLT_MAX);
|
||||||
|
setMaximum(FLT_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
DelegatingItemEditorFactory::DelegatingItemEditorFactory() :
|
DelegatingItemEditorFactory::DelegatingItemEditorFactory() :
|
||||||
|
@ -117,6 +118,12 @@ static QItemEditorCreatorBase* createQColorEditorCreator() {
|
||||||
return creator;
|
return creator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static QItemEditorCreatorBase* createQUrlEditorCreator() {
|
||||||
|
QItemEditorCreatorBase* creator = new LazyItemEditorCreator<QUrlEditor>();
|
||||||
|
getItemEditorFactory()->registerEditor(qMetaTypeId<QUrl>(), creator);
|
||||||
|
return creator;
|
||||||
|
}
|
||||||
|
|
||||||
static QItemEditorCreatorBase* createVec3EditorCreator() {
|
static QItemEditorCreatorBase* createVec3EditorCreator() {
|
||||||
QItemEditorCreatorBase* creator = new LazyItemEditorCreator<Vec3Editor>();
|
QItemEditorCreatorBase* creator = new LazyItemEditorCreator<Vec3Editor>();
|
||||||
getItemEditorFactory()->registerEditor(qMetaTypeId<glm::vec3>(), creator);
|
getItemEditorFactory()->registerEditor(qMetaTypeId<glm::vec3>(), creator);
|
||||||
|
@ -132,6 +139,7 @@ static QItemEditorCreatorBase* createParameterizedURLEditorCreator() {
|
||||||
static QItemEditorCreatorBase* doubleEditorCreator = createDoubleEditorCreator();
|
static QItemEditorCreatorBase* doubleEditorCreator = createDoubleEditorCreator();
|
||||||
static QItemEditorCreatorBase* qMetaObjectEditorCreator = createQMetaObjectEditorCreator();
|
static QItemEditorCreatorBase* qMetaObjectEditorCreator = createQMetaObjectEditorCreator();
|
||||||
static QItemEditorCreatorBase* qColorEditorCreator = createQColorEditorCreator();
|
static QItemEditorCreatorBase* qColorEditorCreator = createQColorEditorCreator();
|
||||||
|
static QItemEditorCreatorBase* qUrlEditorCreator = createQUrlEditorCreator();
|
||||||
static QItemEditorCreatorBase* vec3EditorCreator = createVec3EditorCreator();
|
static QItemEditorCreatorBase* vec3EditorCreator = createVec3EditorCreator();
|
||||||
static QItemEditorCreatorBase* parameterizedURLEditorCreator = createParameterizedURLEditorCreator();
|
static QItemEditorCreatorBase* parameterizedURLEditorCreator = createParameterizedURLEditorCreator();
|
||||||
|
|
||||||
|
@ -211,6 +219,36 @@ void QColorEditor::selectColor() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QUrlEditor::QUrlEditor(QWidget* parent) :
|
||||||
|
QComboBox(parent) {
|
||||||
|
|
||||||
|
setEditable(true);
|
||||||
|
setInsertPolicy(InsertAtTop);
|
||||||
|
|
||||||
|
// populate initial URL list from settings
|
||||||
|
addItems(QSettings().value("editorURLs").toStringList());
|
||||||
|
|
||||||
|
connect(this, SIGNAL(activated(const QString&)), SLOT(updateURL(const QString&)));
|
||||||
|
connect(model(), SIGNAL(rowsInserted(const QModelIndex&,int,int)), SLOT(updateSettings()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void QUrlEditor::setURL(const QUrl& url) {
|
||||||
|
setCurrentText((_url = url).toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
void QUrlEditor::updateURL(const QString& text) {
|
||||||
|
emit urlChanged(_url = text);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QUrlEditor::updateSettings() {
|
||||||
|
QStringList urls;
|
||||||
|
const int MAX_STORED_URLS = 10;
|
||||||
|
for (int i = 0, size = qMin(MAX_STORED_URLS, count()); i < size; i++) {
|
||||||
|
urls.append(itemText(i));
|
||||||
|
}
|
||||||
|
QSettings().setValue("editorURLs", urls);
|
||||||
|
}
|
||||||
|
|
||||||
Vec3Editor::Vec3Editor(QWidget* parent) : QWidget(parent) {
|
Vec3Editor::Vec3Editor(QWidget* parent) : QWidget(parent) {
|
||||||
QHBoxLayout* layout = new QHBoxLayout();
|
QHBoxLayout* layout = new QHBoxLayout();
|
||||||
layout->setContentsMargins(QMargins());
|
layout->setContentsMargins(QMargins());
|
||||||
|
@ -235,6 +273,7 @@ void Vec3Editor::updateVector() {
|
||||||
QDoubleSpinBox* Vec3Editor::createComponentBox() {
|
QDoubleSpinBox* Vec3Editor::createComponentBox() {
|
||||||
QDoubleSpinBox* box = new QDoubleSpinBox();
|
QDoubleSpinBox* box = new QDoubleSpinBox();
|
||||||
box->setMinimum(-FLT_MAX);
|
box->setMinimum(-FLT_MAX);
|
||||||
|
box->setMaximum(FLT_MAX);
|
||||||
box->setMaximumWidth(100);
|
box->setMaximumWidth(100);
|
||||||
connect(box, SIGNAL(valueChanged(double)), SLOT(updateVector()));
|
connect(box, SIGNAL(valueChanged(double)), SLOT(updateVector()));
|
||||||
return box;
|
return box;
|
||||||
|
@ -287,8 +326,9 @@ ParameterizedURLEditor::ParameterizedURLEditor(QWidget* parent) :
|
||||||
lineContainer->setLayout(lineLayout);
|
lineContainer->setLayout(lineLayout);
|
||||||
lineLayout->setContentsMargins(QMargins());
|
lineLayout->setContentsMargins(QMargins());
|
||||||
|
|
||||||
lineLayout->addWidget(_line = new QLineEdit(), 1);
|
lineLayout->addWidget(&_urlEditor, 1);
|
||||||
connect(_line, SIGNAL(textChanged(const QString&)), SLOT(updateURL()));
|
connect(&_urlEditor, SIGNAL(urlChanged(const QUrl&)), SLOT(updateURL()));
|
||||||
|
connect(&_urlEditor, SIGNAL(urlChanged(const QUrl&)), SLOT(updateParameters()));
|
||||||
|
|
||||||
QPushButton* refresh = new QPushButton("...");
|
QPushButton* refresh = new QPushButton("...");
|
||||||
connect(refresh, SIGNAL(clicked(bool)), SLOT(updateParameters()));
|
connect(refresh, SIGNAL(clicked(bool)), SLOT(updateParameters()));
|
||||||
|
@ -296,8 +336,7 @@ ParameterizedURLEditor::ParameterizedURLEditor(QWidget* parent) :
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParameterizedURLEditor::setURL(const ParameterizedURL& url) {
|
void ParameterizedURLEditor::setURL(const ParameterizedURL& url) {
|
||||||
_url = url;
|
_urlEditor.setURL((_url = url).getURL());
|
||||||
_line->setText(url.getURL().toString());
|
|
||||||
updateParameters();
|
updateParameters();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,7 +353,7 @@ void ParameterizedURLEditor::updateURL() {
|
||||||
widget->property("parameterName").toString()), widgetProperty.read(widget));
|
widget->property("parameterName").toString()), widgetProperty.read(widget));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
emit urlChanged(_url = ParameterizedURL(_line->text(), parameters));
|
emit urlChanged(_url = ParameterizedURL(_urlEditor.getURL(), parameters));
|
||||||
if (_program) {
|
if (_program) {
|
||||||
_program->disconnect(this);
|
_program->disconnect(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#define __interface__MetavoxelUtil__
|
#define __interface__MetavoxelUtil__
|
||||||
|
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
|
#include <QComboBox>
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
|
@ -21,9 +22,7 @@
|
||||||
#include "Bitstream.h"
|
#include "Bitstream.h"
|
||||||
|
|
||||||
class QByteArray;
|
class QByteArray;
|
||||||
class QComboBox;
|
|
||||||
class QDoubleSpinBox;
|
class QDoubleSpinBox;
|
||||||
class QLineEdit;
|
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
|
|
||||||
class HifiSockAddr;
|
class HifiSockAddr;
|
||||||
|
@ -107,6 +106,32 @@ private:
|
||||||
QColor _color;
|
QColor _color;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Editor for URL values.
|
||||||
|
class QUrlEditor : public QComboBox {
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QUrl url READ getURL WRITE setURL NOTIFY urlChanged USER true)
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
QUrlEditor(QWidget* parent = NULL);
|
||||||
|
|
||||||
|
void setURL(const QUrl& url);
|
||||||
|
const QUrl& getURL() { return _url; }
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
void urlChanged(const QUrl& url);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
|
||||||
|
void updateURL(const QString& text);
|
||||||
|
void updateSettings();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
QUrl _url;
|
||||||
|
};
|
||||||
|
|
||||||
/// Editor for vector values.
|
/// Editor for vector values.
|
||||||
class Vec3Editor : public QWidget {
|
class Vec3Editor : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -200,7 +225,7 @@ private:
|
||||||
ParameterizedURL _url;
|
ParameterizedURL _url;
|
||||||
QSharedPointer<NetworkProgram> _program;
|
QSharedPointer<NetworkProgram> _program;
|
||||||
|
|
||||||
QLineEdit* _line;
|
QUrlEditor _urlEditor;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* defined(__interface__MetavoxelUtil__) */
|
#endif /* defined(__interface__MetavoxelUtil__) */
|
||||||
|
|
|
@ -130,13 +130,17 @@ void SharedObjectEditor::updateType() {
|
||||||
}
|
}
|
||||||
delete form;
|
delete form;
|
||||||
}
|
}
|
||||||
|
QObject* oldObject = static_cast<SharedObject*>(_object.data());
|
||||||
|
const QMetaObject* oldMetaObject = NULL;
|
||||||
|
if (oldObject) {
|
||||||
|
oldMetaObject = oldObject->metaObject();
|
||||||
|
oldObject->disconnect(this);
|
||||||
|
}
|
||||||
const QMetaObject* metaObject = _type->itemData(_type->currentIndex()).value<const QMetaObject*>();
|
const QMetaObject* metaObject = _type->itemData(_type->currentIndex()).value<const QMetaObject*>();
|
||||||
if (metaObject == NULL) {
|
if (metaObject == NULL) {
|
||||||
_object.reset();
|
_object.reset();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QObject* oldObject = static_cast<SharedObject*>(_object.data());
|
|
||||||
const QMetaObject* oldMetaObject = oldObject ? oldObject->metaObject() : NULL;
|
|
||||||
QObject* newObject = metaObject->newInstance();
|
QObject* newObject = metaObject->newInstance();
|
||||||
|
|
||||||
QFormLayout* form = new QFormLayout();
|
QFormLayout* form = new QFormLayout();
|
||||||
|
@ -162,6 +166,10 @@ void SharedObjectEditor::updateType() {
|
||||||
if (widgetProperty.hasNotifySignal()) {
|
if (widgetProperty.hasNotifySignal()) {
|
||||||
connect(widget, signal(widgetProperty.notifySignal().methodSignature()), SLOT(propertyChanged()));
|
connect(widget, signal(widgetProperty.notifySignal().methodSignature()), SLOT(propertyChanged()));
|
||||||
}
|
}
|
||||||
|
if (property.hasNotifySignal()) {
|
||||||
|
widget->setProperty("notifySignalIndex", property.notifySignalIndex());
|
||||||
|
connect(newObject, signal(property.notifySignal().methodSignature()), SLOT(updateProperty()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_object = static_cast<SharedObject*>(newObject);
|
_object = static_cast<SharedObject*>(newObject);
|
||||||
|
@ -181,3 +189,16 @@ void SharedObjectEditor::propertyChanged() {
|
||||||
property.write(object, widget->property(valuePropertyName));
|
property.write(object, widget->property(valuePropertyName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SharedObjectEditor::updateProperty() {
|
||||||
|
QFormLayout* form = static_cast<QFormLayout*>(layout()->itemAt(1));
|
||||||
|
for (int i = 0; i < form->rowCount(); i++) {
|
||||||
|
QWidget* widget = form->itemAt(i, QFormLayout::FieldRole)->widget();
|
||||||
|
if (widget->property("notifySignalIndex").toInt() != senderSignalIndex()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
QMetaProperty property = _object->metaObject()->property(widget->property("propertyIndex").toInt());
|
||||||
|
QByteArray valuePropertyName = QItemEditorFactory::defaultFactory()->valuePropertyName(property.userType());
|
||||||
|
widget->setProperty(valuePropertyName, property.read(_object.data()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -168,6 +168,7 @@ private slots:
|
||||||
|
|
||||||
void updateType();
|
void updateType();
|
||||||
void propertyChanged();
|
void propertyChanged();
|
||||||
|
void updateProperty();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue