diff --git a/examples/html/entityProperties.html b/examples/html/entityProperties.html
index f54c2c9ce3..ef7791ea15 100644
--- a/examples/html/entityProperties.html
+++ b/examples/html/entityProperties.html
@@ -128,11 +128,11 @@
var elLightSections = document.querySelectorAll(".light-section");
var elLightSpotLight = document.getElementById("property-light-spot-light");
- var elLightDiffuseRed = document.getElementById("property-light-diffuse-red");
- var elLightDiffuseGreen = document.getElementById("property-light-diffuse-green");
- var elLightDiffuseBlue = document.getElementById("property-light-diffuse-blue");
+ var elLightColorRed = document.getElementById("property-light-color-red");
+ var elLightColorGreen = document.getElementById("property-light-color-green");
+ var elLightColorBlue = document.getElementById("property-light-color-blue");
- var elLightConstantAttenuation = document.getElementById("property-light-constant-attenuation");
+ var elLightIntensity = document.getElementById("property-light-intensity");
var elLightExponent = document.getElementById("property-light-exponent");
var elLightCutoff = document.getElementById("property-light-cutoff");
@@ -305,11 +305,11 @@
elLightSections[i].style.display = 'block';
}
- elLightDiffuseRed.value = properties.diffuseColor.red;
- elLightDiffuseGreen.value = properties.diffuseColor.green;
- elLightDiffuseBlue.value = properties.diffuseColor.blue;
+ elLightColorRed.value = properties.color.red;
+ elLightColorGreen.value = properties.color.green;
+ elLightColorBlue.value = properties.color.blue;
- elLightConstantAttenuation.value = properties.constantAttenuation;
+ elLightIntensity.value = properties.intensity;
elLightExponent.value = properties.exponent;
elLightCutoff.value = properties.cutoff;
}
@@ -380,13 +380,13 @@
elLightSpotLight.addEventListener('change', createEmitCheckedPropertyUpdateFunction('isSpotlight'));
- var lightDiffuseChangeFunction = createEmitColorPropertyUpdateFunction(
- 'diffuseColor', elLightDiffuseRed, elLightDiffuseGreen, elLightDiffuseBlue);
- elLightDiffuseRed.addEventListener('change', lightDiffuseChangeFunction);
- elLightDiffuseGreen.addEventListener('change', lightDiffuseChangeFunction);
- elLightDiffuseBlue.addEventListener('change', lightDiffuseChangeFunction);
+ var lightColorChangeFunction = createEmitColorPropertyUpdateFunction(
+ 'color', elLightColorRed, elLightColorGreen, elLightColorBlue);
+ elLightColorRed.addEventListener('change', lightColorChangeFunction);
+ elLightColorGreen.addEventListener('change', lightColorChangeFunction);
+ elLightColorBlue.addEventListener('change', lightColorChangeFunction);
- elLightConstantAttenuation.addEventListener('change', createEmitNumberPropertyUpdateFunction('constantAttenuation'));
+ elLightIntensity.addEventListener('change', createEmitNumberPropertyUpdateFunction('intensity'));
elLightExponent.addEventListener('change', createEmitNumberPropertyUpdateFunction('exponent'));
elLightCutoff.addEventListener('change', createEmitNumberPropertyUpdateFunction('cutoff'));
@@ -708,15 +708,15 @@
diff --git a/libraries/entities-renderer/src/RenderableLightEntityItem.cpp b/libraries/entities-renderer/src/RenderableLightEntityItem.cpp
index 7f630f1c8c..b5a2523158 100644
--- a/libraries/entities-renderer/src/RenderableLightEntityItem.cpp
+++ b/libraries/entities-renderer/src/RenderableLightEntityItem.cpp
@@ -32,13 +32,13 @@ void RenderableLightEntityItem::render(RenderArgs* args) {
float largestDiameter = glm::max(dimensions.x, dimensions.y, dimensions.z);
const float MAX_COLOR = 255.0f;
- float diffuseR = getDiffuseColor()[RED_INDEX] / MAX_COLOR;
- float diffuseG = getDiffuseColor()[GREEN_INDEX] / MAX_COLOR;
- float diffuseB = getDiffuseColor()[BLUE_INDEX] / MAX_COLOR;
+ float colorR = getColor()[RED_INDEX] / MAX_COLOR;
+ float colorG = getColor()[GREEN_INDEX] / MAX_COLOR;
+ float colorB = getColor()[BLUE_INDEX] / MAX_COLOR;
- glm::vec3 color = glm::vec3(diffuseR, diffuseG, diffuseB);
+ glm::vec3 color = glm::vec3(colorR, colorG, colorB);
- float intensity = getConstantAttenuation();
+ float intensity = getIntensity();
float exponent = getExponent();
float cutoff = glm::radians(getCutoff());
diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp
index f3f84876ba..e53a6ede3d 100644
--- a/libraries/entities/src/EntityItemProperties.cpp
+++ b/libraries/entities/src/EntityItemProperties.cpp
@@ -49,12 +49,7 @@ EntityItemProperties::EntityItemProperties() :
CONSTRUCT_PROPERTY(ignoreForCollisions, ENTITY_ITEM_DEFAULT_IGNORE_FOR_COLLISIONS),
CONSTRUCT_PROPERTY(collisionsWillMove, ENTITY_ITEM_DEFAULT_COLLISIONS_WILL_MOVE),
CONSTRUCT_PROPERTY(isSpotlight, false),
- CONSTRUCT_PROPERTY(diffuseColor, ),
- CONSTRUCT_PROPERTY(ambientColor, ),
- CONSTRUCT_PROPERTY(specularColor, ),
- CONSTRUCT_PROPERTY(constantAttenuation, 1.0f),
- CONSTRUCT_PROPERTY(linearAttenuation, 0.0f),
- CONSTRUCT_PROPERTY(quadraticAttenuation, 0.0f),
+ CONSTRUCT_PROPERTY(intensity, 1.0f),
CONSTRUCT_PROPERTY(exponent, 0.0f),
CONSTRUCT_PROPERTY(cutoff, PI),
CONSTRUCT_PROPERTY(locked, ENTITY_ITEM_DEFAULT_LOCKED),
@@ -222,12 +217,7 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const {
CHECK_PROPERTY_CHANGE(PROP_IGNORE_FOR_COLLISIONS, ignoreForCollisions);
CHECK_PROPERTY_CHANGE(PROP_COLLISIONS_WILL_MOVE, collisionsWillMove);
CHECK_PROPERTY_CHANGE(PROP_IS_SPOTLIGHT, isSpotlight);
- CHECK_PROPERTY_CHANGE(PROP_DIFFUSE_COLOR, diffuseColor);
- CHECK_PROPERTY_CHANGE(PROP_AMBIENT_COLOR, ambientColor);
- CHECK_PROPERTY_CHANGE(PROP_SPECULAR_COLOR, specularColor);
- CHECK_PROPERTY_CHANGE(PROP_CONSTANT_ATTENUATION, constantAttenuation);
- CHECK_PROPERTY_CHANGE(PROP_LINEAR_ATTENUATION, linearAttenuation);
- CHECK_PROPERTY_CHANGE(PROP_QUADRATIC_ATTENUATION, quadraticAttenuation);
+ CHECK_PROPERTY_CHANGE(PROP_INTENSITY, intensity);
CHECK_PROPERTY_CHANGE(PROP_EXPONENT, exponent);
CHECK_PROPERTY_CHANGE(PROP_CUTOFF, cutoff);
CHECK_PROPERTY_CHANGE(PROP_LOCKED, locked);
@@ -281,12 +271,7 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine) cons
COPY_PROPERTY_TO_QSCRIPTVALUE(ignoreForCollisions);
COPY_PROPERTY_TO_QSCRIPTVALUE(collisionsWillMove);
COPY_PROPERTY_TO_QSCRIPTVALUE(isSpotlight);
- COPY_PROPERTY_TO_QSCRIPTVALUE_COLOR_GETTER(diffuseColor, getDiffuseColor());
- COPY_PROPERTY_TO_QSCRIPTVALUE_COLOR_GETTER(ambientColor, getAmbientColor());
- COPY_PROPERTY_TO_QSCRIPTVALUE_COLOR_GETTER(specularColor, getSpecularColor());
- COPY_PROPERTY_TO_QSCRIPTVALUE(constantAttenuation);
- COPY_PROPERTY_TO_QSCRIPTVALUE(linearAttenuation);
- COPY_PROPERTY_TO_QSCRIPTVALUE(quadraticAttenuation);
+ COPY_PROPERTY_TO_QSCRIPTVALUE(intensity);
COPY_PROPERTY_TO_QSCRIPTVALUE(exponent);
COPY_PROPERTY_TO_QSCRIPTVALUE(cutoff);
COPY_PROPERTY_TO_QSCRIPTVALUE(locked);
@@ -359,12 +344,7 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object) {
COPY_PROPERTY_FROM_QSCRIPTVALUE_BOOL(ignoreForCollisions, setIgnoreForCollisions);
COPY_PROPERTY_FROM_QSCRIPTVALUE_BOOL(collisionsWillMove, setCollisionsWillMove);
COPY_PROPERTY_FROM_QSCRIPTVALUE_BOOL(isSpotlight, setIsSpotlight);
- COPY_PROPERTY_FROM_QSCRIPTVALUE_COLOR(diffuseColor, setDiffuseColor);
- COPY_PROPERTY_FROM_QSCRIPTVALUE_COLOR(ambientColor, setAmbientColor);
- COPY_PROPERTY_FROM_QSCRIPTVALUE_COLOR(specularColor, setSpecularColor);
- COPY_PROPERTY_FROM_QSCRIPTVALUE_FLOAT(constantAttenuation, setConstantAttenuation);
- COPY_PROPERTY_FROM_QSCRIPTVALUE_FLOAT(linearAttenuation, setLinearAttenuation);
- COPY_PROPERTY_FROM_QSCRIPTVALUE_FLOAT(quadraticAttenuation, setQuadraticAttenuation);
+ COPY_PROPERTY_FROM_QSCRIPTVALUE_FLOAT(intensity, setIntensity);
COPY_PROPERTY_FROM_QSCRIPTVALUE_FLOAT(exponent, setExponent);
COPY_PROPERTY_FROM_QSCRIPTVALUE_FLOAT(cutoff, setCutoff);
COPY_PROPERTY_FROM_QSCRIPTVALUE_BOOL(locked, setLocked);
@@ -543,12 +523,8 @@ bool EntityItemProperties::encodeEntityEditPacket(PacketType command, EntityItem
if (properties.getType() == EntityTypes::Light) {
APPEND_ENTITY_PROPERTY(PROP_IS_SPOTLIGHT, appendValue, properties.getIsSpotlight());
- APPEND_ENTITY_PROPERTY(PROP_DIFFUSE_COLOR, appendColor, properties.getDiffuseColor());
- APPEND_ENTITY_PROPERTY(PROP_AMBIENT_COLOR, appendColor, properties.getAmbientColor());
- APPEND_ENTITY_PROPERTY(PROP_SPECULAR_COLOR, appendColor, properties.getSpecularColor());
- APPEND_ENTITY_PROPERTY(PROP_CONSTANT_ATTENUATION, appendValue, properties.getConstantAttenuation());
- APPEND_ENTITY_PROPERTY(PROP_LINEAR_ATTENUATION, appendValue, properties.getLinearAttenuation());
- APPEND_ENTITY_PROPERTY(PROP_QUADRATIC_ATTENUATION, appendValue, properties.getQuadraticAttenuation());
+ APPEND_ENTITY_PROPERTY(PROP_COLOR, appendColor, properties.getColor());
+ APPEND_ENTITY_PROPERTY(PROP_INTENSITY, appendValue, properties.getIntensity());
APPEND_ENTITY_PROPERTY(PROP_EXPONENT, appendValue, properties.getExponent());
APPEND_ENTITY_PROPERTY(PROP_CUTOFF, appendValue, properties.getCutoff());
}
@@ -765,12 +741,8 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int
if (properties.getType() == EntityTypes::Light) {
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_IS_SPOTLIGHT, bool, setIsSpotlight);
- READ_ENTITY_PROPERTY_COLOR_TO_PROPERTIES(PROP_DIFFUSE_COLOR, setDiffuseColor);
- READ_ENTITY_PROPERTY_COLOR_TO_PROPERTIES(PROP_AMBIENT_COLOR, setAmbientColor);
- READ_ENTITY_PROPERTY_COLOR_TO_PROPERTIES(PROP_SPECULAR_COLOR, setSpecularColor);
- READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_CONSTANT_ATTENUATION, float, setConstantAttenuation);
- READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_LINEAR_ATTENUATION, float, setLinearAttenuation);
- READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_QUADRATIC_ATTENUATION, float, setQuadraticAttenuation);
+ READ_ENTITY_PROPERTY_COLOR_TO_PROPERTIES(PROP_COLOR, setColor);
+ READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_INTENSITY, float, setIntensity);
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_EXPONENT, float, setExponent);
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_CUTOFF, float, setCutoff);
}
@@ -835,12 +807,7 @@ void EntityItemProperties::markAllChanged() {
_ignoreForCollisionsChanged = true;
_collisionsWillMoveChanged = true;
- _diffuseColorChanged = true;
- _ambientColorChanged = true;
- _specularColorChanged = true;
- _constantAttenuationChanged = true;
- _linearAttenuationChanged = true;
- _quadraticAttenuationChanged = true;
+ _intensityChanged = true;
_exponentChanged = true;
_cutoffChanged = true;
_lockedChanged = true;
diff --git a/libraries/entities/src/EntityItemProperties.h b/libraries/entities/src/EntityItemProperties.h
index 2391bcde84..12cc50b6ea 100644
--- a/libraries/entities/src/EntityItemProperties.h
+++ b/libraries/entities/src/EntityItemProperties.h
@@ -66,12 +66,12 @@ enum EntityPropertyList {
// property used by Light entity
PROP_IS_SPOTLIGHT,
- PROP_DIFFUSE_COLOR,
- PROP_AMBIENT_COLOR,
- PROP_SPECULAR_COLOR,
- PROP_CONSTANT_ATTENUATION,
- PROP_LINEAR_ATTENUATION,
- PROP_QUADRATIC_ATTENUATION,
+ PROP_DIFFUSE_COLOR_UNUSED,
+ PROP_AMBIENT_COLOR_UNUSED,
+ PROP_SPECULAR_COLOR_UNUSED,
+ PROP_INTENSITY, // Previously PROP_CONSTANT_ATTENUATION
+ PROP_LINEAR_ATTENUATION_UNUSED,
+ PROP_QUADRATIC_ATTENUATION_UNUSED,
PROP_EXPONENT,
PROP_CUTOFF,
@@ -165,12 +165,7 @@ public:
DEFINE_PROPERTY(PROP_IGNORE_FOR_COLLISIONS, IgnoreForCollisions, ignoreForCollisions, bool);
DEFINE_PROPERTY(PROP_COLLISIONS_WILL_MOVE, CollisionsWillMove, collisionsWillMove, bool);
DEFINE_PROPERTY(PROP_IS_SPOTLIGHT, IsSpotlight, isSpotlight, bool);
- DEFINE_PROPERTY_REF(PROP_DIFFUSE_COLOR, DiffuseColor, diffuseColor, xColor);
- DEFINE_PROPERTY_REF(PROP_AMBIENT_COLOR, AmbientColor, ambientColor, xColor);
- DEFINE_PROPERTY_REF(PROP_SPECULAR_COLOR, SpecularColor, specularColor, xColor);
- DEFINE_PROPERTY(PROP_CONSTANT_ATTENUATION, ConstantAttenuation, constantAttenuation, float);
- DEFINE_PROPERTY(PROP_LINEAR_ATTENUATION, LinearAttenuation, linearAttenuation, float);
- DEFINE_PROPERTY(PROP_QUADRATIC_ATTENUATION, QuadraticAttenuation, quadraticAttenuation, float);
+ DEFINE_PROPERTY(PROP_INTENSITY, Intensity, intensity, float);
DEFINE_PROPERTY(PROP_EXPONENT, Exponent, exponent, float);
DEFINE_PROPERTY(PROP_CUTOFF, Cutoff, cutoff, float);
DEFINE_PROPERTY(PROP_LOCKED, Locked, locked, bool);
@@ -288,12 +283,7 @@ inline QDebug operator<<(QDebug debug, const EntityItemProperties& properties) {
DEBUG_PROPERTY_IF_CHANGED(debug, properties, IgnoreForCollisions, ignoreForCollisions, "");
DEBUG_PROPERTY_IF_CHANGED(debug, properties, CollisionsWillMove, collisionsWillMove, "");
DEBUG_PROPERTY_IF_CHANGED(debug, properties, IsSpotlight, isSpotlight, "");
- DEBUG_PROPERTY_IF_CHANGED(debug, properties, DiffuseColor, diffuseColor, "");
- DEBUG_PROPERTY_IF_CHANGED(debug, properties, AmbientColor, ambientColor, "");
- DEBUG_PROPERTY_IF_CHANGED(debug, properties, SpecularColor, specularColor, "");
- DEBUG_PROPERTY_IF_CHANGED(debug, properties, ConstantAttenuation, constantAttenuation, "");
- DEBUG_PROPERTY_IF_CHANGED(debug, properties, LinearAttenuation, linearAttenuation, "");
- DEBUG_PROPERTY_IF_CHANGED(debug, properties, QuadraticAttenuation, quadraticAttenuation, "");
+ DEBUG_PROPERTY_IF_CHANGED(debug, properties, Intensity, intensity, "");
DEBUG_PROPERTY_IF_CHANGED(debug, properties, Exponent, exponent, "");
DEBUG_PROPERTY_IF_CHANGED(debug, properties, Cutoff, cutoff, "");
DEBUG_PROPERTY_IF_CHANGED(debug, properties, Locked, locked, "");
diff --git a/libraries/entities/src/LightEntityItem.cpp b/libraries/entities/src/LightEntityItem.cpp
index 4a8dc2d582..3265891b18 100644
--- a/libraries/entities/src/LightEntityItem.cpp
+++ b/libraries/entities/src/LightEntityItem.cpp
@@ -14,6 +14,7 @@
#include
+#include "EntityItemID.h"
#include "EntityTree.h"
#include "EntityTreeElement.h"
#include "LightEntityItem.h"
@@ -32,12 +33,8 @@ LightEntityItem::LightEntityItem(const EntityItemID& entityItemID, const EntityI
// default property values
const quint8 MAX_COLOR = 255;
- _ambientColor[RED_INDEX] = _ambientColor[GREEN_INDEX] = _ambientColor[BLUE_INDEX] = 0;
- _diffuseColor[RED_INDEX] = _diffuseColor[GREEN_INDEX] = _diffuseColor[BLUE_INDEX] = MAX_COLOR;
- _specularColor[RED_INDEX] = _specularColor[GREEN_INDEX] = _specularColor[BLUE_INDEX] = MAX_COLOR;
- _constantAttenuation = 1.0f;
- _linearAttenuation = 0.0f;
- _quadraticAttenuation = 0.0f;
+ _color[RED_INDEX] = _color[GREEN_INDEX] = _color[BLUE_INDEX] = 0;
+ _intensity = 1.0f;
_exponent = 0.0f;
_cutoff = PI;
@@ -54,12 +51,8 @@ EntityItemProperties LightEntityItem::getProperties() const {
EntityItemProperties properties = EntityItem::getProperties(); // get the properties from our base class
COPY_ENTITY_PROPERTY_TO_PROPERTIES(isSpotlight, getIsSpotlight);
- COPY_ENTITY_PROPERTY_TO_PROPERTIES(diffuseColor, getDiffuseXColor);
- COPY_ENTITY_PROPERTY_TO_PROPERTIES(ambientColor, getAmbientXColor);
- COPY_ENTITY_PROPERTY_TO_PROPERTIES(specularColor, getSpecularXColor);
- COPY_ENTITY_PROPERTY_TO_PROPERTIES(constantAttenuation, getConstantAttenuation);
- COPY_ENTITY_PROPERTY_TO_PROPERTIES(linearAttenuation, getLinearAttenuation);
- COPY_ENTITY_PROPERTY_TO_PROPERTIES(quadraticAttenuation, getQuadraticAttenuation);
+ COPY_ENTITY_PROPERTY_TO_PROPERTIES(color, getXColor);
+ COPY_ENTITY_PROPERTY_TO_PROPERTIES(intensity, getIntensity);
COPY_ENTITY_PROPERTY_TO_PROPERTIES(exponent, getExponent);
COPY_ENTITY_PROPERTY_TO_PROPERTIES(cutoff, getCutoff);
@@ -70,17 +63,11 @@ bool LightEntityItem::setProperties(const EntityItemProperties& properties) {
bool somethingChanged = EntityItem::setProperties(properties); // set the properties in our base class
SET_ENTITY_PROPERTY_FROM_PROPERTIES(isSpotlight, setIsSpotlight);
- SET_ENTITY_PROPERTY_FROM_PROPERTIES(diffuseColor, setDiffuseColor);
- SET_ENTITY_PROPERTY_FROM_PROPERTIES(ambientColor, setAmbientColor);
- SET_ENTITY_PROPERTY_FROM_PROPERTIES(specularColor, setSpecularColor);
- SET_ENTITY_PROPERTY_FROM_PROPERTIES(isSpotlight, setIsSpotlight);
- SET_ENTITY_PROPERTY_FROM_PROPERTIES(constantAttenuation, setConstantAttenuation);
- SET_ENTITY_PROPERTY_FROM_PROPERTIES(linearAttenuation, setLinearAttenuation);
- SET_ENTITY_PROPERTY_FROM_PROPERTIES(quadraticAttenuation, setQuadraticAttenuation);
+ SET_ENTITY_PROPERTY_FROM_PROPERTIES(color, setColor);
+ SET_ENTITY_PROPERTY_FROM_PROPERTIES(intensity, setIntensity);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(exponent, setExponent);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(cutoff, setCutoff);
-
if (somethingChanged) {
bool wantDebug = false;
if (wantDebug) {
@@ -101,15 +88,37 @@ int LightEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data,
int bytesRead = 0;
const unsigned char* dataAt = data;
- READ_ENTITY_PROPERTY(PROP_IS_SPOTLIGHT, bool, _isSpotlight);
- READ_ENTITY_PROPERTY_COLOR(PROP_DIFFUSE_COLOR, _diffuseColor);
- READ_ENTITY_PROPERTY_COLOR(PROP_AMBIENT_COLOR, _ambientColor);
- READ_ENTITY_PROPERTY_COLOR(PROP_SPECULAR_COLOR, _specularColor);
- READ_ENTITY_PROPERTY(PROP_CONSTANT_ATTENUATION, float, _constantAttenuation);
- READ_ENTITY_PROPERTY(PROP_LINEAR_ATTENUATION, float, _linearAttenuation);
- READ_ENTITY_PROPERTY(PROP_QUADRATIC_ATTENUATION, float, _quadraticAttenuation);
- READ_ENTITY_PROPERTY(PROP_EXPONENT, float, _exponent);
- READ_ENTITY_PROPERTY(PROP_CUTOFF, float, _cutoff);
+ if (args.bitstreamVersion < VERSION_ENTITIES_LIGHT_HAS_INTENSITY_AND_COLOR_PROPERTIES) {
+ rgbColor ignoredColor;
+ float ignoredAttenuation;
+
+ READ_ENTITY_PROPERTY(PROP_IS_SPOTLIGHT, bool, _isSpotlight);
+
+ // _diffuseColor has been renamed to _color
+ READ_ENTITY_PROPERTY_COLOR(PROP_DIFFUSE_COLOR_UNUSED, _color);
+
+ // Ambient and specular color are from an older format and are no longer supported.
+ // Their values will be ignored.
+ READ_ENTITY_PROPERTY_COLOR(PROP_AMBIENT_COLOR_UNUSED, ignoredColor);
+ READ_ENTITY_PROPERTY_COLOR(PROP_SPECULAR_COLOR_UNUSED, ignoredColor);
+
+ // _constantAttenuation has been renamed to _intensity
+ READ_ENTITY_PROPERTY(PROP_INTENSITY, float, _intensity);
+
+ // Linear and quadratic attenuation are from an older format and are no longer supported.
+ // Their values will be ignored.
+ READ_ENTITY_PROPERTY(PROP_LINEAR_ATTENUATION_UNUSED, float, ignoredAttenuation);
+ READ_ENTITY_PROPERTY(PROP_QUADRATIC_ATTENUATION_UNUSED, float, ignoredAttenuation);
+
+ READ_ENTITY_PROPERTY(PROP_EXPONENT, float, _exponent);
+ READ_ENTITY_PROPERTY(PROP_CUTOFF, float, _cutoff);
+ } else {
+ READ_ENTITY_PROPERTY(PROP_IS_SPOTLIGHT, bool, _isSpotlight);
+ READ_ENTITY_PROPERTY_COLOR(PROP_COLOR, _color);
+ READ_ENTITY_PROPERTY(PROP_INTENSITY, float, _intensity);
+ READ_ENTITY_PROPERTY(PROP_EXPONENT, float, _exponent);
+ READ_ENTITY_PROPERTY(PROP_CUTOFF, float, _cutoff);
+ }
return bytesRead;
}
@@ -119,12 +128,8 @@ int LightEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data,
EntityPropertyFlags LightEntityItem::getEntityProperties(EncodeBitstreamParams& params) const {
EntityPropertyFlags requestedProperties = EntityItem::getEntityProperties(params);
requestedProperties += PROP_IS_SPOTLIGHT;
- requestedProperties += PROP_DIFFUSE_COLOR;
- requestedProperties += PROP_AMBIENT_COLOR;
- requestedProperties += PROP_SPECULAR_COLOR;
- requestedProperties += PROP_CONSTANT_ATTENUATION;
- requestedProperties += PROP_LINEAR_ATTENUATION;
- requestedProperties += PROP_QUADRATIC_ATTENUATION;
+ requestedProperties += PROP_COLOR;
+ requestedProperties += PROP_INTENSITY;
requestedProperties += PROP_EXPONENT;
requestedProperties += PROP_CUTOFF;
return requestedProperties;
@@ -140,12 +145,8 @@ void LightEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBit
bool successPropertyFits = true;
APPEND_ENTITY_PROPERTY(PROP_IS_SPOTLIGHT, appendValue, getIsSpotlight());
- APPEND_ENTITY_PROPERTY(PROP_DIFFUSE_COLOR, appendColor, getDiffuseColor());
- APPEND_ENTITY_PROPERTY(PROP_AMBIENT_COLOR, appendColor, getAmbientColor());
- APPEND_ENTITY_PROPERTY(PROP_SPECULAR_COLOR, appendColor, getSpecularColor());
- APPEND_ENTITY_PROPERTY(PROP_CONSTANT_ATTENUATION, appendValue, getConstantAttenuation());
- APPEND_ENTITY_PROPERTY(PROP_LINEAR_ATTENUATION, appendValue, getLinearAttenuation());
- APPEND_ENTITY_PROPERTY(PROP_QUADRATIC_ATTENUATION, appendValue, getQuadraticAttenuation());
+ APPEND_ENTITY_PROPERTY(PROP_COLOR, appendColor, getColor());
+ APPEND_ENTITY_PROPERTY(PROP_INTENSITY, appendValue, getIntensity());
APPEND_ENTITY_PROPERTY(PROP_EXPONENT, appendValue, getExponent());
APPEND_ENTITY_PROPERTY(PROP_CUTOFF, appendValue, getCutoff());
}
diff --git a/libraries/entities/src/LightEntityItem.h b/libraries/entities/src/LightEntityItem.h
index 5e39ba26a2..cdbdb59ece 100644
--- a/libraries/entities/src/LightEntityItem.h
+++ b/libraries/entities/src/LightEntityItem.h
@@ -43,53 +43,23 @@ public:
ReadBitstreamToTreeParams& args,
EntityPropertyFlags& propertyFlags, bool overwriteLocalData);
- const rgbColor& getAmbientColor() const { return _ambientColor; }
- xColor getAmbientXColor() const {
- xColor color = { _ambientColor[RED_INDEX], _ambientColor[GREEN_INDEX], _ambientColor[BLUE_INDEX] }; return color;
+ const rgbColor& getColor() const { return _color; }
+ xColor getXColor() const {
+ xColor color = { _color[RED_INDEX], _color[GREEN_INDEX], _color[BLUE_INDEX] }; return color;
}
- void setAmbientColor(const rgbColor& value) { memcpy(_ambientColor, value, sizeof(_ambientColor)); }
- void setAmbientColor(const xColor& value) {
- _ambientColor[RED_INDEX] = value.red;
- _ambientColor[GREEN_INDEX] = value.green;
- _ambientColor[BLUE_INDEX] = value.blue;
- }
-
- const rgbColor& getDiffuseColor() const { return _diffuseColor; }
- xColor getDiffuseXColor() const {
- xColor color = { _diffuseColor[RED_INDEX], _diffuseColor[GREEN_INDEX], _diffuseColor[BLUE_INDEX] }; return color;
- }
-
- void setDiffuseColor(const rgbColor& value) { memcpy(_diffuseColor, value, sizeof(_diffuseColor)); }
- void setDiffuseColor(const xColor& value) {
- _diffuseColor[RED_INDEX] = value.red;
- _diffuseColor[GREEN_INDEX] = value.green;
- _diffuseColor[BLUE_INDEX] = value.blue;
- }
-
- const rgbColor& getSpecularColor() const { return _specularColor; }
- xColor getSpecularXColor() const {
- xColor color = { _specularColor[RED_INDEX], _specularColor[GREEN_INDEX], _specularColor[BLUE_INDEX] }; return color;
- }
-
- void setSpecularColor(const rgbColor& value) { memcpy(_specularColor, value, sizeof(_specularColor)); }
- void setSpecularColor(const xColor& value) {
- _specularColor[RED_INDEX] = value.red;
- _specularColor[GREEN_INDEX] = value.green;
- _specularColor[BLUE_INDEX] = value.blue;
+ void setColor(const rgbColor& value) { memcpy(_color, value, sizeof(_color)); }
+ void setColor(const xColor& value) {
+ _color[RED_INDEX] = value.red;
+ _color[GREEN_INDEX] = value.green;
+ _color[BLUE_INDEX] = value.blue;
}
bool getIsSpotlight() const { return _isSpotlight; }
void setIsSpotlight(bool value) { _isSpotlight = value; }
- float getConstantAttenuation() const { return _constantAttenuation; }
- void setConstantAttenuation(float value) { _constantAttenuation = value; }
-
- float getLinearAttenuation() const { return _linearAttenuation; }
- void setLinearAttenuation(float value) { _linearAttenuation = value; }
-
- float getQuadraticAttenuation() const { return _quadraticAttenuation; }
- void setQuadraticAttenuation(float value) { _quadraticAttenuation = value; }
+ float getIntensity() const { return _intensity; }
+ void setIntensity(float value) { _intensity = value; }
float getExponent() const { return _exponent; }
void setExponent(float value) { _exponent = value; }
@@ -103,13 +73,9 @@ public:
protected:
// properties of a light
- rgbColor _ambientColor;
- rgbColor _diffuseColor;
- rgbColor _specularColor;
+ rgbColor _color;
bool _isSpotlight;
- float _constantAttenuation;
- float _linearAttenuation;
- float _quadraticAttenuation;
+ float _intensity;
float _exponent;
float _cutoff;
diff --git a/libraries/networking/src/PacketHeaders.cpp b/libraries/networking/src/PacketHeaders.cpp
index db97e216ee..c8f6b6e25c 100644
--- a/libraries/networking/src/PacketHeaders.cpp
+++ b/libraries/networking/src/PacketHeaders.cpp
@@ -74,7 +74,7 @@ PacketVersion versionForPacketType(PacketType type) {
return 1;
case PacketTypeEntityAddOrEdit:
case PacketTypeEntityData:
- return VERSION_MODEL_ENTITIES_SUPPORT_SHAPE_TYPE;
+ return VERSION_ENTITIES_LIGHT_HAS_INTENSITY_AND_COLOR_PROPERTIES;
case PacketTypeEntityErase:
return 2;
case PacketTypeAudioStreamStats:
diff --git a/libraries/networking/src/PacketHeaders.h b/libraries/networking/src/PacketHeaders.h
index 32f33c01d9..44a464201b 100644
--- a/libraries/networking/src/PacketHeaders.h
+++ b/libraries/networking/src/PacketHeaders.h
@@ -128,6 +128,7 @@ const PacketVersion VERSION_ENTITIES_MODELS_HAVE_ANIMATION_SETTINGS = 5;
const PacketVersion VERSION_ENTITIES_HAVE_USER_DATA = 6;
const PacketVersion VERSION_ENTITIES_HAS_LAST_SIMULATED_TIME = 7;
const PacketVersion VERSION_MODEL_ENTITIES_SUPPORT_SHAPE_TYPE = 8;
+const PacketVersion VERSION_ENTITIES_LIGHT_HAS_INTENSITY_AND_COLOR_PROPERTIES = 9;
const PacketVersion VERSION_OCTREE_HAS_FILE_BREAKS = 1;
#endif // hifi_PacketHeaders_h