diff --git a/unpublishedScripts/DomainContent/Home/dressingRoom/transformer.js b/unpublishedScripts/DomainContent/Home/dressingRoom/transformer.js index 404658cf6c..78caec3d80 100644 --- a/unpublishedScripts/DomainContent/Home/dressingRoom/transformer.js +++ b/unpublishedScripts/DomainContent/Home/dressingRoom/transformer.js @@ -25,26 +25,41 @@ x: 1.8838, y: 1.7865, z: 0.2955 - } + }; var ROBOT_DIMENSIONS = { //robot x: 1.4439, y: 0.6224, z: 0.4998 - } + }; + var WILL_DIMENSIONS = { x: 1.6326, y: 1.6764, z: 0.2606 }; + var PRISCILLA_DIMENSIONS = { + //priscilla + x: 1.6448, + y: 1.6657, + z: 0.3078 + }; + + var MATTHEW_DIMENSIONS = { + //matthew + x: 1.8722, + y: 1.8197, + z: 0.3666 + }; + var _this; function Transformer() { _this = this; return this; - } + }; Transformer.prototype = { locked: false, @@ -54,33 +69,45 @@ print('PRELOAD TRANSFORMER SCRIPT') this.entityID = entityID; this.initialProperties = Entities.getEntityProperties(entityID); - // this.transformationSound = SoundCache.getSound(TRANSFORMATION_SOUND_URL); }, collisionWithEntity: function(myID, otherID, collisionInfo) { var otherProps = Entities.getEntityProperties(otherID); if (otherProps.name === "hifi-home-dressing-room-transformer-collider" && _this.locked === false) { - print('UNLOCKED TRANSFORMER COLLIDED WITH BASE!! THE AVATAR WHO SIMULATED THIS COLLISION IS:: ' + MyAvatar.sessionUUID); _this.locked = true; _this.findRotatorBlock(); } else { + var transformerProps = Entities.getEntityProperties(_this.entityID, ["rotation", "position"]); + + var eulerRotation = Quat.safeEulerAngles(transformerProps.rotation); + eulerRotation.x = 0; + eulerRotation.z = 0; + var newRotation = Quat.fromVec3Degrees(eulerRotation); + + //we zero out the velocity and angular velocity so the cow doesn't change position or spin + Entities.editEntity(_this.entityID, { + rotation: newRotation, + velocity: { + x: 0, + y: 0, + z: 0 + }, + angularVelocity: { + x: 0, + y: 0, + z: 0 + } + }); + return; } }, - // playTransformationSound: function(position) { - // print('transformer should play a sound') - // Audio.playSound(_this.transformationSound, { - // position: position, - // volume: 0.5 - // }); - // }, - findRotatorBlock: function() { - print('transformer should find rotator block') var myProps = Entities.getEntityProperties(_this.entityID); var results = Entities.findEntities(myProps.position, 10); + results.forEach(function(result) { var resultProps = Entities.getEntityProperties(result); if (resultProps.name === "hifi-home-dressing-room-rotator-block") { @@ -89,14 +116,13 @@ return; } }); - }, removeCurrentBigVersion: function(rotatorBlock) { - print('transformer should remove big version') var blacklistKey = 'Hifi-Hand-RayPick-Blacklist'; var myProps = Entities.getEntityProperties(_this.entityID); var results = Entities.findEntities(myProps.position, 10); + results.forEach(function(result) { var resultProps = Entities.getEntityProperties(result); if (resultProps.name === "hifi-home-dressing-room-big-transformer") { @@ -110,31 +136,35 @@ return; } }); + _this.createBigVersion(); }, createBigVersion: function() { var smallProps = Entities.getEntityProperties(_this.entityID); - print('transformer should create big version!!' + smallProps.modelURL); - print('transformer has rotatorBlock??' + _this.rotatorBlock); var rotatorProps = Entities.getEntityProperties(_this.rotatorBlock); var dimensions; if (smallProps.modelURL.indexOf('will') > -1) { - print('TRANSFORMER IS WILL') + // print('TRANSFORMER IS WILL'); dimensions = WILL_DIMENSIONS; } else if (smallProps.modelURL.indexOf('being_of_light') > -1) { - print('TRANSFORMER IS BEING OF LIGHT') - + // print('TRANSFORMER IS BEING OF LIGHT'); dimensions = BEING_OF_LIGHT_DIMENSIONS; } else if (smallProps.modelURL.indexOf('stylized_female') > -1) { - print('TRANSFORMER IS ARTEMIS') + // print('TRANSFORMER IS ARTEMIS'); dimensions = STYLIZED_FEMALE_DIMENSIONS; } else if (smallProps.modelURL.indexOf('simple_robot') > -1) { - print('TRANSFORMER IS A ROBOT') + // print('TRANSFORMER IS A ROBOT'); dimensions = ROBOT_DIMENSIONS; + } else if (smallProps.modelURL.indexOf('priscilla') > -1) { + // print('TRANSFORMER IS PRISCILLA'); + dimensions = PRISCILLA_DIMENSIONS; + } else if (smallProps.modelURL.indexOf('matthew') > -1) { + // print('TRANSFORMER IS MATTHEW'); + dimensions = MATTHEW_DIMENSIONS; } else { - print('TRANSFORMER IS SOME OTHER'); + // print('TRANSFORMER IS SOME OTHER'); dimensions = smallProps.naturalDimensions; } @@ -154,14 +184,13 @@ 'reset': true } }), - } + }; - if(bigVersionProps.modelURL.indexOf('simple_robot') > -1){ - bigVersionProps.position.y+=0.5; + if (bigVersionProps.modelURL.indexOf('simple_robot') > -1) { + bigVersionProps.position.y += 0.5; } var bigVersion = Entities.addEntity(bigVersionProps); - print('transformer created big version: ' + bigVersion); var blacklistKey = 'Hifi-Hand-RayPick-Blacklist'; Messages.sendMessage(blacklistKey, JSON.stringify({ @@ -173,12 +202,10 @@ }, putTransformerOnRotatorBlock: function(blockPosition) { - print('transformer should get set on rotator block') - return blockPosition + return blockPosition; }, putNewVersionOnShelf: function() { - print('transformer should out a new version of itself on the shelf') var littleVersionProps = Entities.getEntityProperties(_this.entityID); delete littleVersionProps.id; delete littleVersionProps.created; @@ -189,23 +216,24 @@ delete littleVersionProps.localPosition; delete littleVersionProps.localRotation; delete littleVersionProps.naturalPosition; - // delete littleVersionProps.script; littleVersionProps.gravity = { x: 0, y: -10, z: 0 }; var userData = JSON.parse(littleVersionProps.userData); + var basePosition = userData["hifiHomeTransformerKey"].basePosition; var baseRotation = userData["hifiHomeTransformerKey"].baseRotation; + littleVersionProps.position = basePosition; littleVersionProps.rotation = baseRotation; var littleTransformer = Entities.addEntity(littleVersionProps); + _this.removeSelf(); }, removeSelf: function() { - print('transformer should remove itself') var success = Entities.deleteEntity(_this.entityID); }, }; diff --git a/unpublishedScripts/DomainContent/Home/dressingRoom/wrapper.js b/unpublishedScripts/DomainContent/Home/dressingRoom/wrapper.js index c1fe53e49b..4b2793966a 100644 --- a/unpublishedScripts/DomainContent/Home/dressingRoom/wrapper.js +++ b/unpublishedScripts/DomainContent/Home/dressingRoom/wrapper.js @@ -9,48 +9,53 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // - var TRANSFORMER_SCRIPT = Script.resolvePath('transformer.js'); +var TRANSFORMER_SCRIPT = Script.resolvePath('transformer.js'); - var AVATAR_COLLISION_HULL = 'atp:/dressingRoom/Avatar-Hull-4.obj'; +var AVATAR_COLLISION_HULL = 'atp:/dressingRoom/Avatar-Hull-6.obj'; +var ROBOT_COLLISION_HULL = 'atp:/dressingRoom/robot_hull.obj'; - TransformerDoll = function(modelURL, spawnPosition, spawnRotation, dimensions) { - print('SCRIPT REF AT TRANSFORMER CREATE::' + TRANSFORMER_SCRIPT); - var transformerProps = { - name: 'hifi-home-dressing-room-little-transformer', - type: 'Model', - shapeType: 'compound', - compoundShapeURL: AVATAR_COLLISION_HULL, - position: spawnPosition, - rotation: Quat.fromPitchYawRollDegrees(spawnRotation.x, spawnRotation.y, spawnRotation.z), - modelURL: modelURL, - dynamic: true, - gravity: { - x: 0, - y: -10, - z: 0 - }, - visible: true, - damping: 0.8, - angularDamping: 0.8, - userData: JSON.stringify({ - 'grabbableKey': { - 'grabbable': true - }, - 'hifiHomeTransformerKey': { - 'basePosition': spawnPosition, - 'baseRotation': Quat.fromPitchYawRollDegrees(spawnRotation.x, spawnRotation.y, spawnRotation.z), - }, - 'hifiHomeKey': { - 'reset': true - } - }), - density: 5000, - dimensions: dimensions, - script: TRANSFORMER_SCRIPT - } - var transformer = Entities.addEntity(transformerProps); +TransformerDoll = function(modelURL, spawnPosition, spawnRotation, dimensions) { - print('CREATED TRANSFORMER' + transformer); + var transformerProps = { + name: 'hifi-home-dressing-room-little-transformer', + type: 'Model', + shapeType: 'compound', + compoundShapeURL: AVATAR_COLLISION_HULL, + position: spawnPosition, + rotation: Quat.fromPitchYawRollDegrees(spawnRotation.x, spawnRotation.y, spawnRotation.z), + modelURL: modelURL, + dynamic: true, + gravity: { + x: 0, + y: -10, + z: 0 + }, + visible: true, + restitution: 0.1, + damping: 0.9, + angularDamping: 0.9, + userData: JSON.stringify({ + 'grabbableKey': { + 'grabbable': true + }, + 'hifiHomeTransformerKey': { + 'basePosition': spawnPosition, + 'baseRotation': Quat.fromPitchYawRollDegrees(spawnRotation.x, spawnRotation.y, spawnRotation.z), + }, + 'hifiHomeKey': { + 'reset': true + } + }), + density: 7500, + dimensions: dimensions, + script: TRANSFORMER_SCRIPT + }; - return this; - } \ No newline at end of file + if (modelURL.indexOf('robot') > -1) { + transformerProps.compoundShapeURL = ROBOT_COLLISION_HULL; + } + + var transformer = Entities.addEntity(transformerProps); + + return this; +} \ No newline at end of file diff --git a/unpublishedScripts/DomainContent/Home/reset.js b/unpublishedScripts/DomainContent/Home/reset.js index 5f548cfd19..6f8dde1212 100644 --- a/unpublishedScripts/DomainContent/Home/reset.js +++ b/unpublishedScripts/DomainContent/Home/reset.js @@ -68,9 +68,9 @@ var TRANSFORMER_URL_STYLIZED_FEMALE = 'atp:/dressingRoom/stylized_female.fbx'; - var TRANSFORMER_URL_REALISTIC_MALE = ''; + var TRANSFORMER_URL_PRISCILLA = 'atp:/dressingRoom/priscilla.fbx'; - var TRANSFORMER_URL_REALISTIC_FEMALE = ''; + var TRANSFORMER_URL_MATTHEW = 'atp:/dressingRoom/matthew.fbx'; Reset.prototype = { tidying: false, @@ -414,14 +414,13 @@ }; var dais = Entities.addEntity(daisProperties); - print('HOME created dais : ' + dais) }, createTransformers: function() { var firstDollPosition = { - x: 1107.61, - y: 460.6, - z: -77.34 + x: 1107.6, + y: 460.575, + z: -77.37 } var dollRotation = { @@ -433,18 +432,15 @@ var rotationAsQuat = Quat.fromPitchYawRollDegrees(dollRotation.x, dollRotation.y, dollRotation.z); var dolls = [ - TRANSFORMER_URL_STYLIZED_FEMALE, TRANSFORMER_URL_ROBOT, TRANSFORMER_URL_BEING_OF_LIGHT, - TRANSFORMER_URL_WILL + TRANSFORMER_URL_STYLIZED_FEMALE, + TRANSFORMER_URL_WILL, + TRANSFORMER_URL_PRISCILLA, + TRANSFORMER_URL_MATTHEW ]; var dollDimensions = [{ - //stylized female artemis - x: 1.6323, - y: 1.7705, - z: 0.2851 - }, { //robot x: 1.4439, y: 0.6224, @@ -454,11 +450,26 @@ x: 1.8838, y: 1.7865, z: 0.2955 + }, { + //stylized female artemis + x: 1.6323, + y: 1.7705, + z: 0.2851 }, { //will x: 1.6326, y: 1.6764, z: 0.2606 + }, { + //priscilla + x: 1.6448, + y: 1.6657, + z: 0.3078 + }, { + //matthew + x: 1.8722, + y: 1.8197, + z: 0.3666 }]; var TRANSFORMER_SCALE = 0.25; @@ -474,7 +485,11 @@ var separation = index * dollLateralSeparation; var left = Quat.getRight(rotationAsQuat); var distanceToLeft = Vec3.multiply(separation, left); - var dollPosition = Vec3.sum(firstDollPosition, distanceToLeft) + var dollPosition = Vec3.sum(firstDollPosition, distanceToLeft); + if (index === 0) { + //special case for robot + dollPosition.y += 0.15; + } var transformer = new TransformerDoll(doll, dollPosition, dollRotation, dollDimensions[index]); });