Merge pull request #7803 from imgntn/homeUpdates

[Home] Dressing Room Updates
This commit is contained in:
Brad Hefta-Gaub 2016-05-05 11:06:10 -07:00
commit d89c339b6a
3 changed files with 136 additions and 88 deletions

View file

@ -25,26 +25,41 @@
x: 1.8838, x: 1.8838,
y: 1.7865, y: 1.7865,
z: 0.2955 z: 0.2955
} };
var ROBOT_DIMENSIONS = { var ROBOT_DIMENSIONS = {
//robot //robot
x: 1.4439, x: 1.4439,
y: 0.6224, y: 0.6224,
z: 0.4998 z: 0.4998
} };
var WILL_DIMENSIONS = { var WILL_DIMENSIONS = {
x: 1.6326, x: 1.6326,
y: 1.6764, y: 1.6764,
z: 0.2606 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; var _this;
function Transformer() { function Transformer() {
_this = this; _this = this;
return this; return this;
} };
Transformer.prototype = { Transformer.prototype = {
locked: false, locked: false,
@ -54,33 +69,45 @@
print('PRELOAD TRANSFORMER SCRIPT') print('PRELOAD TRANSFORMER SCRIPT')
this.entityID = entityID; this.entityID = entityID;
this.initialProperties = Entities.getEntityProperties(entityID); this.initialProperties = Entities.getEntityProperties(entityID);
// this.transformationSound = SoundCache.getSound(TRANSFORMATION_SOUND_URL);
}, },
collisionWithEntity: function(myID, otherID, collisionInfo) { collisionWithEntity: function(myID, otherID, collisionInfo) {
var otherProps = Entities.getEntityProperties(otherID); var otherProps = Entities.getEntityProperties(otherID);
if (otherProps.name === "hifi-home-dressing-room-transformer-collider" && _this.locked === false) { 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.locked = true;
_this.findRotatorBlock(); _this.findRotatorBlock();
} else { } 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; return;
} }
}, },
// playTransformationSound: function(position) {
// print('transformer should play a sound')
// Audio.playSound(_this.transformationSound, {
// position: position,
// volume: 0.5
// });
// },
findRotatorBlock: function() { findRotatorBlock: function() {
print('transformer should find rotator block')
var myProps = Entities.getEntityProperties(_this.entityID); var myProps = Entities.getEntityProperties(_this.entityID);
var results = Entities.findEntities(myProps.position, 10); var results = Entities.findEntities(myProps.position, 10);
results.forEach(function(result) { results.forEach(function(result) {
var resultProps = Entities.getEntityProperties(result); var resultProps = Entities.getEntityProperties(result);
if (resultProps.name === "hifi-home-dressing-room-rotator-block") { if (resultProps.name === "hifi-home-dressing-room-rotator-block") {
@ -89,14 +116,13 @@
return; return;
} }
}); });
}, },
removeCurrentBigVersion: function(rotatorBlock) { removeCurrentBigVersion: function(rotatorBlock) {
print('transformer should remove big version')
var blacklistKey = 'Hifi-Hand-RayPick-Blacklist'; var blacklistKey = 'Hifi-Hand-RayPick-Blacklist';
var myProps = Entities.getEntityProperties(_this.entityID); var myProps = Entities.getEntityProperties(_this.entityID);
var results = Entities.findEntities(myProps.position, 10); var results = Entities.findEntities(myProps.position, 10);
results.forEach(function(result) { results.forEach(function(result) {
var resultProps = Entities.getEntityProperties(result); var resultProps = Entities.getEntityProperties(result);
if (resultProps.name === "hifi-home-dressing-room-big-transformer") { if (resultProps.name === "hifi-home-dressing-room-big-transformer") {
@ -110,31 +136,35 @@
return; return;
} }
}); });
_this.createBigVersion(); _this.createBigVersion();
}, },
createBigVersion: function() { createBigVersion: function() {
var smallProps = Entities.getEntityProperties(_this.entityID); 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 rotatorProps = Entities.getEntityProperties(_this.rotatorBlock);
var dimensions; var dimensions;
if (smallProps.modelURL.indexOf('will') > -1) { if (smallProps.modelURL.indexOf('will') > -1) {
print('TRANSFORMER IS WILL') // print('TRANSFORMER IS WILL');
dimensions = WILL_DIMENSIONS; dimensions = WILL_DIMENSIONS;
} else if (smallProps.modelURL.indexOf('being_of_light') > -1) { } 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; dimensions = BEING_OF_LIGHT_DIMENSIONS;
} else if (smallProps.modelURL.indexOf('stylized_female') > -1) { } else if (smallProps.modelURL.indexOf('stylized_female') > -1) {
print('TRANSFORMER IS ARTEMIS') // print('TRANSFORMER IS ARTEMIS');
dimensions = STYLIZED_FEMALE_DIMENSIONS; dimensions = STYLIZED_FEMALE_DIMENSIONS;
} else if (smallProps.modelURL.indexOf('simple_robot') > -1) { } else if (smallProps.modelURL.indexOf('simple_robot') > -1) {
print('TRANSFORMER IS A ROBOT') // print('TRANSFORMER IS A ROBOT');
dimensions = ROBOT_DIMENSIONS; 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 { } else {
print('TRANSFORMER IS SOME OTHER'); // print('TRANSFORMER IS SOME OTHER');
dimensions = smallProps.naturalDimensions; dimensions = smallProps.naturalDimensions;
} }
@ -154,14 +184,13 @@
'reset': true 'reset': true
} }
}), }),
} };
if(bigVersionProps.modelURL.indexOf('simple_robot') > -1){ if (bigVersionProps.modelURL.indexOf('simple_robot') > -1) {
bigVersionProps.position.y+=0.5; bigVersionProps.position.y += 0.5;
} }
var bigVersion = Entities.addEntity(bigVersionProps); var bigVersion = Entities.addEntity(bigVersionProps);
print('transformer created big version: ' + bigVersion);
var blacklistKey = 'Hifi-Hand-RayPick-Blacklist'; var blacklistKey = 'Hifi-Hand-RayPick-Blacklist';
Messages.sendMessage(blacklistKey, JSON.stringify({ Messages.sendMessage(blacklistKey, JSON.stringify({
@ -173,12 +202,10 @@
}, },
putTransformerOnRotatorBlock: function(blockPosition) { putTransformerOnRotatorBlock: function(blockPosition) {
print('transformer should get set on rotator block') return blockPosition;
return blockPosition
}, },
putNewVersionOnShelf: function() { putNewVersionOnShelf: function() {
print('transformer should out a new version of itself on the shelf')
var littleVersionProps = Entities.getEntityProperties(_this.entityID); var littleVersionProps = Entities.getEntityProperties(_this.entityID);
delete littleVersionProps.id; delete littleVersionProps.id;
delete littleVersionProps.created; delete littleVersionProps.created;
@ -189,23 +216,24 @@
delete littleVersionProps.localPosition; delete littleVersionProps.localPosition;
delete littleVersionProps.localRotation; delete littleVersionProps.localRotation;
delete littleVersionProps.naturalPosition; delete littleVersionProps.naturalPosition;
// delete littleVersionProps.script;
littleVersionProps.gravity = { littleVersionProps.gravity = {
x: 0, x: 0,
y: -10, y: -10,
z: 0 z: 0
}; };
var userData = JSON.parse(littleVersionProps.userData); var userData = JSON.parse(littleVersionProps.userData);
var basePosition = userData["hifiHomeTransformerKey"].basePosition; var basePosition = userData["hifiHomeTransformerKey"].basePosition;
var baseRotation = userData["hifiHomeTransformerKey"].baseRotation; var baseRotation = userData["hifiHomeTransformerKey"].baseRotation;
littleVersionProps.position = basePosition; littleVersionProps.position = basePosition;
littleVersionProps.rotation = baseRotation; littleVersionProps.rotation = baseRotation;
var littleTransformer = Entities.addEntity(littleVersionProps); var littleTransformer = Entities.addEntity(littleVersionProps);
_this.removeSelf(); _this.removeSelf();
}, },
removeSelf: function() { removeSelf: function() {
print('transformer should remove itself')
var success = Entities.deleteEntity(_this.entityID); var success = Entities.deleteEntity(_this.entityID);
}, },
}; };

View file

@ -9,48 +9,53 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // 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) { 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);
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; if (modelURL.indexOf('robot') > -1) {
} transformerProps.compoundShapeURL = ROBOT_COLLISION_HULL;
}
var transformer = Entities.addEntity(transformerProps);
return this;
}

View file

@ -68,9 +68,9 @@
var TRANSFORMER_URL_STYLIZED_FEMALE = 'atp:/dressingRoom/stylized_female.fbx'; 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 = { Reset.prototype = {
tidying: false, tidying: false,
@ -414,14 +414,13 @@
}; };
var dais = Entities.addEntity(daisProperties); var dais = Entities.addEntity(daisProperties);
print('HOME created dais : ' + dais)
}, },
createTransformers: function() { createTransformers: function() {
var firstDollPosition = { var firstDollPosition = {
x: 1107.61, x: 1107.6,
y: 460.6, y: 460.575,
z: -77.34 z: -77.37
} }
var dollRotation = { var dollRotation = {
@ -433,18 +432,15 @@
var rotationAsQuat = Quat.fromPitchYawRollDegrees(dollRotation.x, dollRotation.y, dollRotation.z); var rotationAsQuat = Quat.fromPitchYawRollDegrees(dollRotation.x, dollRotation.y, dollRotation.z);
var dolls = [ var dolls = [
TRANSFORMER_URL_STYLIZED_FEMALE,
TRANSFORMER_URL_ROBOT, TRANSFORMER_URL_ROBOT,
TRANSFORMER_URL_BEING_OF_LIGHT, TRANSFORMER_URL_BEING_OF_LIGHT,
TRANSFORMER_URL_WILL TRANSFORMER_URL_STYLIZED_FEMALE,
TRANSFORMER_URL_WILL,
TRANSFORMER_URL_PRISCILLA,
TRANSFORMER_URL_MATTHEW
]; ];
var dollDimensions = [{ var dollDimensions = [{
//stylized female artemis
x: 1.6323,
y: 1.7705,
z: 0.2851
}, {
//robot //robot
x: 1.4439, x: 1.4439,
y: 0.6224, y: 0.6224,
@ -454,11 +450,26 @@
x: 1.8838, x: 1.8838,
y: 1.7865, y: 1.7865,
z: 0.2955 z: 0.2955
}, {
//stylized female artemis
x: 1.6323,
y: 1.7705,
z: 0.2851
}, { }, {
//will //will
x: 1.6326, x: 1.6326,
y: 1.6764, y: 1.6764,
z: 0.2606 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; var TRANSFORMER_SCALE = 0.25;
@ -474,7 +485,11 @@
var separation = index * dollLateralSeparation; var separation = index * dollLateralSeparation;
var left = Quat.getRight(rotationAsQuat); var left = Quat.getRight(rotationAsQuat);
var distanceToLeft = Vec3.multiply(separation, left); 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, var transformer = new TransformerDoll(doll, dollPosition, dollRotation,
dollDimensions[index]); dollDimensions[index]);
}); });