From 99cd9bada199535b4ab6e8836fc76745bbca528c Mon Sep 17 00:00:00 2001 From: bwent Date: Tue, 23 Jun 2015 16:22:34 -0700 Subject: [PATCH 1/4] Added Billboard entity property and enabled billboarding for text entities --- .../src/RenderableTextEntityItem.cpp | 18 +++++++++++++++--- libraries/entities/src/EntityItem.cpp | 4 ++++ libraries/entities/src/EntityItem.h | 6 +++++- .../entities/src/EntityItemProperties.cpp | 10 ++++++++-- libraries/entities/src/EntityItemProperties.h | 3 ++- .../src/EntityItemPropertiesDefaults.h | 1 + libraries/entities/src/EntityPropertyFlags.h | 2 ++ libraries/networking/src/PacketHeaders.cpp | 2 +- libraries/networking/src/PacketHeaders.h | 1 + 9 files changed, 39 insertions(+), 8 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableTextEntityItem.cpp b/libraries/entities-renderer/src/RenderableTextEntityItem.cpp index d06ffb9400..dac0ce14e5 100644 --- a/libraries/entities-renderer/src/RenderableTextEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableTextEntityItem.cpp @@ -16,6 +16,9 @@ #include #include #include +#include + + #include "RenderableTextEntityItem.h" #include "GLMHelpers.h" @@ -37,14 +40,22 @@ void RenderableTextEntityItem::render(RenderArgs* args) { transformToTopLeft.postTranslate(glm::vec3(-0.5f, 0.5f, 0.0f)); // Go to the top left transformToTopLeft.setScale(1.0f); // Use a scale of one so that the text is not deformed + // Render background + glm::vec3 minCorner = glm::vec3(0.0f, -dimensions.y, SLIGHTLY_BEHIND); + glm::vec3 maxCorner = glm::vec3(dimensions.x, 0.0f, SLIGHTLY_BEHIND); + + // rotate about vertical to face the camera + if (getBillboarded()) { + glm::vec3 position = minCorner; + glm::quat rotation = args->_viewFrustum->getOrientation(); + transformToTopLeft.setRotation(rotation); + } + // Batch render calls Q_ASSERT(args->_batch); gpu::Batch& batch = *args->_batch; batch.setModelTransform(transformToTopLeft); - // Render background - glm::vec3 minCorner = glm::vec3(0.0f, -dimensions.y, SLIGHTLY_BEHIND); - glm::vec3 maxCorner = glm::vec3(dimensions.x, 0.0f, SLIGHTLY_BEHIND); DependencyManager::get()->renderQuad(batch, minCorner, maxCorner, backgroundColor); float scale = _lineHeight / _textRenderer->getFontSize(); @@ -55,6 +66,7 @@ void RenderableTextEntityItem::render(RenderArgs* args) { glm::vec2 bounds = glm::vec2(dimensions.x - 2.0f * leftMargin, dimensions.y - 2.0f * topMargin); _textRenderer->draw(batch, leftMargin / scale, -topMargin / scale, _text, textColor, bounds / scale); + } diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index da5f96f503..a0b3a22a5b 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -69,6 +69,7 @@ EntityItem::EntityItem(const EntityItemID& entityItemID) : _name(ENTITY_ITEM_DEFAULT_NAME), _href(""), _description(""), + _billBoarded(false), _dirtyFlags(0), _element(nullptr), _physicsInfo(nullptr), @@ -121,6 +122,7 @@ EntityPropertyFlags EntityItem::getEntityProperties(EncodeBitstreamParams& param requestedProperties += PROP_SIMULATOR_ID; requestedProperties += PROP_HREF; requestedProperties += PROP_DESCRIPTION; + requestedProperties += PROP_BILLBOARDED; return requestedProperties; } @@ -917,6 +919,7 @@ EntityItemProperties EntityItem::getProperties() const { COPY_ENTITY_PROPERTY_TO_PROPERTIES(name, getName); COPY_ENTITY_PROPERTY_TO_PROPERTIES(href, getHref); COPY_ENTITY_PROPERTY_TO_PROPERTIES(description, getDescription); + COPY_ENTITY_PROPERTY_TO_PROPERTIES(billBoarded, getBillboarded); properties._defaultSettings = false; @@ -977,6 +980,7 @@ bool EntityItem::setProperties(const EntityItemProperties& properties) { SET_ENTITY_PROPERTY_FROM_PROPERTIES(name, setName); SET_ENTITY_PROPERTY_FROM_PROPERTIES(href, setHref); SET_ENTITY_PROPERTY_FROM_PROPERTIES(description, setDescription); + SET_ENTITY_PROPERTY_FROM_PROPERTIES(billBoarded, setBillboarded); if (somethingChanged) { uint64_t now = usecTimestampNow(); diff --git a/libraries/entities/src/EntityItem.h b/libraries/entities/src/EntityItem.h index 73f9127361..c61c856f89 100644 --- a/libraries/entities/src/EntityItem.h +++ b/libraries/entities/src/EntityItem.h @@ -313,7 +313,10 @@ public: const QString& getUserData() const { return _userData; } void setUserData(const QString& value) { _userData = value; } - + + bool getBillboarded() const { return _billBoarded; } + void setBillboarded(bool value) { _billBoarded = value; } + QUuid getSimulatorID() const { return _simulatorID; } void setSimulatorID(const QUuid& value); void updateSimulatorID(const QUuid& value); @@ -427,6 +430,7 @@ protected: QString _name; QString _href; //Hyperlink href QString _description; //Hyperlink description + bool _billBoarded; // NOTE: Damping is applied like this: v *= pow(1 - damping, dt) // diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index cbb3b1dc31..15108f68c0 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -98,6 +98,7 @@ CONSTRUCT_PROPERTY(backgroundMode, BACKGROUND_MODE_INHERIT), CONSTRUCT_PROPERTY(sourceUrl, ""), CONSTRUCT_PROPERTY(lineWidth, LineEntityItem::DEFAULT_LINE_WIDTH), CONSTRUCT_PROPERTY(linePoints, QVector()), +CONSTRUCT_PROPERTY(billBoarded, ENTITY_ITEM_DEFAULT_BILLBOARDED), _id(UNKNOWN_ENTITY_ID), @@ -444,6 +445,7 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool COPY_PROPERTY_TO_QSCRIPTVALUE(linePoints); COPY_PROPERTY_TO_QSCRIPTVALUE(href); COPY_PROPERTY_TO_QSCRIPTVALUE(description); + COPY_PROPERTY_TO_QSCRIPTVALUE(billBoarded); // Sitting properties support if (!skipDefaults) { @@ -555,7 +557,7 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object, bool COPY_PROPERTY_FROM_QSCRIPTVALUE(linePoints, qVectorVec3, setLinePoints); COPY_PROPERTY_FROM_QSCRIPTVALUE(href, QString, setHref); COPY_PROPERTY_FROM_QSCRIPTVALUE(description, QString, setDescription); - + COPY_PROPERTY_FROM_QSCRIPTVALUE(billBoarded, bool, setBillboarded); if (!honorReadOnly) { // this is used by the json reader to set things that we don't want javascript to able to affect. @@ -722,6 +724,7 @@ bool EntityItemProperties::encodeEntityEditPacket(PacketType command, EntityItem APPEND_ENTITY_PROPERTY(PROP_SIMULATOR_ID, properties.getSimulatorID()); APPEND_ENTITY_PROPERTY(PROP_HREF, properties.getHref()); APPEND_ENTITY_PROPERTY(PROP_DESCRIPTION, properties.getDescription()); + APPEND_ENTITY_PROPERTY(PROP_BILLBOARDED, properties.getBillboarded()); if (properties.getType() == EntityTypes::Web) { APPEND_ENTITY_PROPERTY(PROP_SOURCE_URL, properties.getSourceUrl()); @@ -974,6 +977,7 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_SIMULATOR_ID, QUuid, setSimulatorID); READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_HREF, QString, setHref); READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_DESCRIPTION, QString, setDescription); + READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_BILLBOARDED, bool, setBillboarded); if (properties.getType() == EntityTypes::Web) { READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_SOURCE_URL, QString, setSourceUrl); @@ -1161,7 +1165,9 @@ void EntityItemProperties::markAllChanged() { _hrefChanged = true; _descriptionChanged = true; - + + _billBoardedChanged = true; + } /// The maximum bounding cube for the entity, independent of it's rotation. diff --git a/libraries/entities/src/EntityItemProperties.h b/libraries/entities/src/EntityItemProperties.h index 068bc98f7e..4cca14ca19 100644 --- a/libraries/entities/src/EntityItemProperties.h +++ b/libraries/entities/src/EntityItemProperties.h @@ -150,7 +150,8 @@ public: DEFINE_PROPERTY_REF(LINE_POINTS, LinePoints, linePoints, QVector); DEFINE_PROPERTY_REF(PROP_HREF, Href, href, QString); DEFINE_PROPERTY_REF(PROP_DESCRIPTION, Description, description, QString); - + DEFINE_PROPERTY(PROP_BILLBOARDED, Billboarded, billBoarded, bool); + static QString getBackgroundModeString(BackgroundMode mode); diff --git a/libraries/entities/src/EntityItemPropertiesDefaults.h b/libraries/entities/src/EntityItemPropertiesDefaults.h index 11341b160c..1e3a016049 100644 --- a/libraries/entities/src/EntityItemPropertiesDefaults.h +++ b/libraries/entities/src/EntityItemPropertiesDefaults.h @@ -66,6 +66,7 @@ const float ENTITY_ITEM_DEFAULT_FRICTION = 0.5f; const bool ENTITY_ITEM_DEFAULT_IGNORE_FOR_COLLISIONS = false; const bool ENTITY_ITEM_DEFAULT_COLLISIONS_WILL_MOVE = false; +const bool ENTITY_ITEM_DEFAULT_BILLBOARDED = false; const float ENTITY_ITEM_DEFAULT_CUTOFF = PI / 2; diff --git a/libraries/entities/src/EntityPropertyFlags.h b/libraries/entities/src/EntityPropertyFlags.h index f1ebdb8a1f..44646c2643 100644 --- a/libraries/entities/src/EntityPropertyFlags.h +++ b/libraries/entities/src/EntityPropertyFlags.h @@ -122,6 +122,8 @@ enum EntityPropertyList { PROP_HREF, PROP_DESCRIPTION, + PROP_BILLBOARDED, + //////////////////////////////////////////////////////////////////////////////////////////////////// // ATTENTION: add new properties ABOVE this line PROP_AFTER_LAST_ITEM, diff --git a/libraries/networking/src/PacketHeaders.cpp b/libraries/networking/src/PacketHeaders.cpp index 78bb3f11e1..087c2942bd 100644 --- a/libraries/networking/src/PacketHeaders.cpp +++ b/libraries/networking/src/PacketHeaders.cpp @@ -73,7 +73,7 @@ PacketVersion versionForPacketType(PacketType packetType) { case PacketTypeEntityAdd: case PacketTypeEntityEdit: case PacketTypeEntityData: - return VERSION_ENTITIES_LINE_POINTS; + return VERSION_ENTITIES_BILLBOARDED; case PacketTypeEntityErase: return 2; case PacketTypeAudioStreamStats: diff --git a/libraries/networking/src/PacketHeaders.h b/libraries/networking/src/PacketHeaders.h index 228df1cdde..b66ec26d58 100644 --- a/libraries/networking/src/PacketHeaders.h +++ b/libraries/networking/src/PacketHeaders.h @@ -183,5 +183,6 @@ const PacketVersion VERSION_ENTITIES_HAVE_FRICTION = 26; const PacketVersion VERSION_NO_ENTITY_ID_SWAP = 27; const PacketVersion VERSION_ENTITIES_PARTICLE_FIX = 28; const PacketVersion VERSION_ENTITIES_LINE_POINTS = 29; +const PacketVersion VERSION_ENTITIES_BILLBOARDED = 30; #endif // hifi_PacketHeaders_h From 0516caaa323e7ec766721906c8f599ebbfe52b8b Mon Sep 17 00:00:00 2001 From: bwent Date: Wed, 24 Jun 2015 14:58:33 -0700 Subject: [PATCH 2/4] Added CHECK_PROPERTY_CHANGE macro --- libraries/entities/src/EntityItemProperties.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 15108f68c0..320514602c 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -350,6 +350,7 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const { CHECK_PROPERTY_CHANGE(PROP_LINE_POINTS, linePoints); CHECK_PROPERTY_CHANGE(PROP_HREF, href); CHECK_PROPERTY_CHANGE(PROP_DESCRIPTION, description); + CHECK_PROPERTY_CHANGE(PROP_BILLBOARDED, billBoarded); changedProperties += _stage.getChangedProperties(); changedProperties += _atmosphere.getChangedProperties(); From aa865680ab4264b098315b52127fc455972720de Mon Sep 17 00:00:00 2001 From: bwent Date: Thu, 25 Jun 2015 15:38:38 -0700 Subject: [PATCH 3/4] Added faceCamera property to Text Entities MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …and removed from base --- interface/src/ModelPropertiesDialog.cpp | 28 +++++++++++++++++-- interface/src/ModelPropertiesDialog.h | 2 ++ .../src/RenderableTextEntityItem.cpp | 14 +++++----- libraries/entities/src/EntityItem.cpp | 4 --- libraries/entities/src/EntityItem.h | 4 --- .../entities/src/EntityItemProperties.cpp | 16 ++++++----- libraries/entities/src/EntityItemProperties.h | 2 +- libraries/entities/src/EntityPropertyFlags.h | 2 +- libraries/entities/src/TextEntityItem.cpp | 9 +++++- libraries/entities/src/TextEntityItem.h | 5 ++++ libraries/networking/src/PacketHeaders.cpp | 2 +- libraries/networking/src/PacketHeaders.h | 2 +- 12 files changed, 61 insertions(+), 29 deletions(-) diff --git a/interface/src/ModelPropertiesDialog.cpp b/interface/src/ModelPropertiesDialog.cpp index 8e0541518a..49bc042e94 100644 --- a/interface/src/ModelPropertiesDialog.cpp +++ b/interface/src/ModelPropertiesDialog.cpp @@ -76,13 +76,16 @@ _geometry(geometry) connect(newFreeJoint, SIGNAL(clicked(bool)), SLOT(createNewFreeJoint())); } } - + _printButton = new QPushButton(tr("&Print Mapping")); + QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Reset); + buttons->addButton(_printButton, QDialogButtonBox::ActionRole); connect(buttons, SIGNAL(accepted()), SLOT(accept())); connect(buttons, SIGNAL(rejected()), SLOT(reject())); connect(buttons->button(QDialogButtonBox::Reset), SIGNAL(clicked(bool)), SLOT(reset())); - + connect(_printButton, SIGNAL(clicked(bool)), SLOT(printJointMapping())); + form->addRow(buttons); // reset to initialize the fields @@ -146,8 +149,29 @@ QVariantHash ModelPropertiesDialog::getMapping() const { } return mapping; + } + +void ModelPropertiesDialog::printJointMapping() const { + QVariantHash jointHash = getMapping(); + QHashIterator i(getMapping()); + qDebug() << "STARTING..."; + while (i.hasNext()) { + i.next(); + if(i.key() == "joint" || i.key() == "jointIndex") { + QHashIterator j(i.value().toHash()); + while(j.hasNext()) { + j.next(); + qDebug() << j.key() << ": " << j.value().toString(); + } + } else { + qDebug() << i.key() << ": " << i.value().toString(); + } + } +} + + static void setJointText(QComboBox* box, const QString& text) { box->setCurrentIndex(qMax(box->findText(text), 0)); } diff --git a/interface/src/ModelPropertiesDialog.h b/interface/src/ModelPropertiesDialog.h index 11abc5ab54..cce210f67d 100644 --- a/interface/src/ModelPropertiesDialog.h +++ b/interface/src/ModelPropertiesDialog.h @@ -39,6 +39,7 @@ private slots: void chooseTextureDirectory(); void updatePivotJoint(); void createNewFreeJoint(const QString& joint = QString()); + void printJointMapping() const; private: QComboBox* createJointBox(bool withNone = true) const; @@ -52,6 +53,7 @@ private: FBXGeometry _geometry; QLineEdit* _name = nullptr; QPushButton* _textureDirectory = nullptr; + QPushButton* _printButton = nullptr; QDoubleSpinBox* _scale = nullptr; QDoubleSpinBox* _translationX = nullptr; QDoubleSpinBox* _translationY = nullptr; diff --git a/libraries/entities-renderer/src/RenderableTextEntityItem.cpp b/libraries/entities-renderer/src/RenderableTextEntityItem.cpp index dac0ce14e5..245cf00a3d 100644 --- a/libraries/entities-renderer/src/RenderableTextEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableTextEntityItem.cpp @@ -44,18 +44,18 @@ void RenderableTextEntityItem::render(RenderArgs* args) { glm::vec3 minCorner = glm::vec3(0.0f, -dimensions.y, SLIGHTLY_BEHIND); glm::vec3 maxCorner = glm::vec3(dimensions.x, 0.0f, SLIGHTLY_BEHIND); - // rotate about vertical to face the camera - if (getBillboarded()) { - glm::vec3 position = minCorner; - glm::quat rotation = args->_viewFrustum->getOrientation(); - transformToTopLeft.setRotation(rotation); - } - + // Batch render calls Q_ASSERT(args->_batch); gpu::Batch& batch = *args->_batch; batch.setModelTransform(transformToTopLeft); + //rotate about vertical to face the camera + if (getFaceCamera()) { + transformToTopLeft.postRotate(args->_viewFrustum->getOrientation()); + batch.setModelTransform(transformToTopLeft); + } + DependencyManager::get()->renderQuad(batch, minCorner, maxCorner, backgroundColor); float scale = _lineHeight / _textRenderer->getFontSize(); diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index a0b3a22a5b..da5f96f503 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -69,7 +69,6 @@ EntityItem::EntityItem(const EntityItemID& entityItemID) : _name(ENTITY_ITEM_DEFAULT_NAME), _href(""), _description(""), - _billBoarded(false), _dirtyFlags(0), _element(nullptr), _physicsInfo(nullptr), @@ -122,7 +121,6 @@ EntityPropertyFlags EntityItem::getEntityProperties(EncodeBitstreamParams& param requestedProperties += PROP_SIMULATOR_ID; requestedProperties += PROP_HREF; requestedProperties += PROP_DESCRIPTION; - requestedProperties += PROP_BILLBOARDED; return requestedProperties; } @@ -919,7 +917,6 @@ EntityItemProperties EntityItem::getProperties() const { COPY_ENTITY_PROPERTY_TO_PROPERTIES(name, getName); COPY_ENTITY_PROPERTY_TO_PROPERTIES(href, getHref); COPY_ENTITY_PROPERTY_TO_PROPERTIES(description, getDescription); - COPY_ENTITY_PROPERTY_TO_PROPERTIES(billBoarded, getBillboarded); properties._defaultSettings = false; @@ -980,7 +977,6 @@ bool EntityItem::setProperties(const EntityItemProperties& properties) { SET_ENTITY_PROPERTY_FROM_PROPERTIES(name, setName); SET_ENTITY_PROPERTY_FROM_PROPERTIES(href, setHref); SET_ENTITY_PROPERTY_FROM_PROPERTIES(description, setDescription); - SET_ENTITY_PROPERTY_FROM_PROPERTIES(billBoarded, setBillboarded); if (somethingChanged) { uint64_t now = usecTimestampNow(); diff --git a/libraries/entities/src/EntityItem.h b/libraries/entities/src/EntityItem.h index c61c856f89..b27129c124 100644 --- a/libraries/entities/src/EntityItem.h +++ b/libraries/entities/src/EntityItem.h @@ -314,9 +314,6 @@ public: const QString& getUserData() const { return _userData; } void setUserData(const QString& value) { _userData = value; } - bool getBillboarded() const { return _billBoarded; } - void setBillboarded(bool value) { _billBoarded = value; } - QUuid getSimulatorID() const { return _simulatorID; } void setSimulatorID(const QUuid& value); void updateSimulatorID(const QUuid& value); @@ -430,7 +427,6 @@ protected: QString _name; QString _href; //Hyperlink href QString _description; //Hyperlink description - bool _billBoarded; // NOTE: Damping is applied like this: v *= pow(1 - damping, dt) // diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 320514602c..cab96eb2e6 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -98,7 +98,7 @@ CONSTRUCT_PROPERTY(backgroundMode, BACKGROUND_MODE_INHERIT), CONSTRUCT_PROPERTY(sourceUrl, ""), CONSTRUCT_PROPERTY(lineWidth, LineEntityItem::DEFAULT_LINE_WIDTH), CONSTRUCT_PROPERTY(linePoints, QVector()), -CONSTRUCT_PROPERTY(billBoarded, ENTITY_ITEM_DEFAULT_BILLBOARDED), +CONSTRUCT_PROPERTY(faceCamera, TextEntityItem::DEFAULT_FACE_CAMERA), _id(UNKNOWN_ENTITY_ID), @@ -350,7 +350,7 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const { CHECK_PROPERTY_CHANGE(PROP_LINE_POINTS, linePoints); CHECK_PROPERTY_CHANGE(PROP_HREF, href); CHECK_PROPERTY_CHANGE(PROP_DESCRIPTION, description); - CHECK_PROPERTY_CHANGE(PROP_BILLBOARDED, billBoarded); + CHECK_PROPERTY_CHANGE(PROP_FACE_CAMERA, faceCamera); changedProperties += _stage.getChangedProperties(); changedProperties += _atmosphere.getChangedProperties(); @@ -446,7 +446,7 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool COPY_PROPERTY_TO_QSCRIPTVALUE(linePoints); COPY_PROPERTY_TO_QSCRIPTVALUE(href); COPY_PROPERTY_TO_QSCRIPTVALUE(description); - COPY_PROPERTY_TO_QSCRIPTVALUE(billBoarded); + COPY_PROPERTY_TO_QSCRIPTVALUE(faceCamera); // Sitting properties support if (!skipDefaults) { @@ -558,7 +558,7 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object, bool COPY_PROPERTY_FROM_QSCRIPTVALUE(linePoints, qVectorVec3, setLinePoints); COPY_PROPERTY_FROM_QSCRIPTVALUE(href, QString, setHref); COPY_PROPERTY_FROM_QSCRIPTVALUE(description, QString, setDescription); - COPY_PROPERTY_FROM_QSCRIPTVALUE(billBoarded, bool, setBillboarded); + COPY_PROPERTY_FROM_QSCRIPTVALUE(faceCamera, bool, setFaceCamera); if (!honorReadOnly) { // this is used by the json reader to set things that we don't want javascript to able to affect. @@ -725,7 +725,7 @@ bool EntityItemProperties::encodeEntityEditPacket(PacketType command, EntityItem APPEND_ENTITY_PROPERTY(PROP_SIMULATOR_ID, properties.getSimulatorID()); APPEND_ENTITY_PROPERTY(PROP_HREF, properties.getHref()); APPEND_ENTITY_PROPERTY(PROP_DESCRIPTION, properties.getDescription()); - APPEND_ENTITY_PROPERTY(PROP_BILLBOARDED, properties.getBillboarded()); + if (properties.getType() == EntityTypes::Web) { APPEND_ENTITY_PROPERTY(PROP_SOURCE_URL, properties.getSourceUrl()); @@ -736,6 +736,7 @@ bool EntityItemProperties::encodeEntityEditPacket(PacketType command, EntityItem APPEND_ENTITY_PROPERTY(PROP_LINE_HEIGHT, properties.getLineHeight()); APPEND_ENTITY_PROPERTY(PROP_TEXT_COLOR, properties.getTextColor()); APPEND_ENTITY_PROPERTY(PROP_BACKGROUND_COLOR, properties.getBackgroundColor()); + APPEND_ENTITY_PROPERTY(PROP_FACE_CAMERA, properties.getFaceCamera()); } if (properties.getType() == EntityTypes::Model) { @@ -978,7 +979,7 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_SIMULATOR_ID, QUuid, setSimulatorID); READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_HREF, QString, setHref); READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_DESCRIPTION, QString, setDescription); - READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_BILLBOARDED, bool, setBillboarded); + if (properties.getType() == EntityTypes::Web) { READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_SOURCE_URL, QString, setSourceUrl); @@ -989,6 +990,7 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_LINE_HEIGHT, float, setLineHeight); READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_TEXT_COLOR, xColor, setTextColor); READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_BACKGROUND_COLOR, xColor, setBackgroundColor); + READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_FACE_CAMERA, bool, setFaceCamera); } if (properties.getType() == EntityTypes::Model) { @@ -1167,7 +1169,7 @@ void EntityItemProperties::markAllChanged() { _hrefChanged = true; _descriptionChanged = true; - _billBoardedChanged = true; + _faceCameraChanged = true; } diff --git a/libraries/entities/src/EntityItemProperties.h b/libraries/entities/src/EntityItemProperties.h index 4cca14ca19..a057b09bcd 100644 --- a/libraries/entities/src/EntityItemProperties.h +++ b/libraries/entities/src/EntityItemProperties.h @@ -150,7 +150,7 @@ public: DEFINE_PROPERTY_REF(LINE_POINTS, LinePoints, linePoints, QVector); DEFINE_PROPERTY_REF(PROP_HREF, Href, href, QString); DEFINE_PROPERTY_REF(PROP_DESCRIPTION, Description, description, QString); - DEFINE_PROPERTY(PROP_BILLBOARDED, Billboarded, billBoarded, bool); + DEFINE_PROPERTY(PROP_FACE_CAMERA, FaceCamera, faceCamera, bool); static QString getBackgroundModeString(BackgroundMode mode); diff --git a/libraries/entities/src/EntityPropertyFlags.h b/libraries/entities/src/EntityPropertyFlags.h index 44646c2643..5e35419ba2 100644 --- a/libraries/entities/src/EntityPropertyFlags.h +++ b/libraries/entities/src/EntityPropertyFlags.h @@ -122,7 +122,7 @@ enum EntityPropertyList { PROP_HREF, PROP_DESCRIPTION, - PROP_BILLBOARDED, + PROP_FACE_CAMERA, //////////////////////////////////////////////////////////////////////////////////////////////////// // ATTENTION: add new properties ABOVE this line diff --git a/libraries/entities/src/TextEntityItem.cpp b/libraries/entities/src/TextEntityItem.cpp index 5718fe8c12..31ee9e6676 100644 --- a/libraries/entities/src/TextEntityItem.cpp +++ b/libraries/entities/src/TextEntityItem.cpp @@ -27,6 +27,7 @@ const QString TextEntityItem::DEFAULT_TEXT(""); const float TextEntityItem::DEFAULT_LINE_HEIGHT = 0.1f; const xColor TextEntityItem::DEFAULT_TEXT_COLOR = { 255, 255, 255 }; const xColor TextEntityItem::DEFAULT_BACKGROUND_COLOR = { 0, 0, 0}; +const bool TextEntityItem::DEFAULT_FACE_CAMERA = false; EntityItemPointer TextEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { return EntityItemPointer(new TextEntityItem(entityID, properties)); @@ -54,6 +55,7 @@ EntityItemProperties TextEntityItem::getProperties() const { COPY_ENTITY_PROPERTY_TO_PROPERTIES(lineHeight, getLineHeight); COPY_ENTITY_PROPERTY_TO_PROPERTIES(textColor, getTextColorX); COPY_ENTITY_PROPERTY_TO_PROPERTIES(backgroundColor, getBackgroundColorX); + COPY_ENTITY_PROPERTY_TO_PROPERTIES(faceCamera, getFaceCamera); return properties; } @@ -65,6 +67,7 @@ bool TextEntityItem::setProperties(const EntityItemProperties& properties) { SET_ENTITY_PROPERTY_FROM_PROPERTIES(lineHeight, setLineHeight); SET_ENTITY_PROPERTY_FROM_PROPERTIES(textColor, setTextColor); SET_ENTITY_PROPERTY_FROM_PROPERTIES(backgroundColor, setBackgroundColor); + SET_ENTITY_PROPERTY_FROM_PROPERTIES(faceCamera, setFaceCamera); if (somethingChanged) { bool wantDebug = false; @@ -91,7 +94,8 @@ int TextEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data, READ_ENTITY_PROPERTY(PROP_LINE_HEIGHT, float, setLineHeight); READ_ENTITY_PROPERTY(PROP_TEXT_COLOR, rgbColor, setTextColor); READ_ENTITY_PROPERTY(PROP_BACKGROUND_COLOR, rgbColor, setBackgroundColor); - + READ_ENTITY_PROPERTY(PROP_FACE_CAMERA, bool, setFaceCamera); + return bytesRead; } @@ -103,6 +107,7 @@ EntityPropertyFlags TextEntityItem::getEntityProperties(EncodeBitstreamParams& p requestedProperties += PROP_LINE_HEIGHT; requestedProperties += PROP_TEXT_COLOR; requestedProperties += PROP_BACKGROUND_COLOR; + requestedProperties += PROP_FACE_CAMERA; return requestedProperties; } @@ -120,6 +125,8 @@ void TextEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBits APPEND_ENTITY_PROPERTY(PROP_LINE_HEIGHT, getLineHeight()); APPEND_ENTITY_PROPERTY(PROP_TEXT_COLOR, getTextColor()); APPEND_ENTITY_PROPERTY(PROP_BACKGROUND_COLOR, getBackgroundColor()); + APPEND_ENTITY_PROPERTY(PROP_FACE_CAMERA, getFaceCamera()); + } diff --git a/libraries/entities/src/TextEntityItem.h b/libraries/entities/src/TextEntityItem.h index 6d72896047..bf03c192c7 100644 --- a/libraries/entities/src/TextEntityItem.h +++ b/libraries/entities/src/TextEntityItem.h @@ -79,12 +79,17 @@ public: _backgroundColor[GREEN_INDEX] = value.green; _backgroundColor[BLUE_INDEX] = value.blue; } + + static const bool DEFAULT_FACE_CAMERA; + bool getFaceCamera() const { return _faceCamera; } + void setFaceCamera(bool value) { _faceCamera = value; } protected: QString _text; float _lineHeight; rgbColor _textColor; rgbColor _backgroundColor; + bool _faceCamera; }; #endif // hifi_TextEntityItem_h diff --git a/libraries/networking/src/PacketHeaders.cpp b/libraries/networking/src/PacketHeaders.cpp index 087c2942bd..29a670761a 100644 --- a/libraries/networking/src/PacketHeaders.cpp +++ b/libraries/networking/src/PacketHeaders.cpp @@ -73,7 +73,7 @@ PacketVersion versionForPacketType(PacketType packetType) { case PacketTypeEntityAdd: case PacketTypeEntityEdit: case PacketTypeEntityData: - return VERSION_ENTITIES_BILLBOARDED; + return VERSION_ENTITIES_FACE_CAMERA; case PacketTypeEntityErase: return 2; case PacketTypeAudioStreamStats: diff --git a/libraries/networking/src/PacketHeaders.h b/libraries/networking/src/PacketHeaders.h index b66ec26d58..1d064c3399 100644 --- a/libraries/networking/src/PacketHeaders.h +++ b/libraries/networking/src/PacketHeaders.h @@ -183,6 +183,6 @@ const PacketVersion VERSION_ENTITIES_HAVE_FRICTION = 26; const PacketVersion VERSION_NO_ENTITY_ID_SWAP = 27; const PacketVersion VERSION_ENTITIES_PARTICLE_FIX = 28; const PacketVersion VERSION_ENTITIES_LINE_POINTS = 29; -const PacketVersion VERSION_ENTITIES_BILLBOARDED = 30; +const PacketVersion VERSION_ENTITIES_FACE_CAMERA = 30; #endif // hifi_PacketHeaders_h From e3526467c71f0a315bedceda2df854175932de43 Mon Sep 17 00:00:00 2001 From: bwent Date: Thu, 25 Jun 2015 16:04:02 -0700 Subject: [PATCH 4/4] Revert changes to ModelPropertiesDialog --- interface/src/ModelPropertiesDialog.cpp | 28 ++----------------------- interface/src/ModelPropertiesDialog.h | 2 -- 2 files changed, 2 insertions(+), 28 deletions(-) diff --git a/interface/src/ModelPropertiesDialog.cpp b/interface/src/ModelPropertiesDialog.cpp index 49bc042e94..8e0541518a 100644 --- a/interface/src/ModelPropertiesDialog.cpp +++ b/interface/src/ModelPropertiesDialog.cpp @@ -76,16 +76,13 @@ _geometry(geometry) connect(newFreeJoint, SIGNAL(clicked(bool)), SLOT(createNewFreeJoint())); } } - _printButton = new QPushButton(tr("&Print Mapping")); - + QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Reset); - buttons->addButton(_printButton, QDialogButtonBox::ActionRole); connect(buttons, SIGNAL(accepted()), SLOT(accept())); connect(buttons, SIGNAL(rejected()), SLOT(reject())); connect(buttons->button(QDialogButtonBox::Reset), SIGNAL(clicked(bool)), SLOT(reset())); - connect(_printButton, SIGNAL(clicked(bool)), SLOT(printJointMapping())); - + form->addRow(buttons); // reset to initialize the fields @@ -149,29 +146,8 @@ QVariantHash ModelPropertiesDialog::getMapping() const { } return mapping; - } - -void ModelPropertiesDialog::printJointMapping() const { - QVariantHash jointHash = getMapping(); - QHashIterator i(getMapping()); - qDebug() << "STARTING..."; - while (i.hasNext()) { - i.next(); - if(i.key() == "joint" || i.key() == "jointIndex") { - QHashIterator j(i.value().toHash()); - while(j.hasNext()) { - j.next(); - qDebug() << j.key() << ": " << j.value().toString(); - } - } else { - qDebug() << i.key() << ": " << i.value().toString(); - } - } -} - - static void setJointText(QComboBox* box, const QString& text) { box->setCurrentIndex(qMax(box->findText(text), 0)); } diff --git a/interface/src/ModelPropertiesDialog.h b/interface/src/ModelPropertiesDialog.h index cce210f67d..11abc5ab54 100644 --- a/interface/src/ModelPropertiesDialog.h +++ b/interface/src/ModelPropertiesDialog.h @@ -39,7 +39,6 @@ private slots: void chooseTextureDirectory(); void updatePivotJoint(); void createNewFreeJoint(const QString& joint = QString()); - void printJointMapping() const; private: QComboBox* createJointBox(bool withNone = true) const; @@ -53,7 +52,6 @@ private: FBXGeometry _geometry; QLineEdit* _name = nullptr; QPushButton* _textureDirectory = nullptr; - QPushButton* _printButton = nullptr; QDoubleSpinBox* _scale = nullptr; QDoubleSpinBox* _translationX = nullptr; QDoubleSpinBox* _translationY = nullptr;