From 8f25e54027bfaf9e858b4d131a546b839809189a Mon Sep 17 00:00:00 2001 From: James Pollack Date: Fri, 25 Sep 2015 18:34:34 -0700 Subject: [PATCH 1/6] Hoop, ball, ground --- examples/toys/basketball/createHoop.js | 101 +++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 examples/toys/basketball/createHoop.js diff --git a/examples/toys/basketball/createHoop.js b/examples/toys/basketball/createHoop.js new file mode 100644 index 0000000000..778c73915c --- /dev/null +++ b/examples/toys/basketball/createHoop.js @@ -0,0 +1,101 @@ +// +// createFlashlight.js +// examples/entityScripts +// +// Created by Sam Gateau on 9/9/15. +// Copyright 2015 High Fidelity, Inc. +// +// This is a toy script that create a flashlight entity that lit when grabbed +// This can be run from an interface and the flashlight will get deleted from the domain when quitting +// +// 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 */ +Script.include("../../utilities.js"); +Script.include("../../libraries/utils.js"); + +var groundURL = "https://hifi-public.s3.amazonaws.com/eric/models/woodFloor.fbx"; +var basketballURL = "https://hifi-public.s3.amazonaws.com/models/content/basketball2.fbx"; +var hoopURL = "http://hifi-public.s3.amazonaws.com/models/basketball/new_hoop_2.fbx"; +var hoopCollisionHullURL = "http://hifi-public.s3.amazonaws.com/models/basketball/new_basketball_hoop_collision_hull.obj"; +var ballCollisionSound = "https://hifi-public.s3.amazonaws.com/sounds/basketball/basketball.wav"; + +var basePosition = { + x: 0, + y: 0, + z: 0 +}; + +var hoopStartPosition = { + x: 0, + y: 3.25, + z: 0 +}; + + +var ground = Entities.addEntity({ + type: "Model", + modelURL: groundURL, + dimensions: { + x: 100, + y: 2, + z: 100 + }, + position: basePosition, + shapeType: 'box' +}); + +var BALL_DIAMETER = 0.30; +var DISTANCE_IN_FRONT_OF_ME = 1.0; + +var ballPosition = Vec3.sum(MyAvatar.position, + Vec3.multiplyQbyV(MyAvatar.orientation, { + x: 0, + y: 0.0, + z: -DISTANCE_IN_FRONT_OF_ME + })); + +var ballRotation = Quat.multiply(MyAvatar.orientation, + Quat.fromPitchYawRollDegrees(0, -90, 0)); + +var basketball = Entities.addEntity({ + type: "Model", + position: ballPosition, + rotation: ballRotation, + dimensions: { + x: BALL_DIAMETER, + y: BALL_DIAMETER, + z: BALL_DIAMETER + }, + gravity: { + x: 0, + y: -9.8, + z: 0 + }, + collisionsWillMove: true, + collisionSoundURL: ballCollisionSound, + modelURL: basketballURL, + restitution: 1.0, + linearDamping: 0.00001, + shapeType: "sphere" +}); + + +var hoop = Entities.addEntity({ + type: "Model", + modelURL: hoopURL, + position: hoopStartPosition, + shapeType: 'compound', + gravity: { + x: 0, + y: -9.8, + z: 0 + }, + dimensions: { + x: 1.89, + y: 3.99, + z: 3.79 + }, + compoundShapeURL: hoopCollisionHullURL +}); \ No newline at end of file From ade78fda9ec9e739a2d00e2ee56ecc5add5dbb59 Mon Sep 17 00:00:00 2001 From: James Pollack Date: Mon, 28 Sep 2015 12:24:21 -0700 Subject: [PATCH 2/6] balls --- examples/toys/basketball/createHoop.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/examples/toys/basketball/createHoop.js b/examples/toys/basketball/createHoop.js index 778c73915c..9a80ccaace 100644 --- a/examples/toys/basketball/createHoop.js +++ b/examples/toys/basketball/createHoop.js @@ -17,7 +17,7 @@ Script.include("../../libraries/utils.js"); var groundURL = "https://hifi-public.s3.amazonaws.com/eric/models/woodFloor.fbx"; var basketballURL = "https://hifi-public.s3.amazonaws.com/models/content/basketball2.fbx"; -var hoopURL = "http://hifi-public.s3.amazonaws.com/models/basketball/new_hoop_2.fbx"; +var hoopURL = "http://hifi-public.s3.amazonaws.com/models/basketball/new_hoop_3.fbx"; var hoopCollisionHullURL = "http://hifi-public.s3.amazonaws.com/models/basketball/new_basketball_hoop_collision_hull.obj"; var ballCollisionSound = "https://hifi-public.s3.amazonaws.com/sounds/basketball/basketball.wav"; @@ -98,4 +98,13 @@ var hoop = Entities.addEntity({ z: 3.79 }, compoundShapeURL: hoopCollisionHullURL -}); \ No newline at end of file +}); + + + +function cleanup() { + Entities.deleteEntity(basketball); + Entities.deleteEntity(hoop); + Entities.deleteEntity(ground); +} +Script.scriptEnding.connect(cleanup); \ No newline at end of file From afa179b9c44d06b56782e18f8dd9d9f587e0aa12 Mon Sep 17 00:00:00 2001 From: James Pollack Date: Mon, 28 Sep 2015 15:08:48 -0700 Subject: [PATCH 3/6] hoop --- examples/toys/basketball/createHoop.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/toys/basketball/createHoop.js b/examples/toys/basketball/createHoop.js index 9a80ccaace..a4044d4adf 100644 --- a/examples/toys/basketball/createHoop.js +++ b/examples/toys/basketball/createHoop.js @@ -17,7 +17,7 @@ Script.include("../../libraries/utils.js"); var groundURL = "https://hifi-public.s3.amazonaws.com/eric/models/woodFloor.fbx"; var basketballURL = "https://hifi-public.s3.amazonaws.com/models/content/basketball2.fbx"; -var hoopURL = "http://hifi-public.s3.amazonaws.com/models/basketball/new_hoop_3.fbx"; +var hoopURL = "http://hifi-public.s3.amazonaws.com/models/basketball/basketball_hoop_10.fbx"; var hoopCollisionHullURL = "http://hifi-public.s3.amazonaws.com/models/basketball/new_basketball_hoop_collision_hull.obj"; var ballCollisionSound = "https://hifi-public.s3.amazonaws.com/sounds/basketball/basketball.wav"; From 4c86b1ce03abf3dd92e4c887455f872a3f39ede4 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Mon, 28 Sep 2015 18:47:32 -0700 Subject: [PATCH 4/6] ballin --- examples/toys/basketball/createHoop.js | 59 ++++++++++++++------------ 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/examples/toys/basketball/createHoop.js b/examples/toys/basketball/createHoop.js index 778c73915c..bd3fc32411 100644 --- a/examples/toys/basketball/createHoop.js +++ b/examples/toys/basketball/createHoop.js @@ -15,40 +15,40 @@ Script.include("../../utilities.js"); Script.include("../../libraries/utils.js"); -var groundURL = "https://hifi-public.s3.amazonaws.com/eric/models/woodFloor.fbx"; +var courtURL = "https://hifi-public.s3.amazonaws.com/eric/models/woodFloor.fbx"; var basketballURL = "https://hifi-public.s3.amazonaws.com/models/content/basketball2.fbx"; -var hoopURL = "http://hifi-public.s3.amazonaws.com/models/basketball/new_hoop_2.fbx"; -var hoopCollisionHullURL = "http://hifi-public.s3.amazonaws.com/models/basketball/new_basketball_hoop_collision_hull.obj"; var ballCollisionSound = "https://hifi-public.s3.amazonaws.com/sounds/basketball/basketball.wav"; - -var basePosition = { - x: 0, - y: 0, - z: 0 -}; - -var hoopStartPosition = { - x: 0, - y: 3.25, - z: 0 -}; - - -var ground = Entities.addEntity({ - type: "Model", - modelURL: groundURL, - dimensions: { - x: 100, - y: 2, - z: 100 - }, - position: basePosition, - shapeType: 'box' -}); +var hoopURL = "http://hifi-public.s3.amazonaws.com/models/basketball_hoop/basketball_hoop.fbx"; +var hoopCollisionHullURL = "http://hifi-public.s3.amazonaws.com/models/basketball_hoop/basketball_hoop_collision_hull.obj"; var BALL_DIAMETER = 0.30; var DISTANCE_IN_FRONT_OF_ME = 1.0; +var hoopStartPosition = + Vec3.sum(MyAvatar.position, + Vec3.multiplyQbyV(MyAvatar.orientation, { + x: 0, + y: 0.0, + z: -DISTANCE_IN_FRONT_OF_ME * 2 + })); + +// courtStartPosition.y = hoopStartPosition.y - 2 + + +// var court = Entities.addEntity({ +// type: "Model", +// modelURL: courtURL, +// dimensions: { +// x: 28.65, +// y: 0.02, +// z: 15.24 +// }, +// position: courtStartPosition, +// shapeType: 'box' +// }); + + + var ballPosition = Vec3.sum(MyAvatar.position, Vec3.multiplyQbyV(MyAvatar.orientation, { x: 0, @@ -56,6 +56,8 @@ var ballPosition = Vec3.sum(MyAvatar.position, z: -DISTANCE_IN_FRONT_OF_ME })); + + var ballRotation = Quat.multiply(MyAvatar.orientation, Quat.fromPitchYawRollDegrees(0, -90, 0)); @@ -92,6 +94,7 @@ var hoop = Entities.addEntity({ y: -9.8, z: 0 }, + // rotation: Quat.fromPitchYawRollDegrees(0, -90, 0)), dimensions: { x: 1.89, y: 3.99, From cbd55ddba62cfa4558df3459a9cb9834a55aea18 Mon Sep 17 00:00:00 2001 From: James Pollack Date: Tue, 29 Sep 2015 13:24:49 -0700 Subject: [PATCH 5/6] Add the hoop --- examples/toys/basketball/createHoop.js | 113 -------------------- examples/toys/basketball_hoop/createHoop.js | 49 +++++++++ 2 files changed, 49 insertions(+), 113 deletions(-) delete mode 100644 examples/toys/basketball/createHoop.js create mode 100644 examples/toys/basketball_hoop/createHoop.js diff --git a/examples/toys/basketball/createHoop.js b/examples/toys/basketball/createHoop.js deleted file mode 100644 index 7af54767f3..0000000000 --- a/examples/toys/basketball/createHoop.js +++ /dev/null @@ -1,113 +0,0 @@ -// -// createFlashlight.js -// examples/entityScripts -// -// Created by Sam Gateau on 9/9/15. -// Copyright 2015 High Fidelity, Inc. -// -// This is a toy script that create a flashlight entity that lit when grabbed -// This can be run from an interface and the flashlight will get deleted from the domain when quitting -//a -// 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 */ -Script.include("../../utilities.js"); -Script.include("../../libraries/utils.js"); - -var courtURL = "https://hifi-public.s3.amazonaws.com/eric/models/woodFloor.fbx"; -var basketballURL = "https://hifi-public.s3.amazonaws.com/models/content/basketball2.fbx"; -var ballCollisionSound = "https://hifi-public.s3.amazonaws.com/sounds/basketball/basketball.wav"; -var hoopURL = "http://hifi-public.s3.amazonaws.com/models/basketball_hoop/basketball_hoop.fbx"; -var hoopCollisionHullURL = "http://hifi-public.s3.amazonaws.com/models/basketball_hoop/basketball_hoop_collision_hull.obj"; - -var BALL_DIAMETER = 0.30; -var DISTANCE_IN_FRONT_OF_ME = 1.0; - -var hoopStartPosition = - Vec3.sum(MyAvatar.position, - Vec3.multiplyQbyV(MyAvatar.orientation, { - x: 0, - y: 0.0, - z: -DISTANCE_IN_FRONT_OF_ME * 2 - })); - -// courtStartPosition.y = hoopStartPosition.y - 2 - - -// var court = Entities.addEntity({ -// type: "Model", -// modelURL: courtURL, -// dimensions: { -// x: 28.65, -// y: 0.02, -// z: 15.24 -// }, -// position: courtStartPosition, -// shapeType: 'box' -// }); - - - -var ballPosition = Vec3.sum(MyAvatar.position, - Vec3.multiplyQbyV(MyAvatar.orientation, { - x: 0, - y: 0.0, - z: -DISTANCE_IN_FRONT_OF_ME - })); - - - -var ballRotation = Quat.multiply(MyAvatar.orientation, - Quat.fromPitchYawRollDegrees(0, -90, 0)); - -var basketball = Entities.addEntity({ - type: "Model", - position: ballPosition, - rotation: ballRotation, - dimensions: { - x: BALL_DIAMETER, - y: BALL_DIAMETER, - z: BALL_DIAMETER - }, - gravity: { - x: 0, - y: -9.8, - z: 0 - }, - collisionsWillMove: true, - collisionSoundURL: ballCollisionSound, - modelURL: basketballURL, - restitution: 1.0, - linearDamping: 0.00001, - shapeType: "sphere" -}); - - -var hoop = Entities.addEntity({ - type: "Model", - modelURL: hoopURL, - position: hoopStartPosition, - shapeType: 'compound', - gravity: { - x: 0, - y: -9.8, - z: 0 - }, - // rotation: Quat.fromPitchYawRollDegrees(0, -90, 0)), - dimensions: { - x: 1.89, - y: 3.99, - z: 3.79 - }, - compoundShapeURL: hoopCollisionHullURL -}); - - - -function cleanup() { - Entities.deleteEntity(basketball); - Entities.deleteEntity(hoop); - // Entities.deleteEntity(court); -} -Script.scriptEnding.connect(cleanup); \ No newline at end of file diff --git a/examples/toys/basketball_hoop/createHoop.js b/examples/toys/basketball_hoop/createHoop.js new file mode 100644 index 0000000000..26fb7347d1 --- /dev/null +++ b/examples/toys/basketball_hoop/createHoop.js @@ -0,0 +1,49 @@ +// +// createHoop.js +// examples/entityScripts +// +// Created by James B. Pollack on 9/29/2015 +// Copyright 2015 High Fidelity, Inc. +// +// This is a script that creates a persistent basketball hoop with a working collision hull. Feel free to move it. +// Run basketball.js to make a basketball. +// +// 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 */ +Script.include("../../utilities.js"); +Script.include("../../libraries/utils.js"); + +var hoopURL = "http://hifi-public.s3.amazonaws.com/models/basketball_hoop/basketball_hoop.fbx"; +var hoopCollisionHullURL = "http://hifi-public.s3.amazonaws.com/models/basketball_hoop/basketball_hoop_collision_hull.obj"; + + +var DISTANCE_IN_FRONT_OF_ME = 1.0; + +var hoopStartPosition = + Vec3.sum(MyAvatar.position, + Vec3.multiplyQbyV(MyAvatar.orientation, { + x: 0, + y: 0.0, + z: -DISTANCE_IN_FRONT_OF_ME * 2 + })); + + +var hoop = Entities.addEntity({ + type: "Model", + modelURL: hoopURL, + position: hoopStartPosition, + shapeType: 'compound', + gravity: { + x: 0, + y: -9.8, + z: 0 + }, + dimensions: { + x: 1.89, + y: 3.99, + z: 3.79 + }, + compoundShapeURL: hoopCollisionHullURL +}); \ No newline at end of file From b9a83be4d33f8ddc1d1e4dacde414467acce0c2f Mon Sep 17 00:00:00 2001 From: James Pollack Date: Tue, 29 Sep 2015 14:31:13 -0700 Subject: [PATCH 6/6] cleanup --- examples/toys/basketball_hoop/createHoop.js | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/examples/toys/basketball_hoop/createHoop.js b/examples/toys/basketball_hoop/createHoop.js index 26fb7347d1..3887e0b421 100644 --- a/examples/toys/basketball_hoop/createHoop.js +++ b/examples/toys/basketball_hoop/createHoop.js @@ -10,26 +10,19 @@ // // 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 */ -Script.include("../../utilities.js"); -Script.include("../../libraries/utils.js"); var hoopURL = "http://hifi-public.s3.amazonaws.com/models/basketball_hoop/basketball_hoop.fbx"; var hoopCollisionHullURL = "http://hifi-public.s3.amazonaws.com/models/basketball_hoop/basketball_hoop_collision_hull.obj"; - -var DISTANCE_IN_FRONT_OF_ME = 1.0; - var hoopStartPosition = Vec3.sum(MyAvatar.position, Vec3.multiplyQbyV(MyAvatar.orientation, { x: 0, y: 0.0, - z: -DISTANCE_IN_FRONT_OF_ME * 2 + z: -2 })); - var hoop = Entities.addEntity({ type: "Model", modelURL: hoopURL, @@ -46,4 +39,5 @@ var hoop = Entities.addEntity({ z: 3.79 }, compoundShapeURL: hoopCollisionHullURL -}); \ No newline at end of file +}); +