From 29f083547527adbdc74c86b71c62af1caefd861c Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Wed, 20 Dec 2017 16:06:19 -0800 Subject: [PATCH 1/4] making entity joints work again --- .../src/RenderableModelEntityItem.cpp | 4 ++- script-archive/dressing_room/doppelganger.js | 34 +++++++++---------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp index e578e4858d..ce43aa4eb5 100644 --- a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp @@ -1259,7 +1259,9 @@ void ModelEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce _currentTextures = newTextures; } } - + if(entity->_needsJointSimulation) { + entity->copyAnimationJointDataToModel(); + } entity->updateModelBounds(); if (model->isVisible() != _visible) { diff --git a/script-archive/dressing_room/doppelganger.js b/script-archive/dressing_room/doppelganger.js index 10f6468e9f..8ff62ff665 100644 --- a/script-archive/dressing_room/doppelganger.js +++ b/script-archive/dressing_room/doppelganger.js @@ -15,7 +15,7 @@ var TEST_MODEL_URL = 'https://s3.amazonaws.com/hifi-public/ozan/avatars/albert/a var MIRROR_JOINT_DATA = true; var MIRRORED_ENTITY_SCRIPT_URL = Script.resolvePath('mirroredEntity.js'); -var FREEZE_TOGGLER_SCRIPT_URL = Script.resolvePath('freezeToggler.js?' + Math.random(0, 1000)) +var FREEZE_TOGGLER_SCRIPT_URL = Script.resolvePath('freezeToggler.js?' + Math.random(0, 1000)); var THROTTLE = false; var THROTTLE_RATE = 100; var doppelgangers = []; @@ -24,8 +24,7 @@ function Doppelganger(avatar) { this.initialProperties = { name: 'Hifi-Doppelganger', type: 'Model', - modelURL: TEST_MODEL_URL, - // dimensions: getAvatarDimensions(avatar), + modelURL: MyAvatar.skeletonModelURL, position: putDoppelgangerAcrossFromAvatar(this, avatar), rotation: rotateDoppelgangerTowardAvatar(this, avatar), collisionsWillMove: false, @@ -33,7 +32,7 @@ function Doppelganger(avatar) { script: FREEZE_TOGGLER_SCRIPT_URL, userData: JSON.stringify({ grabbableKey: { - grabbable: false, + grabbable: true, wantsTrigger: true } }) @@ -48,7 +47,7 @@ function getJointData(avatar) { var jointNames = MyAvatar.jointNames; jointNames.forEach(function(joint, index) { var translation = MyAvatar.getJointTranslation(index); - var rotation = MyAvatar.getJointRotation(index) + var rotation = MyAvatar.getJointRotation(index); allJointData.push({ joint: joint, index: index, @@ -65,9 +64,10 @@ function setJointData(doppelganger, relativeXforms) { var i, l = relativeXforms.length; for (i = 0; i < l; i++) { jointRotations.push(relativeXforms[i].rot); + //Entities.setAbsoluteJointRotationInObjectFrame(doppelganger.id, i, relativeXforms[i].rot); } - Entities.setAbsoluteJointRotationsInObjectFrame(doppelganger.id, jointRotations); + Entities.setLocalJointRotations(doppelganger.id, jointRotations); return true; } @@ -127,7 +127,7 @@ var JOINT_MIRROR_NAME_MAP = { LeftHandPinky2: "RightHandPinky2", LeftHandPinky3: "RightHandPinky3", LeftHandPinky4: "RightHandPinky4", - LeftHandPinky: "RightHandPinky", + LeftHandPinky: "RightHandPinky" }; // maps joint names to parent joint names. @@ -192,7 +192,7 @@ var JOINT_PARENT_NAME_MAP = { LeftHandPinky1: "LeftHand", LeftHandPinky2: "LeftHandPinky1", LeftHandPinky3: "LeftHandPinky2", - LeftHandPinky: "LeftHandPinky3", + LeftHandPinky: "LeftHandPinky3" }; // maps joint indices to parent joint indices. @@ -395,7 +395,7 @@ function connectDoppelgangerUpdates() { } function disconnectDoppelgangerUpdates() { - print('SHOULD DISCONNECT') + print('SHOULD DISCONNECT'); if (isConnected === true) { Script.update.disconnect(updateDoppelganger); } @@ -465,13 +465,13 @@ function handleFreezeMessages(channel, message, sender) { } catch (e) { print('error parsing wearable message'); } - print('MESSAGE ACTION::' + parsedMessage.action) + print('MESSAGE ACTION::' + parsedMessage.action); if (parsedMessage.action === 'freeze') { - print('ACTUAL FREEZE') + print('ACTUAL FREEZE'); disconnectDoppelgangerUpdates(); } if (parsedMessage.action === 'unfreeze') { - print('ACTUAL UNFREEZE') + print('ACTUAL UNFREEZE'); connectDoppelgangerUpdates(); } @@ -496,7 +496,7 @@ function handleWearableMessages(channel, message, sender) { } catch (e) { print('error parsing wearable message'); } - print('parsed message!!!') + print('parsed message!!!'); if (channel === 'Hifi-Doppelganger-Wearable') { mirrorEntitiesForDoppelganger(doppelgangers[0], parsedMessage); @@ -511,13 +511,13 @@ function mirrorEntitiesForDoppelganger(doppelganger, parsedMessage) { var doppelgangerProps = Entities.getEntityProperties(doppelganger.id); var action = parsedMessage.action; - print('IN MIRROR ENTITIES CALL' + action) + print('IN MIRROR ENTITIES CALL' + action); var baseEntity = parsedMessage.baseEntity; var wearableProps = Entities.getEntityProperties(baseEntity); - print('WEARABLE PROPS::') + print('WEARABLE PROPS::'); delete wearableProps.id; delete wearableProps.created; delete wearableProps.age; @@ -613,7 +613,7 @@ function getBaseEntityForMirrorEntity(mirrorEntity) { makeDoppelgangerForMyAvatar(); subscribeToWearableMessages(); -subscribeToWearableMessagesForAvatar(); +//subscribeToWearableMessagesForAvatar(); subscribeToFreezeMessages(); function cleanup() { @@ -626,4 +626,4 @@ function cleanup() { Entities.deleteEntity(doppelganger.id); }); } -Script.scriptEnding.connect(cleanup); \ No newline at end of file +Script.scriptEnding.connect(cleanup); From 77874de9093bebd98377dd4d8e8400ce32adce1f Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Thu, 21 Dec 2017 15:05:23 -0800 Subject: [PATCH 2/4] fix spacing --- interface/resources/qml/js/Utils.jsc | Bin 6596 -> 6548 bytes .../src/RenderableModelEntityItem.cpp | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/resources/qml/js/Utils.jsc b/interface/resources/qml/js/Utils.jsc index ab20e996b9469915ac6a89901da175143e6b5024..96c5b26fda10a505b491ad2d08588089fdfa8922 100644 GIT binary patch delta 581 zcmZ9JO=uH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em.cpp index cfce275008..0b8c1a5bc5 100644 --- a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp @@ -1255,7 +1255,7 @@ void ModelEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce _currentTextures = newTextures; } } - if(entity->_needsJointSimulation) { + if (entity->_needsJointSimulation) { entity->copyAnimationJointDataToModel(); } entity->updateModelBounds(); From 537db37b2634fbf3577da28de665d61b5556e763 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Thu, 25 Jan 2018 16:23:35 -0800 Subject: [PATCH 3/4] removed dead comment --- .../dressing_room/.#doppelganger.js | 1 + script-archive/dressing_room/doppelganger.js | 30 +++++++++---------- 2 files changed, 15 insertions(+), 16 deletions(-) create mode 100644 script-archive/dressing_room/.#doppelganger.js diff --git a/script-archive/dressing_room/.#doppelganger.js b/script-archive/dressing_room/.#doppelganger.js new file mode 100644 index 0000000000..63b1f8f93c --- /dev/null +++ b/script-archive/dressing_room/.#doppelganger.js @@ -0,0 +1 @@ +dante@0228-DESKTOP-PC.9420:1516899782 \ No newline at end of file diff --git a/script-archive/dressing_room/doppelganger.js b/script-archive/dressing_room/doppelganger.js index 8ff62ff665..773a5d974b 100644 --- a/script-archive/dressing_room/doppelganger.js +++ b/script-archive/dressing_room/doppelganger.js @@ -32,7 +32,7 @@ function Doppelganger(avatar) { script: FREEZE_TOGGLER_SCRIPT_URL, userData: JSON.stringify({ grabbableKey: { - grabbable: true, + grabbable: false, wantsTrigger: true } }) @@ -64,7 +64,6 @@ function setJointData(doppelganger, relativeXforms) { var i, l = relativeXforms.length; for (i = 0; i < l; i++) { jointRotations.push(relativeXforms[i].rot); - //Entities.setAbsoluteJointRotationInObjectFrame(doppelganger.id, i, relativeXforms[i].rot); } Entities.setLocalJointRotations(doppelganger.id, jointRotations); @@ -206,7 +205,7 @@ function Xform(rot, pos) { }; Xform.ident = function () { return new Xform({x: 0, y: 0, z: 0, w: 1}, {x: 0, y: 0, z: 0}); -} +}; Xform.mul = function (lhs, rhs) { var rot = Quat.multiply(lhs.rot, rhs.rot); var pos = Vec3.sum(lhs.pos, Vec3.multiplyQbyV(lhs.rot, rhs.pos)); @@ -354,12 +353,12 @@ function getAvatarFootOffset() { if (jointName === "RightToe_End") { toeTop = d.translation.y } - }) + }); var myPosition = MyAvatar.position; var offset = upperLeg + lowerLeg + foot + toe + toeTop; offset = offset / 100; - return offset + return offset; } @@ -545,15 +544,15 @@ function mirrorEntitiesForDoppelganger(doppelganger, parsedMessage) { baseEntity: baseEntity, doppelganger: doppelganger.id } - }) + }); var mirrorEntity = Entities.addEntity(wearableProps); - var mirrorEntityProps = Entities.getEntityProperties(mirrorEntity) - print('MIRROR PROPS::' + JSON.stringify(mirrorEntityProps)) + var mirrorEntityProps = Entities.getEntityProperties(mirrorEntity); + print('MIRROR PROPS::' + JSON.stringify(mirrorEntityProps)); var wearablePair = { baseEntity: baseEntity, mirrorEntity: mirrorEntity - } + }; wearablePairs.push(wearablePair); } @@ -563,11 +562,11 @@ function mirrorEntitiesForDoppelganger(doppelganger, parsedMessage) { var mirrorEntity = getMirrorEntityForBaseEntity(baseEntity); // print('MIRROR ENTITY, newPosition' + mirrorEntity + ":::" + JSON.stringify(newPosition)) - Entities.editEntity(mirrorEntity, wearableProps) + Entities.editEntity(mirrorEntity, wearableProps); } if (action === 'remove') { - Entities.deleteEntity(getMirrorEntityForBaseEntity(baseEntity)) + Entities.deleteEntity(getMirrorEntityForBaseEntity(baseEntity)); wearablePairs = wearablePairs.filter(function(obj) { return obj.baseEntity !== baseEntity; }); @@ -575,7 +574,7 @@ function mirrorEntitiesForDoppelganger(doppelganger, parsedMessage) { if (action === 'updateBase') { //this gets called when the mirrored entity gets grabbed. now we move the - var mirrorEntityProperties = Entities.getEntityProperties(message.mirrorEntity) + var mirrorEntityProperties = Entities.getEntityProperties(message.mirrorEntity); var doppelgangerToMirrorEntity = Vec3.subtract(doppelgangerProps.position, mirrorEntityProperties.position); var newPosition = Vec3.sum(MyAvatar.position, doppelgangerToMirrorEntity); @@ -596,7 +595,7 @@ function getMirrorEntityForBaseEntity(baseEntity) { if (result.length === 0) { return false; } else { - return result[0].mirrorEntity + return result[0].mirrorEntity; } } @@ -607,13 +606,12 @@ function getBaseEntityForMirrorEntity(mirrorEntity) { if (result.length === 0) { return false; } else { - return result[0].baseEntity + return result[0].baseEntity; } } makeDoppelgangerForMyAvatar(); subscribeToWearableMessages(); -//subscribeToWearableMessagesForAvatar(); subscribeToFreezeMessages(); function cleanup() { @@ -622,7 +620,7 @@ function cleanup() { } doppelgangers.forEach(function(doppelganger) { - print('DOPPELGANGER' + doppelganger.id) + print('DOPPELGANGER' + doppelganger.id); Entities.deleteEntity(doppelganger.id); }); } From 5bb1b1bbffb006d651d9f9d74904bec9f725e5d9 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Thu, 25 Jan 2018 16:26:00 -0800 Subject: [PATCH 4/4] remove backup file --- script-archive/dressing_room/.#doppelganger.js | 1 - 1 file changed, 1 deletion(-) delete mode 100644 script-archive/dressing_room/.#doppelganger.js diff --git a/script-archive/dressing_room/.#doppelganger.js b/script-archive/dressing_room/.#doppelganger.js deleted file mode 100644 index 63b1f8f93c..0000000000 --- a/script-archive/dressing_room/.#doppelganger.js +++ /dev/null @@ -1 +0,0 @@ -dante@0228-DESKTOP-PC.9420:1516899782 \ No newline at end of file