mirror of
https://github.com/lubosz/overte.git
synced 2025-04-27 13:55:26 +02:00
Merge pull request #3702 from ZappoMan/lockAndMaterialProperties
Lock and textures properties
This commit is contained in:
commit
4cf77d1c6c
10 changed files with 125 additions and 248 deletions
examples
interface/src/entities
libraries/entities/src
|
@ -25,6 +25,9 @@
|
|||
Script.include("libraries/globals.js");
|
||||
Script.include("libraries/toolBars.js");
|
||||
|
||||
Script.include("libraries/entityPropertyDialogBox.js");
|
||||
var entityPropertyDialogBox = EntityPropertyDialogBox;
|
||||
|
||||
var windowDimensions = Controller.getViewportDimensions();
|
||||
var toolIconUrl = HIFI_PUBLIC_BUCKET + "images/tools/";
|
||||
var toolHeight = 50;
|
||||
|
@ -2845,126 +2848,8 @@ var dimensionY;
|
|||
var dimensionZ;
|
||||
var rescalePercentage;
|
||||
|
||||
function showPropertiesForm() {
|
||||
propertiesForEditedEntity = Entities.getEntityProperties(editModelID);
|
||||
var properties = propertiesForEditedEntity;
|
||||
|
||||
var array = new Array();
|
||||
var index = 0;
|
||||
var decimals = 3;
|
||||
if (properties.type == "Model") {
|
||||
array.push({ label: "Model URL:", value: properties.modelURL });
|
||||
index++;
|
||||
array.push({ label: "Animation URL:", value: properties.animationURL });
|
||||
index++;
|
||||
array.push({ label: "Animation is playing:", value: properties.animationIsPlaying });
|
||||
index++;
|
||||
array.push({ label: "Animation FPS:", value: properties.animationFPS });
|
||||
index++;
|
||||
array.push({ label: "Animation Frame:", value: properties.animationFrameIndex });
|
||||
index++;
|
||||
}
|
||||
array.push({ label: "Position:", type: "header" });
|
||||
index++;
|
||||
array.push({ label: "X:", value: properties.position.x.toFixed(decimals) });
|
||||
index++;
|
||||
array.push({ label: "Y:", value: properties.position.y.toFixed(decimals) });
|
||||
index++;
|
||||
array.push({ label: "Z:", value: properties.position.z.toFixed(decimals) });
|
||||
index++;
|
||||
|
||||
array.push({ label: "Registration X:", value: properties.registrationPoint.x.toFixed(decimals) });
|
||||
index++;
|
||||
array.push({ label: "Registration Y:", value: properties.registrationPoint.y.toFixed(decimals) });
|
||||
index++;
|
||||
array.push({ label: "Registration Z:", value: properties.registrationPoint.z.toFixed(decimals) });
|
||||
index++;
|
||||
|
||||
array.push({ label: "Rotation:", type: "header" });
|
||||
index++;
|
||||
var angles = Quat.safeEulerAngles(properties.rotation);
|
||||
array.push({ label: "Pitch:", value: angles.x.toFixed(decimals) });
|
||||
index++;
|
||||
array.push({ label: "Yaw:", value: angles.y.toFixed(decimals) });
|
||||
index++;
|
||||
array.push({ label: "Roll:", value: angles.z.toFixed(decimals) });
|
||||
index++;
|
||||
|
||||
array.push({ label: "Dimensions:", type: "header" });
|
||||
index++;
|
||||
array.push({ label: "Width:", value: properties.dimensions.x.toFixed(decimals) });
|
||||
dimensionX = index;
|
||||
index++;
|
||||
array.push({ label: "Height:", value: properties.dimensions.y.toFixed(decimals) });
|
||||
dimensionY = index;
|
||||
index++;
|
||||
array.push({ label: "Depth:", value: properties.dimensions.z.toFixed(decimals) });
|
||||
dimensionZ = index;
|
||||
index++;
|
||||
array.push({ label: "", type: "inlineButton", buttonLabel: "Reset to Natural Dimensions", name: "resetDimensions" });
|
||||
index++;
|
||||
array.push({ label: "Rescale Percentage:", value: 100 });
|
||||
rescalePercentage = index;
|
||||
index++;
|
||||
array.push({ label: "", type: "inlineButton", buttonLabel: "Rescale", name: "rescaleDimensions" });
|
||||
index++;
|
||||
|
||||
array.push({ label: "Velocity:", type: "header" });
|
||||
index++;
|
||||
array.push({ label: "Linear X:", value: properties.velocity.x.toFixed(decimals) });
|
||||
index++;
|
||||
array.push({ label: "Linear Y:", value: properties.velocity.y.toFixed(decimals) });
|
||||
index++;
|
||||
array.push({ label: "Linear Z:", value: properties.velocity.z.toFixed(decimals) });
|
||||
index++;
|
||||
array.push({ label: "Linear Damping:", value: properties.damping.toFixed(decimals) });
|
||||
index++;
|
||||
array.push({ label: "Angular Pitch:", value: properties.angularVelocity.x.toFixed(decimals) });
|
||||
index++;
|
||||
array.push({ label: "Angular Yaw:", value: properties.angularVelocity.y.toFixed(decimals) });
|
||||
index++;
|
||||
array.push({ label: "Angular Roll:", value: properties.angularVelocity.z.toFixed(decimals) });
|
||||
index++;
|
||||
array.push({ label: "Angular Damping:", value: properties.angularDamping.toFixed(decimals) });
|
||||
index++;
|
||||
|
||||
array.push({ label: "Gravity X:", value: properties.gravity.x.toFixed(decimals) });
|
||||
index++;
|
||||
array.push({ label: "Gravity Y:", value: properties.gravity.y.toFixed(decimals) });
|
||||
index++;
|
||||
array.push({ label: "Gravity Z:", value: properties.gravity.z.toFixed(decimals) });
|
||||
index++;
|
||||
|
||||
array.push({ label: "Collisions:", type: "header" });
|
||||
index++;
|
||||
array.push({ label: "Mass:", value: properties.mass.toFixed(decimals) });
|
||||
index++;
|
||||
array.push({ label: "Ignore for Collisions:", value: properties.ignoreForCollisions });
|
||||
index++;
|
||||
array.push({ label: "Collisions Will Move:", value: properties.collisionsWillMove });
|
||||
index++;
|
||||
|
||||
array.push({ label: "Lifetime:", value: properties.lifetime.toFixed(decimals) });
|
||||
index++;
|
||||
|
||||
array.push({ label: "Visible:", value: properties.visible });
|
||||
index++;
|
||||
|
||||
if (properties.type == "Box" || properties.type == "Sphere") {
|
||||
array.push({ label: "Color:", type: "header" });
|
||||
index++;
|
||||
array.push({ label: "Red:", value: properties.color.red });
|
||||
index++;
|
||||
array.push({ label: "Green:", value: properties.color.green });
|
||||
index++;
|
||||
array.push({ label: "Blue:", value: properties.color.blue });
|
||||
index++;
|
||||
}
|
||||
array.push({ button: "Cancel" });
|
||||
index++;
|
||||
|
||||
editEntityFormArray = array;
|
||||
Window.nonBlockingForm("Edit Properties", array);
|
||||
function showPropertiesForm(editModelID) {
|
||||
entityPropertyDialogBox.openDialog(editModelID);
|
||||
}
|
||||
|
||||
function handeMenuEvent(menuItem) {
|
||||
|
@ -3018,7 +2903,7 @@ function handeMenuEvent(menuItem) {
|
|||
var selectedModel = form[0].value;
|
||||
if (form[1].value == "Properties") {
|
||||
editModelID = selectedModel;
|
||||
showPropertiesForm();
|
||||
showPropertiesForm(editModelID);
|
||||
} else if (form[1].value == "Delete") {
|
||||
Entities.deleteEntity(selectedModel);
|
||||
} else if (form[1].value == "Teleport") {
|
||||
|
@ -3103,104 +2988,3 @@ Controller.keyReleaseEvent.connect(function (event) {
|
|||
}
|
||||
});
|
||||
|
||||
Window.inlineButtonClicked.connect(function (name) {
|
||||
if (name == "resetDimensions") {
|
||||
var decimals = 3;
|
||||
Window.reloadNonBlockingForm([
|
||||
{ value: propertiesForEditedEntity.naturalDimensions.x.toFixed(decimals), oldIndex: dimensionX },
|
||||
{ value: propertiesForEditedEntity.naturalDimensions.y.toFixed(decimals), oldIndex: dimensionY },
|
||||
{ value: propertiesForEditedEntity.naturalDimensions.z.toFixed(decimals), oldIndex: dimensionZ }
|
||||
]);
|
||||
}
|
||||
|
||||
if (name == "rescaleDimensions") {
|
||||
var decimals = 3;
|
||||
var peekValues = editEntityFormArray;
|
||||
Window.peekNonBlockingFormResult(peekValues);
|
||||
var peekX = peekValues[dimensionX].value;
|
||||
var peekY = peekValues[dimensionY].value;
|
||||
var peekZ = peekValues[dimensionZ].value;
|
||||
var peekRescale = peekValues[rescalePercentage].value;
|
||||
var rescaledX = peekX * peekRescale / 100.0;
|
||||
var rescaledY = peekY * peekRescale / 100.0;
|
||||
var rescaledZ = peekZ * peekRescale / 100.0;
|
||||
|
||||
Window.reloadNonBlockingForm([
|
||||
{ value: rescaledX.toFixed(decimals), oldIndex: dimensionX },
|
||||
{ value: rescaledY.toFixed(decimals), oldIndex: dimensionY },
|
||||
{ value: rescaledZ.toFixed(decimals), oldIndex: dimensionZ },
|
||||
{ value: 100, oldIndex: rescalePercentage }
|
||||
]);
|
||||
}
|
||||
|
||||
});
|
||||
Window.nonBlockingFormClosed.connect(function() {
|
||||
array = editEntityFormArray;
|
||||
if (Window.getNonBlockingFormResult(array)) {
|
||||
var properties = propertiesForEditedEntity;
|
||||
var index = 0;
|
||||
if (properties.type == "Model") {
|
||||
properties.modelURL = array[index++].value;
|
||||
properties.animationURL = array[index++].value;
|
||||
properties.animationIsPlaying = array[index++].value;
|
||||
properties.animationFPS = array[index++].value;
|
||||
properties.animationFrameIndex = array[index++].value;
|
||||
}
|
||||
index++; // skip header
|
||||
properties.position.x = array[index++].value;
|
||||
properties.position.y = array[index++].value;
|
||||
properties.position.z = array[index++].value;
|
||||
properties.registrationPoint.x = array[index++].value;
|
||||
properties.registrationPoint.y = array[index++].value;
|
||||
properties.registrationPoint.z = array[index++].value;
|
||||
|
||||
index++; // skip header
|
||||
var angles = Quat.safeEulerAngles(properties.rotation);
|
||||
angles.x = array[index++].value;
|
||||
angles.y = array[index++].value;
|
||||
angles.z = array[index++].value;
|
||||
properties.rotation = Quat.fromVec3Degrees(angles);
|
||||
|
||||
index++; // skip header
|
||||
properties.dimensions.x = array[index++].value;
|
||||
properties.dimensions.y = array[index++].value;
|
||||
properties.dimensions.z = array[index++].value;
|
||||
index++; // skip reset button
|
||||
index++; // skip rescale percentage
|
||||
index++; // skip rescale button
|
||||
|
||||
index++; // skip header
|
||||
properties.velocity.x = array[index++].value;
|
||||
properties.velocity.y = array[index++].value;
|
||||
properties.velocity.z = array[index++].value;
|
||||
properties.damping = array[index++].value;
|
||||
|
||||
properties.angularVelocity.x = array[index++].value;
|
||||
properties.angularVelocity.y = array[index++].value;
|
||||
properties.angularVelocity.z = array[index++].value;
|
||||
properties.angularDamping = array[index++].value;
|
||||
|
||||
properties.gravity.x = array[index++].value;
|
||||
properties.gravity.y = array[index++].value;
|
||||
properties.gravity.z = array[index++].value;
|
||||
|
||||
index++; // skip header
|
||||
properties.mass = array[index++].value;
|
||||
properties.ignoreForCollisions = array[index++].value;
|
||||
properties.collisionsWillMove = array[index++].value;
|
||||
|
||||
properties.lifetime = array[index++].value;
|
||||
properties.visible = array[index++].value;
|
||||
|
||||
if (properties.type == "Box" || properties.type == "Sphere") {
|
||||
index++; // skip header
|
||||
properties.color.red = array[index++].value;
|
||||
properties.color.green = array[index++].value;
|
||||
properties.color.blue = array[index++].value;
|
||||
}
|
||||
Entities.editEntity(editModelID, properties);
|
||||
}
|
||||
modelSelected = false;
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -35,6 +35,12 @@ EntityPropertyDialogBox = (function () {
|
|||
|
||||
var array = new Array();
|
||||
var index = 0;
|
||||
|
||||
array.push({ label: "Entity Type:" + properties.type, type: "header" });
|
||||
index++;
|
||||
array.push({ label: "Locked:", value: properties.locked });
|
||||
index++;
|
||||
|
||||
if (properties.type == "Model") {
|
||||
array.push({ label: "Model URL:", value: properties.modelURL });
|
||||
index++;
|
||||
|
@ -46,6 +52,8 @@ EntityPropertyDialogBox = (function () {
|
|||
index++;
|
||||
array.push({ label: "Animation Frame:", value: properties.animationFrameIndex });
|
||||
index++;
|
||||
array.push({ label: "Textures:", value: properties.textures });
|
||||
index++;
|
||||
}
|
||||
array.push({ label: "Position:", type: "header" });
|
||||
index++;
|
||||
|
@ -219,12 +227,15 @@ EntityPropertyDialogBox = (function () {
|
|||
if (Window.getNonBlockingFormResult(array)) {
|
||||
var properties = propertiesForEditedEntity;
|
||||
var index = 0;
|
||||
index++; // skip type header
|
||||
properties.locked = array[index++].value;
|
||||
if (properties.type == "Model") {
|
||||
properties.modelURL = array[index++].value;
|
||||
properties.animationURL = array[index++].value;
|
||||
properties.animationIsPlaying = array[index++].value;
|
||||
properties.animationFPS = array[index++].value;
|
||||
properties.animationFrameIndex = array[index++].value;
|
||||
properties.textures = array[index++].value;
|
||||
}
|
||||
index++; // skip header
|
||||
properties.position.x = array[index++].value;
|
||||
|
@ -298,7 +309,9 @@ EntityPropertyDialogBox = (function () {
|
|||
}
|
||||
|
||||
Entities.editEntity(editModelID, properties);
|
||||
selectionDisplay.select(editModelID, false);
|
||||
if (typeof(selectionDisplay) != "undefined") {
|
||||
selectionDisplay.select(editModelID, false);
|
||||
}
|
||||
}
|
||||
modelSelected = false;
|
||||
});
|
||||
|
|
|
@ -38,9 +38,12 @@ RenderableModelEntityItem::~RenderableModelEntityItem() {
|
|||
|
||||
bool RenderableModelEntityItem::setProperties(const EntityItemProperties& properties, bool forceCopy) {
|
||||
QString oldModelURL = getModelURL();
|
||||
QString oldTextures = getTextures();
|
||||
bool somethingChanged = ModelEntityItem::setProperties(properties, forceCopy);
|
||||
if (somethingChanged && oldModelURL != getModelURL()) {
|
||||
_needsModelReload = true;
|
||||
if (somethingChanged) {
|
||||
if ((oldModelURL != getModelURL()) || (oldTextures != getTextures())) {
|
||||
_needsModelReload = true;
|
||||
}
|
||||
}
|
||||
return somethingChanged;
|
||||
}
|
||||
|
@ -180,6 +183,18 @@ Model* RenderableModelEntityItem::getModel(EntityTreeRenderer* renderer) {
|
|||
}
|
||||
}
|
||||
|
||||
// here's where we remap any textures if needed...
|
||||
if (!_textures.isEmpty() && _model) {
|
||||
QJsonDocument texturesAsJson = QJsonDocument::fromJson(_textures.toUtf8());
|
||||
QJsonObject texturesAsJsonObject = texturesAsJson.object();
|
||||
QVariantMap textureMap = texturesAsJsonObject.toVariantMap();
|
||||
foreach(const QString& key, textureMap.keys()) {
|
||||
QUrl newTextureURL = textureMap[key].toUrl();
|
||||
qDebug() << "Updating texture named" << key << "to texture at URL" << newTextureURL;
|
||||
_model->setTextureWithNameToURL(key, newTextureURL);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ const float EntityItem::DEFAULT_ANGULAR_DAMPING = 0.5f;
|
|||
const bool EntityItem::DEFAULT_VISIBLE = true;
|
||||
const bool EntityItem::DEFAULT_IGNORE_FOR_COLLISIONS = false;
|
||||
const bool EntityItem::DEFAULT_COLLISIONS_WILL_MOVE = false;
|
||||
const bool EntityItem::DEFAULT_LOCKED = false;
|
||||
|
||||
void EntityItem::initFromEntityItemID(const EntityItemID& entityItemID) {
|
||||
_id = entityItemID.id;
|
||||
|
@ -118,6 +119,7 @@ EntityPropertyFlags EntityItem::getEntityProperties(EncodeBitstreamParams& param
|
|||
requestedProperties += PROP_VISIBLE;
|
||||
requestedProperties += PROP_IGNORE_FOR_COLLISIONS;
|
||||
requestedProperties += PROP_COLLISIONS_WILL_MOVE;
|
||||
requestedProperties += PROP_LOCKED;
|
||||
|
||||
return requestedProperties;
|
||||
}
|
||||
|
@ -233,6 +235,7 @@ OctreeElement::AppendState EntityItem::appendEntityData(OctreePacketData* packet
|
|||
APPEND_ENTITY_PROPERTY(PROP_VISIBLE, appendValue, getVisible());
|
||||
APPEND_ENTITY_PROPERTY(PROP_IGNORE_FOR_COLLISIONS, appendValue, getIgnoreForCollisions());
|
||||
APPEND_ENTITY_PROPERTY(PROP_COLLISIONS_WILL_MOVE, appendValue, getCollisionsWillMove());
|
||||
APPEND_ENTITY_PROPERTY(PROP_LOCKED, appendValue, getLocked());
|
||||
|
||||
appendSubclassData(packetData, params, entityTreeElementExtraEncodeData,
|
||||
requestedProperties,
|
||||
|
@ -495,6 +498,7 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
|
|||
READ_ENTITY_PROPERTY(PROP_VISIBLE, bool, _visible);
|
||||
READ_ENTITY_PROPERTY(PROP_IGNORE_FOR_COLLISIONS, bool, _ignoreForCollisions);
|
||||
READ_ENTITY_PROPERTY(PROP_COLLISIONS_WILL_MOVE, bool, _collisionsWillMove);
|
||||
READ_ENTITY_PROPERTY(PROP_LOCKED, bool, _locked);
|
||||
|
||||
if (wantDebug) {
|
||||
qDebug() << " readEntityDataFromBuffer() _registrationPoint:" << _registrationPoint;
|
||||
|
@ -750,6 +754,7 @@ EntityItemProperties EntityItem::getProperties() const {
|
|||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(visible, getVisible);
|
||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(ignoreForCollisions, getIgnoreForCollisions);
|
||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(collisionsWillMove, getCollisionsWillMove);
|
||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(locked, getLocked);
|
||||
|
||||
properties._defaultSettings = false;
|
||||
|
||||
|
@ -785,6 +790,7 @@ bool EntityItem::setProperties(const EntityItemProperties& properties, bool forc
|
|||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(visible, setVisible);
|
||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(ignoreForCollisions, setIgnoreForCollisions);
|
||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(collisionsWillMove, setCollisionsWillMove);
|
||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(locked, setLocked);
|
||||
|
||||
if (somethingChanged) {
|
||||
somethingChangedNotification(); // notify derived classes that something has changed
|
||||
|
|
|
@ -243,6 +243,10 @@ public:
|
|||
static const bool DEFAULT_COLLISIONS_WILL_MOVE;
|
||||
bool getCollisionsWillMove() const { return _collisionsWillMove; }
|
||||
void setCollisionsWillMove(bool value) { _collisionsWillMove = value; }
|
||||
|
||||
static const bool DEFAULT_LOCKED;
|
||||
bool getLocked() const { return _locked; }
|
||||
void setLocked(bool value) { _locked = value; }
|
||||
|
||||
// TODO: We need to get rid of these users of getRadius()...
|
||||
float getRadius() const;
|
||||
|
@ -281,6 +285,7 @@ protected:
|
|||
bool _visible;
|
||||
bool _ignoreForCollisions;
|
||||
bool _collisionsWillMove;
|
||||
bool _locked;
|
||||
|
||||
// NOTE: Radius support is obsolete, but these private helper functions are available for this class to
|
||||
// parse old data streams
|
||||
|
|
|
@ -88,6 +88,8 @@ EntityItemProperties::EntityItemProperties() :
|
|||
_quadraticAttenuation(0.0f),
|
||||
_exponent(0.0f),
|
||||
_cutoff(PI),
|
||||
_locked(false),
|
||||
_textures(""),
|
||||
|
||||
_diffuseColorChanged(false),
|
||||
_ambientColorChanged(false),
|
||||
|
@ -97,6 +99,8 @@ EntityItemProperties::EntityItemProperties() :
|
|||
_quadraticAttenuationChanged(false),
|
||||
_exponentChanged(false),
|
||||
_cutoffChanged(false),
|
||||
_lockedChanged(false),
|
||||
_texturesChanged(false),
|
||||
|
||||
_defaultSettings(true),
|
||||
_naturalDimensions(1.0f, 1.0f, 1.0f)
|
||||
|
@ -160,6 +164,8 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const {
|
|||
CHECK_PROPERTY_CHANGE(PROP_QUADRATIC_ATTENUATION, quadraticAttenuation);
|
||||
CHECK_PROPERTY_CHANGE(PROP_EXPONENT, exponent);
|
||||
CHECK_PROPERTY_CHANGE(PROP_CUTOFF, cutoff);
|
||||
CHECK_PROPERTY_CHANGE(PROP_LOCKED, locked);
|
||||
CHECK_PROPERTY_CHANGE(PROP_TEXTURES, textures);
|
||||
|
||||
return changedProperties;
|
||||
}
|
||||
|
@ -210,6 +216,8 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine) cons
|
|||
COPY_PROPERTY_TO_QSCRIPTVALUE(quadraticAttenuation);
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE(exponent);
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE(cutoff);
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE(locked);
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE(textures);
|
||||
|
||||
// Sitting properties support
|
||||
QScriptValue sittingPoints = engine->newObject();
|
||||
|
@ -278,6 +286,8 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object) {
|
|||
COPY_PROPERTY_FROM_QSCRIPTVALUE_FLOAT(quadraticAttenuation, setQuadraticAttenuation);
|
||||
COPY_PROPERTY_FROM_QSCRIPTVALUE_FLOAT(exponent, setExponent);
|
||||
COPY_PROPERTY_FROM_QSCRIPTVALUE_FLOAT(cutoff, setCutoff);
|
||||
COPY_PROPERTY_FROM_QSCRIPTVALUE_BOOL(locked, setLocked);
|
||||
COPY_PROPERTY_FROM_QSCRIPTVALUE_STRING(textures, setTextures);
|
||||
|
||||
_lastEdited = usecTimestampNow();
|
||||
}
|
||||
|
@ -437,6 +447,8 @@ bool EntityItemProperties::encodeEntityEditPacket(PacketType command, EntityItem
|
|||
APPEND_ENTITY_PROPERTY(PROP_QUADRATIC_ATTENUATION, appendValue, properties.getQuadraticAttenuation());
|
||||
APPEND_ENTITY_PROPERTY(PROP_EXPONENT, appendValue, properties.getExponent());
|
||||
APPEND_ENTITY_PROPERTY(PROP_CUTOFF, appendValue, properties.getCutoff());
|
||||
APPEND_ENTITY_PROPERTY(PROP_LOCKED, appendValue, properties.getLocked());
|
||||
APPEND_ENTITY_PROPERTY(PROP_TEXTURES, appendValue, properties.getTextures());
|
||||
}
|
||||
if (propertyCount > 0) {
|
||||
int endOfEntityItemData = packetData->getUncompressedByteOffset();
|
||||
|
@ -644,6 +656,8 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int
|
|||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_QUADRATIC_ATTENUATION, float, setQuadraticAttenuation);
|
||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_EXPONENT, float, setExponent);
|
||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_CUTOFF, float, setCutoff);
|
||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_LOCKED, bool, setLocked);
|
||||
READ_ENTITY_PROPERTY_STRING_TO_PROPERTIES(PROP_TEXTURES, setTextures);
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
@ -708,6 +722,8 @@ void EntityItemProperties::markAllChanged() {
|
|||
_quadraticAttenuationChanged = true;
|
||||
_exponentChanged = true;
|
||||
_cutoffChanged = true;
|
||||
_lockedChanged = true;
|
||||
_texturesChanged = true;
|
||||
}
|
||||
|
||||
AACube EntityItemProperties::getMaximumAACubeInTreeUnits() const {
|
||||
|
|
|
@ -75,6 +75,12 @@ enum EntityPropertyList {
|
|||
PROP_EXPONENT,
|
||||
PROP_CUTOFF,
|
||||
|
||||
// available to all entities
|
||||
PROP_LOCKED,
|
||||
|
||||
// used by Model entities
|
||||
PROP_TEXTURES,
|
||||
|
||||
PROP_LAST_ITEM = PROP_CUTOFF
|
||||
};
|
||||
|
||||
|
@ -272,6 +278,13 @@ public:
|
|||
|
||||
float getCutoff() const { return _cutoff; }
|
||||
void setCutoff(float value) { _cutoff = value; _cutoffChanged = true; }
|
||||
|
||||
bool getLocked() const { return _locked; }
|
||||
void setLocked(bool value) { _locked = value; _lockedChanged = true; }
|
||||
bool lockedChanged() const { return _lockedChanged; }
|
||||
|
||||
const QString& getTextures() const { return _textures; }
|
||||
void setTextures(const QString& value) { _textures = value; _texturesChanged = true; }
|
||||
|
||||
void setLastEdited(quint64 usecTime) { _lastEdited = usecTime; }
|
||||
|
||||
|
@ -348,6 +361,8 @@ private:
|
|||
float _quadraticAttenuation;
|
||||
float _exponent;
|
||||
float _cutoff;
|
||||
bool _locked;
|
||||
QString _textures;
|
||||
|
||||
bool _diffuseColorChanged;
|
||||
bool _ambientColorChanged;
|
||||
|
@ -357,6 +372,8 @@ private:
|
|||
bool _quadraticAttenuationChanged;
|
||||
bool _exponentChanged;
|
||||
bool _cutoffChanged;
|
||||
bool _lockedChanged;
|
||||
bool _texturesChanged;
|
||||
|
||||
bool _defaultSettings;
|
||||
|
||||
|
|
|
@ -108,16 +108,31 @@ bool EntityTree::updateEntity(const EntityItemID& entityID, const EntityItemProp
|
|||
return false;
|
||||
}
|
||||
|
||||
// check to see if we need to simulate this entity...
|
||||
EntityItem::SimulationState oldState = existingEntity->getSimulationState();
|
||||
// enforce support for locked entities. If an entity is currently locked, then the only
|
||||
// property we allow you to change is the locked property.
|
||||
if (existingEntity->getLocked()) {
|
||||
if (properties.lockedChanged()) {
|
||||
bool wantsLocked = properties.getLocked();
|
||||
if (!wantsLocked) {
|
||||
EntityItemProperties tempProperties;
|
||||
tempProperties.setLocked(wantsLocked);
|
||||
UpdateEntityOperator theOperator(this, containingElement, existingEntity, tempProperties);
|
||||
recurseTreeWithOperator(&theOperator);
|
||||
_isDirty = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// check to see if we need to simulate this entity...
|
||||
EntityItem::SimulationState oldState = existingEntity->getSimulationState();
|
||||
|
||||
UpdateEntityOperator theOperator(this, containingElement, existingEntity, properties);
|
||||
recurseTreeWithOperator(&theOperator);
|
||||
_isDirty = true;
|
||||
|
||||
EntityItem::SimulationState newState = existingEntity->getSimulationState();
|
||||
changeEntityState(existingEntity, oldState, newState);
|
||||
UpdateEntityOperator theOperator(this, containingElement, existingEntity, properties);
|
||||
recurseTreeWithOperator(&theOperator);
|
||||
_isDirty = true;
|
||||
|
||||
EntityItem::SimulationState newState = existingEntity->getSimulationState();
|
||||
changeEntityState(existingEntity, oldState, newState);
|
||||
}
|
||||
|
||||
containingElement = getContainingElement(entityID);
|
||||
if (!containingElement) {
|
||||
qDebug() << "UNEXPECTED!!!! after updateEntity() we no longer have a containing element??? entityID=" << entityID;
|
||||
|
|
|
@ -41,20 +41,15 @@ ModelEntityItem::ModelEntityItem(const EntityItemID& entityItemID, const EntityI
|
|||
|
||||
EntityItemProperties ModelEntityItem::getProperties() const {
|
||||
EntityItemProperties properties = EntityItem::getProperties(); // get the properties from our base class
|
||||
properties._color = getXColor();
|
||||
properties._modelURL = getModelURL();
|
||||
properties._animationURL = getAnimationURL();
|
||||
properties._animationIsPlaying = getAnimationIsPlaying();
|
||||
properties._animationFrameIndex = getAnimationFrameIndex();
|
||||
properties._animationFPS = getAnimationFPS();
|
||||
properties._colorChanged = false;
|
||||
properties._modelURLChanged = false;
|
||||
properties._animationURLChanged = false;
|
||||
properties._animationIsPlayingChanged = false;
|
||||
properties._animationFrameIndexChanged = false;
|
||||
properties._animationFPSChanged = false;
|
||||
properties._glowLevel = getGlowLevel();
|
||||
properties._glowLevelChanged = false;
|
||||
|
||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(color, getXColor);
|
||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(modelURL, getModelURL);
|
||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(animationURL, getAnimationURL);
|
||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(animationIsPlaying, getAnimationIsPlaying);
|
||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(animationFrameIndex, getAnimationFrameIndex);
|
||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(animationFPS, getAnimationFPS);
|
||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(glowLevel, getGlowLevel);
|
||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(textures, getTextures);
|
||||
return properties;
|
||||
}
|
||||
|
||||
|
@ -68,6 +63,7 @@ bool ModelEntityItem::setProperties(const EntityItemProperties& properties, bool
|
|||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(animationIsPlaying, setAnimationIsPlaying);
|
||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(animationFrameIndex, setAnimationFrameIndex);
|
||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(animationFPS, setAnimationFPS);
|
||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(textures, setTextures);
|
||||
|
||||
if (somethingChanged) {
|
||||
bool wantDebug = false;
|
||||
|
@ -107,6 +103,7 @@ int ModelEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data,
|
|||
READ_ENTITY_PROPERTY(PROP_ANIMATION_FPS, float, _animationFPS);
|
||||
READ_ENTITY_PROPERTY(PROP_ANIMATION_FRAME_INDEX, float, _animationFrameIndex);
|
||||
READ_ENTITY_PROPERTY(PROP_ANIMATION_PLAYING, bool, _animationIsPlaying);
|
||||
READ_ENTITY_PROPERTY_STRING(PROP_TEXTURES, setTextures);
|
||||
|
||||
return bytesRead;
|
||||
}
|
||||
|
@ -230,6 +227,7 @@ EntityPropertyFlags ModelEntityItem::getEntityProperties(EncodeBitstreamParams&
|
|||
requestedProperties += PROP_ANIMATION_FPS;
|
||||
requestedProperties += PROP_ANIMATION_FRAME_INDEX;
|
||||
requestedProperties += PROP_ANIMATION_PLAYING;
|
||||
requestedProperties += PROP_TEXTURES;
|
||||
|
||||
return requestedProperties;
|
||||
}
|
||||
|
@ -250,6 +248,7 @@ void ModelEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBit
|
|||
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_FPS, appendValue, getAnimationFPS());
|
||||
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_FRAME_INDEX, appendValue, getAnimationFrameIndex());
|
||||
APPEND_ENTITY_PROPERTY(PROP_ANIMATION_PLAYING, appendValue, getAnimationIsPlaying());
|
||||
APPEND_ENTITY_PROPERTY(PROP_TEXTURES, appendValue, getTextures());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -88,6 +88,10 @@ public:
|
|||
bool getAnimationIsPlaying() const { return _animationIsPlaying; }
|
||||
float getAnimationFrameIndex() const { return _animationFrameIndex; }
|
||||
float getAnimationFPS() const { return _animationFPS; }
|
||||
|
||||
static const QString DEFAULT_TEXTURES;
|
||||
const QString& getTextures() const { return _textures; }
|
||||
void setTextures(const QString& textures) { _textures = textures; }
|
||||
|
||||
static void cleanupLoadedAnimations();
|
||||
|
||||
|
@ -105,9 +109,12 @@ protected:
|
|||
float _animationFrameIndex; // we keep this as a float and round to int only when we need the exact index
|
||||
bool _animationIsPlaying;
|
||||
float _animationFPS;
|
||||
QString _textures;
|
||||
|
||||
// used on client side
|
||||
bool _jointMappingCompleted;
|
||||
QVector<int> _jointMapping;
|
||||
|
||||
|
||||
static Animation* getAnimation(const QString& url);
|
||||
static QMap<QString, AnimationPointer> _loadedAnimations;
|
||||
static AnimationCache _animationCache;
|
||||
|
|
Loading…
Reference in a new issue