From e65f383b2532ffa0b4a59d8997aa3880b0088aed Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Wed, 1 Oct 2014 09:43:03 -0700 Subject: [PATCH] add localRenderAlpha property to entities --- libraries/entities/src/EntityItem.cpp | 8 +++++++- libraries/entities/src/EntityItem.h | 5 +++++ libraries/entities/src/EntityItemProperties.cpp | 8 ++++++++ libraries/entities/src/EntityItemProperties.h | 5 +++++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index 86fac0997e..12e79332c3 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -25,6 +25,7 @@ const float EntityItem::IMMORTAL = -1.0f; /// special lifetime which means the entity lives for ever. default lifetime const float EntityItem::DEFAULT_GLOW_LEVEL = 0.0f; +const float EntityItem::DEFAULT_LOCAL_RENDER_ALPHA = 1.0f; const float EntityItem::DEFAULT_MASS = 1.0f; const float EntityItem::DEFAULT_LIFETIME = EntityItem::IMMORTAL; const float EntityItem::DEFAULT_DAMPING = 0.5f; @@ -61,8 +62,8 @@ void EntityItem::initFromEntityItemID(const EntityItemID& entityItemID) { _position = glm::vec3(0,0,0); _rotation = DEFAULT_ROTATION; _dimensions = DEFAULT_DIMENSIONS; - _glowLevel = DEFAULT_GLOW_LEVEL; + _localRenderAlpha = DEFAULT_LOCAL_RENDER_ALPHA; _mass = DEFAULT_MASS; _velocity = DEFAULT_VELOCITY; _gravity = DEFAULT_GRAVITY; @@ -745,6 +746,7 @@ EntityItemProperties EntityItem::getProperties() const { COPY_ENTITY_PROPERTY_TO_PROPERTIES(angularVelocity, getAngularVelocity); COPY_ENTITY_PROPERTY_TO_PROPERTIES(angularDamping, getAngularDamping); COPY_ENTITY_PROPERTY_TO_PROPERTIES(glowLevel, getGlowLevel); + COPY_ENTITY_PROPERTY_TO_PROPERTIES(localRenderAlpha, getLocalRenderAlpha); COPY_ENTITY_PROPERTY_TO_PROPERTIES(visible, getVisible); COPY_ENTITY_PROPERTY_TO_PROPERTIES(ignoreForCollisions, getIgnoreForCollisions); COPY_ENTITY_PROPERTY_TO_PROPERTIES(collisionsWillMove, getCollisionsWillMove); @@ -779,6 +781,10 @@ bool EntityItem::setProperties(const EntityItemProperties& properties, bool forc SET_ENTITY_PROPERTY_FROM_PROPERTIES(angularVelocity, setAngularVelocity); SET_ENTITY_PROPERTY_FROM_PROPERTIES(angularDamping, setAngularDamping); SET_ENTITY_PROPERTY_FROM_PROPERTIES(glowLevel, setGlowLevel); + SET_ENTITY_PROPERTY_FROM_PROPERTIES(localRenderAlpha, setLocalRenderAlpha); + +qDebug() << "EntityItem::setProperties().... localRenderAlpha:" << getLocalRenderAlpha(); + SET_ENTITY_PROPERTY_FROM_PROPERTIES(visible, setVisible); SET_ENTITY_PROPERTY_FROM_PROPERTIES(ignoreForCollisions, setIgnoreForCollisions); SET_ENTITY_PROPERTY_FROM_PROPERTIES(collisionsWillMove, setCollisionsWillMove); diff --git a/libraries/entities/src/EntityItem.h b/libraries/entities/src/EntityItem.h index 621bd94287..b533db3015 100644 --- a/libraries/entities/src/EntityItem.h +++ b/libraries/entities/src/EntityItem.h @@ -153,6 +153,10 @@ public: float getGlowLevel() const { return _glowLevel; } void setGlowLevel(float glowLevel) { _glowLevel = glowLevel; } + static const float DEFAULT_LOCAL_RENDER_ALPHA; + float getLocalRenderAlpha() const { return _localRenderAlpha; } + void setLocalRenderAlpha(float localRenderAlpha) { _localRenderAlpha = localRenderAlpha; } + static const float DEFAULT_MASS; float getMass() const { return _mass; } void setMass(float value) { _mass = value; } @@ -263,6 +267,7 @@ protected: glm::vec3 _dimensions; glm::quat _rotation; float _glowLevel; + float _localRenderAlpha; float _mass; glm::vec3 _velocity; glm::vec3 _gravity; diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index f54ce274f9..ab2ca9b292 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -67,6 +67,7 @@ EntityItemProperties::EntityItemProperties() : _animationFrameIndex(ModelEntityItem::DEFAULT_ANIMATION_FRAME_INDEX), _animationFPS(ModelEntityItem::DEFAULT_ANIMATION_FPS), _glowLevel(0.0f), + _localRenderAlpha(1.0f), _naturalDimensions(1.0f, 1.0f, 1.0f), _colorChanged(false), @@ -76,6 +77,7 @@ EntityItemProperties::EntityItemProperties() : _animationFrameIndexChanged(false), _animationFPSChanged(false), _glowLevelChanged(false), + _localRenderAlphaChanged(false), _defaultSettings(true) { @@ -156,6 +158,7 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine) cons COPY_PROPERTY_TO_QSCRIPTVALUE(animationFrameIndex); COPY_PROPERTY_TO_QSCRIPTVALUE(animationFPS); COPY_PROPERTY_TO_QSCRIPTVALUE(glowLevel); + COPY_PROPERTY_TO_QSCRIPTVALUE(localRenderAlpha); COPY_PROPERTY_TO_QSCRIPTVALUE(ignoreForCollisions); COPY_PROPERTY_TO_QSCRIPTVALUE(collisionsWillMove); @@ -202,6 +205,10 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object) { COPY_PROPERTY_FROM_QSCRIPTVALUE_FLOAT(animationFPS, setAnimationFPS); COPY_PROPERTY_FROM_QSCRIPTVALUE_FLOAT(animationFrameIndex, setAnimationFrameIndex); COPY_PROPERTY_FROM_QSCRIPTVALUE_FLOAT(glowLevel, setGlowLevel); + COPY_PROPERTY_FROM_QSCRIPTVALUE_FLOAT(localRenderAlpha, setLocalRenderAlpha); + +qDebug() << "EntityItemProperties::copyFromScriptValue().... localRenderAlpha:" << getLocalRenderAlpha(); + COPY_PROPERTY_FROM_QSCRIPTVALUE_BOOL(ignoreForCollisions, setIgnoreForCollisions); COPY_PROPERTY_FROM_QSCRIPTVALUE_BOOL(collisionsWillMove, setCollisionsWillMove); @@ -605,6 +612,7 @@ void EntityItemProperties::markAllChanged() { _animationFrameIndexChanged = true; _animationFPSChanged = true; _glowLevelChanged = true; + _localRenderAlphaChanged = true; } AACube EntityItemProperties::getMaximumAACubeInTreeUnits() const { diff --git a/libraries/entities/src/EntityItemProperties.h b/libraries/entities/src/EntityItemProperties.h index 0d993acda9..3c77b63ab6 100644 --- a/libraries/entities/src/EntityItemProperties.h +++ b/libraries/entities/src/EntityItemProperties.h @@ -161,6 +161,7 @@ public: bool getAnimationIsPlaying() const { return _animationIsPlaying; } float getAnimationFPS() const { return _animationFPS; } float getGlowLevel() const { return _glowLevel; } + float getLocalRenderAlpha() const { return _localRenderAlpha; } const QString& getScript() const { return _script; } // model related properties @@ -171,6 +172,7 @@ public: void setAnimationIsPlaying(bool value) { _animationIsPlaying = value; _animationIsPlayingChanged = true; } void setAnimationFPS(float value) { _animationFPS = value; _animationFPSChanged = true; } void setGlowLevel(float value) { _glowLevel = value; _glowLevelChanged = true; } + void setLocalRenderAlpha(float value) { _localRenderAlpha = value; _localRenderAlphaChanged = true; } void setScript(const QString& value) { _script = value; _scriptChanged = true; } @@ -201,6 +203,7 @@ public: bool animationFrameIndexChanged() const { return _animationFrameIndexChanged; } bool animationFPSChanged() const { return _animationFPSChanged; } bool glowLevelChanged() const { return _glowLevelChanged; } + bool localRenderAlphaChanged() const { return _localRenderAlphaChanged; } void clearID() { _id = UNKNOWN_ENTITY_ID; _idSet = false; } void markAllChanged(); @@ -283,6 +286,7 @@ private: float _animationFrameIndex; float _animationFPS; float _glowLevel; + float _localRenderAlpha; QVector _sittingPoints; glm::vec3 _naturalDimensions; @@ -293,6 +297,7 @@ private: bool _animationFrameIndexChanged; bool _animationFPSChanged; bool _glowLevelChanged; + bool _localRenderAlphaChanged; bool _defaultSettings; };