From 2533bfd2ad9a949ec6cb64756f8659df5b87f708 Mon Sep 17 00:00:00 2001 From: James Pollack Date: Fri, 2 Oct 2015 11:30:56 -0700 Subject: [PATCH 1/6] initial --- examples/toys/createKnockoverBlocks.js | 47 ++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 examples/toys/createKnockoverBlocks.js diff --git a/examples/toys/createKnockoverBlocks.js b/examples/toys/createKnockoverBlocks.js new file mode 100644 index 0000000000..b5fe22ca73 --- /dev/null +++ b/examples/toys/createKnockoverBlocks.js @@ -0,0 +1,47 @@ +// +// createKnockoverBlocks.js +// +// Created by James B. Pollack on 9/29/2015 +// Copyright 2015 High Fidelity, Inc. +// +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +/*global MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, HMD, AvatarList, AvatarManager, Controller, UndoStack, Window, Account, GlobalServices, Script, ScriptDiscoveryService, LODManager, Menu, Vec3, Quat, AudioDevice, Paths, Clipboard, Settings, XMLHttpRequest, randFloat, randInt */ + +var blockDimensions={ + x:0.12, + y:0.25, + z:0.50 +}; + +var centerPosition = { + x: + y: + z: +}; + + +var sideBlock1_position = { + x: + y: + z: +}; + + + +var sideBlock2_position = { + x: + y: + z: +}; + + +var sideBlock1_rotation = Quat.fromPitchYawRollDegrees(); +var sideBlock2_rotation = Quat.fromPitchYawRollDegrees(); +var topBlock_rotation = Quat.fromPitchYawRollDegrees(); + +var sideBlock1 = Entities.addEntity(); +var sideBlock2 = Entities.addEntity(); +var topBlock = Entities.addEntity(); +var ground = Entities.addEntity(); \ No newline at end of file From 43f69a0be995ace51dfa0440f775b4bfb9dabef5 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Mon, 5 Oct 2015 13:23:19 -0700 Subject: [PATCH 2/6] initial knockover blocks --- examples/toys/createKnockoverBlocks.js | 152 +++++++++++++++++++++---- 1 file changed, 130 insertions(+), 22 deletions(-) diff --git a/examples/toys/createKnockoverBlocks.js b/examples/toys/createKnockoverBlocks.js index b5fe22ca73..417dc6cadd 100644 --- a/examples/toys/createKnockoverBlocks.js +++ b/examples/toys/createKnockoverBlocks.js @@ -1,47 +1,155 @@ // // createKnockoverBlocks.js // +// Script Type: Entity Spawner // Created by James B. Pollack on 9/29/2015 // Copyright 2015 High Fidelity, Inc. // // +// This script creates a 'stonehenge' formation of physical blocks for testing knock over properties. // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html /*global MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, HMD, AvatarList, AvatarManager, Controller, UndoStack, Window, Account, GlobalServices, Script, ScriptDiscoveryService, LODManager, Menu, Vec3, Quat, AudioDevice, Paths, Clipboard, Settings, XMLHttpRequest, randFloat, randInt */ -var blockDimensions={ - x:0.12, - y:0.25, - z:0.50 + +var BLOCK_GRAVITY = { + x: 0, + y: -9.8, + z: 0 +}; + +var LINEAR_DAMPING = 0.2; + +var RED = { + red: 255, + green: 0, + blue: 0 +}; + +var GREEN = { + red: 0, + green: 255, + blue: 0 +}; + +var BLUE = { + red: 0, + green: 0, + blue: 255 +}; + +var blockDimensions = { + x: 0.12, + y: 0.25, + z: 0.50 }; var centerPosition = { - x: - y: - z: + x: 0, + y: 0, + z: 0 }; +var DISTANCE_IN_FRONT_OF_ME = 2.0; +var position = Vec3.sum(MyAvatar.position, + Vec3.multiplyQbyV(MyAvatar.orientation, { + x: 0, + y: 0.0, + z: -DISTANCE_IN_FRONT_OF_ME + })); + +// var position={ +// x:0, +// y:0, +// z:0 +// }; var sideBlock1_position = { - x: - y: - z: + x: position.x, + y: position.y, + z: position.z - 0.25 }; - - var sideBlock2_position = { - x: - y: - z: + x: position.x, + y: position.y, + z: position.z + 0.25 }; +var topBlock_position = { + x: position.x, + y: position.y + 0.31, + z: position.z +}; -var sideBlock1_rotation = Quat.fromPitchYawRollDegrees(); -var sideBlock2_rotation = Quat.fromPitchYawRollDegrees(); -var topBlock_rotation = Quat.fromPitchYawRollDegrees(); +var sideBlock1_rotation = Quat.fromPitchYawRollDegrees(90, 90, 0); +var sideBlock2_rotation = Quat.fromPitchYawRollDegrees(90, 90, 0); +var topBlock_rotation = Quat.fromPitchYawRollDegrees(0, 0, 90); -var sideBlock1 = Entities.addEntity(); -var sideBlock2 = Entities.addEntity(); -var topBlock = Entities.addEntity(); -var ground = Entities.addEntity(); \ No newline at end of file +var topBlock = Entities.addEntity({ + name: 'Top Block', + color: BLUE, + type: 'Box', + shapeType: 'box', + dimensions: blockDimensions, + position: topBlock_position, + rotation: topBlock_rotation, + linearDamping: LINEAR_DAMPING, + gravity: BLOCK_GRAVITY, + collisionsWillMove: true, + velocity: { + x: 0, + y: -0.01, + z: 0 + } +}); + +var sideBlock1 = Entities.addEntity({ + name: 'Top Block', + color: GREEN, + type: 'Box', + shapeType: 'box', + dimensions: blockDimensions, + position: sideBlock1_position, + rotation: sideBlock1_rotation, + linearDamping: LINEAR_DAMPING, + gravity: BLOCK_GRAVITY, + collisionsWillMove: true +}); + +var sideBlock2 = Entities.addEntity({ + name: 'Side Block', + color: GREEN, + type: 'Box', + shapeType: 'box', + dimensions: blockDimensions, + position: sideBlock2_position, + rotation: sideBlock2_rotation, + collsionsWillMove: true, + linearDamping: LINEAR_DAMPING, + gravity: BLOCK_GRAVITY, + collisionsWillMove: true +}); + +var ground = Entities.addEntity({ + type: 'Box', + dimensions: { + x: 2, + y: 0.02, + z: 1 + }, + color: RED, + position: { + x: position.x, + y: position.y - 0.25, + z: position.z + } +}); + +function cleanUp() { + Entities.deleteEntity(ground); + Entities.deleteEntity(topBlock); + Entities.deleteEntity(sideBlock1); + Entities.deleteEntity(sideBlock2); +}; +Script.scriptEnding.connect(cleanUp); \ No newline at end of file From e528125af2d5d96cf60d6b40373a71878842d345 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Mon, 5 Oct 2015 13:38:48 -0700 Subject: [PATCH 3/6] add test blocks for blockers game --- .../createTestBlocks.js} | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) rename examples/toys/{createKnockoverBlocks.js => blockers/createTestBlocks.js} (97%) diff --git a/examples/toys/createKnockoverBlocks.js b/examples/toys/blockers/createTestBlocks.js similarity index 97% rename from examples/toys/createKnockoverBlocks.js rename to examples/toys/blockers/createTestBlocks.js index 417dc6cadd..d119f6d483 100644 --- a/examples/toys/createKnockoverBlocks.js +++ b/examples/toys/blockers/createTestBlocks.js @@ -1,5 +1,5 @@ // -// createKnockoverBlocks.js +// createTestBlocks.js // // Script Type: Entity Spawner // Created by James B. Pollack on 9/29/2015 @@ -7,11 +7,11 @@ // // // This script creates a 'stonehenge' formation of physical blocks for testing knock over properties. -// Distributed under the Apache License, Version 2.0. +// +// Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html /*global MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, HMD, AvatarList, AvatarManager, Controller, UndoStack, Window, Account, GlobalServices, Script, ScriptDiscoveryService, LODManager, Menu, Vec3, Quat, AudioDevice, Paths, Clipboard, Settings, XMLHttpRequest, randFloat, randInt */ - var BLOCK_GRAVITY = { x: 0, y: -9.8, @@ -151,5 +151,6 @@ function cleanUp() { Entities.deleteEntity(topBlock); Entities.deleteEntity(sideBlock1); Entities.deleteEntity(sideBlock2); -}; +} + Script.scriptEnding.connect(cleanUp); \ No newline at end of file From 839301bf05a72600e66dd9a3100e0f320433702a Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Mon, 5 Oct 2015 13:41:20 -0700 Subject: [PATCH 4/6] remove cleanup to make blocks persistent --- examples/toys/blockers/createTestBlocks.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/toys/blockers/createTestBlocks.js b/examples/toys/blockers/createTestBlocks.js index d119f6d483..44a3d7af61 100644 --- a/examples/toys/blockers/createTestBlocks.js +++ b/examples/toys/blockers/createTestBlocks.js @@ -153,4 +153,4 @@ function cleanUp() { Entities.deleteEntity(sideBlock2); } -Script.scriptEnding.connect(cleanUp); \ No newline at end of file +// Script.scriptEnding.connect(cleanUp); \ No newline at end of file From daf97b0b9db549fbbf220e5a3268edd6edc5e56b Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Mon, 5 Oct 2015 14:12:18 -0700 Subject: [PATCH 5/6] header fixes --- examples/toys/blockers/createTestBlocks.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/toys/blockers/createTestBlocks.js b/examples/toys/blockers/createTestBlocks.js index 44a3d7af61..8d2c20c750 100644 --- a/examples/toys/blockers/createTestBlocks.js +++ b/examples/toys/blockers/createTestBlocks.js @@ -2,7 +2,7 @@ // createTestBlocks.js // // Script Type: Entity Spawner -// Created by James B. Pollack on 9/29/2015 +// Created by James B. Pollack on 10/5/2015 // Copyright 2015 High Fidelity, Inc. // // From 1b241ea05e1708ba141ee89db6ac6037cb4b8fbb Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Mon, 5 Oct 2015 18:13:51 -0700 Subject: [PATCH 6/6] Update createTestBlocks.js --- examples/toys/blockers/createTestBlocks.js | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/examples/toys/blockers/createTestBlocks.js b/examples/toys/blockers/createTestBlocks.js index 8d2c20c750..d92d8d2b32 100644 --- a/examples/toys/blockers/createTestBlocks.js +++ b/examples/toys/blockers/createTestBlocks.js @@ -58,12 +58,6 @@ var position = Vec3.sum(MyAvatar.position, z: -DISTANCE_IN_FRONT_OF_ME })); -// var position={ -// x:0, -// y:0, -// z:0 -// }; - var sideBlock1_position = { x: position.x, y: position.y, @@ -145,12 +139,3 @@ var ground = Entities.addEntity({ z: position.z } }); - -function cleanUp() { - Entities.deleteEntity(ground); - Entities.deleteEntity(topBlock); - Entities.deleteEntity(sideBlock1); - Entities.deleteEntity(sideBlock2); -} - -// Script.scriptEnding.connect(cleanUp); \ No newline at end of file