From 0f057d722987180d9a47c6c1373201b0e3325de8 Mon Sep 17 00:00:00 2001 From: EdgarPironti Date: Fri, 6 Nov 2015 18:58:50 -0800 Subject: [PATCH] Set clip for ControlledAC --- examples/acScripts/ControlACs.js | 29 +++++++++++++++++++++++++++-- examples/acScripts/ControlledAC.js | 16 +++++++++++++--- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/examples/acScripts/ControlACs.js b/examples/acScripts/ControlACs.js index 403c0878cb..fb33dd3178 100644 --- a/examples/acScripts/ControlACs.js +++ b/examples/acScripts/ControlACs.js @@ -17,17 +17,21 @@ var NAMES = new Array("Craig", "Clement", "Jeff"); // ACs names ordered by IDs ( // Those variables MUST be common to every scripts var controlEntitySize = 0.25; -var controlEntityPosition = { x: 2000 , y: 0, z: 0 }; +var controlEntityPosition = { x: 0, y: 0, z: 0 }; // Script. DO NOT MODIFY BEYOND THIS LINE. Script.include("../libraries/toolBars.js"); +var filename = null; +var fileloaded = null; + var DO_NOTHING = 0; var PLAY = 1; var PLAY_LOOP = 2; var STOP = 3; var SHOW = 4; var HIDE = 5; +var LOAD = 6; var COLORS = []; COLORS[PLAY] = { red: PLAY, green: 0, blue: 0 }; @@ -35,6 +39,7 @@ COLORS[PLAY_LOOP] = { red: PLAY_LOOP, green: 0, blue: 0 }; COLORS[STOP] = { red: STOP, green: 0, blue: 0 }; COLORS[SHOW] = { red: SHOW, green: 0, blue: 0 }; COLORS[HIDE] = { red: HIDE, green: 0, blue: 0 }; +COLORS[LOAD] = { red: LOAD, green: 0, blue: 0 }; @@ -53,6 +58,7 @@ var onOffIcon = new Array(); var playIcon = new Array(); var playLoopIcon = new Array(); var stopIcon = new Array(); +var loadIcon = new Array(); setupToolBars(); @@ -104,6 +110,14 @@ function setupToolBars() { alpha: ALPHA_OFF, visible: true }, false); + + loadIcon[i] = toolBars[i].addTool({ + imageURL: TOOL_ICON_URL + "recording-upload.svg", + width: Tool.IMAGE_WIDTH, + height: Tool.IMAGE_HEIGHT, + alpha: ALPHA_OFF, + visible: true + }, false); nameOverlays.push(Overlays.addOverlay("text", { backgroundColor: { red: 0, green: 0, blue: 0 }, @@ -129,11 +143,13 @@ function sendCommand(id, action) { toolBars[id].setAlpha(ALPHA_ON, playIcon[id]); toolBars[id].setAlpha(ALPHA_ON, playLoopIcon[id]); toolBars[id].setAlpha(ALPHA_ON, stopIcon[id]); + toolBars[id].setAlpha(ALPHA_ON, loadIcon[id]); } else if (action === HIDE) { toolBars[id].selectTool(onOffIcon[id], true); toolBars[id].setAlpha(ALPHA_OFF, playIcon[id]); toolBars[id].setAlpha(ALPHA_OFF, playLoopIcon[id]); toolBars[id].setAlpha(ALPHA_OFF, stopIcon[id]); + toolBars[id].setAlpha(ALPHA_OFF, loadIcon[id]); } else if (toolBars[id].toolSelected(onOffIcon[id])) { return; } @@ -148,6 +164,7 @@ function sendCommand(id, action) { var position = { x: controlEntityPosition.x + id * controlEntitySize, y: controlEntityPosition.y, z: controlEntityPosition.z }; Entities.addEntity({ + name: filename, type: "Box", position: position, dimensions: { x: controlEntitySize, y: controlEntitySize, z: controlEntitySize }, @@ -173,6 +190,8 @@ function mousePressEvent(event) { sendCommand(i, PLAY_LOOP); } else if (stopIcon[i] === toolBars[i].clicked(clickedOverlay, false)) { sendCommand(i, STOP); + } else if (loadIcon[i] === toolBars[i].clicked(clickedOverlay, false)) { + sendCommand(i, LOAD); } else { // Check individual controls for (i = 0; i < NUM_AC; i++) { @@ -188,6 +207,12 @@ function mousePressEvent(event) { sendCommand(i, PLAY_LOOP); } else if (stopIcon[i] === toolBars[i].clicked(clickedOverlay, false)) { sendCommand(i, STOP); + } else if (loadIcon[i] === toolBars[i].clicked(clickedOverlay, false)) { + fileloaded = Window.browse("Load recording from file", ".", "Recordings (*.hfr *.rec *.HFR *.REC)"); + if (!(fileloaded === "null" || fileloaded === null || fileloaded === "")) { + filename = fileloaded; + sendCommand(i, LOAD); + } } else { } @@ -231,4 +256,4 @@ Controller.mousePressEvent.connect(mousePressEvent); Script.update.connect(update); Script.scriptEnding.connect(scriptEnding); -moveUI(); +moveUI(); \ No newline at end of file diff --git a/examples/acScripts/ControlledAC.js b/examples/acScripts/ControlledAC.js index 93c71aa1a1..25c2ae72d9 100644 --- a/examples/acScripts/ControlledAC.js +++ b/examples/acScripts/ControlledAC.js @@ -22,7 +22,7 @@ var useAvatarModel = true; var id = 0; // Set avatar model URL -Avatar.skeletonModelURL = "https://hifi-public.s3.amazonaws.com/marketplace/contents/e21c0b95-e502-4d15-8c41-ea2fc40f1125/3585ddf674869a67d31d5964f7b52de1.fst?1427169998"; +Avatar.skeletonModelURL = "https://hifi-public.s3.amazonaws.com/marketplace/contents/d029ae8d-2905-4eb7-ba46-4bd1b8cb9d73/4618d52e711fbb34df442b414da767bb.fst?1427170144"; // Set position/orientation/scale here if playFromCurrentLocation is true Avatar.position = { x:1, y: 1, z: 1 }; Avatar.orientation = Quat.fromPitchYawRollDegrees(0, 0, 0); @@ -30,7 +30,7 @@ Avatar.scale = 1.0; // Those variables MUST be common to every scripts var controlEntitySize = 0.25; -var controlEntityPosition = { x: 2000, y: 0, z: 0 }; +var controlEntityPosition = { x: 0, y: 0, z: 0 }; // Script. DO NOT MODIFY BEYOND THIS LINE. var DO_NOTHING = 0; @@ -39,6 +39,7 @@ var PLAY_LOOP = 2; var STOP = 3; var SHOW = 4; var HIDE = 5; +var LOAD = 6; var COLORS = []; COLORS[PLAY] = { red: PLAY, green: 0, blue: 0 }; @@ -46,6 +47,7 @@ COLORS[PLAY_LOOP] = { red: PLAY_LOOP, green: 0, blue: 0 }; COLORS[STOP] = { red: STOP, green: 0, blue: 0 }; COLORS[SHOW] = { red: SHOW, green: 0, blue: 0 }; COLORS[HIDE] = { red: HIDE, green: 0, blue: 0 }; +COLORS[LOAD] = { red: LOAD, green: 0, blue: 0 }; controlEntityPosition.x += id * controlEntitySize; @@ -68,7 +70,9 @@ function setupEntityViewer() { EntityViewer.queryOctree(); } -function getAction(controlEntity) { +function getAction(controlEntity) { + filename = controlEntity.name; + if (controlEntity === null || controlEntity.position.x !== controlEntityPosition.x || controlEntity.position.y !== controlEntityPosition.y || @@ -141,6 +145,12 @@ function update(event) { } Agent.isAvatar = false; break; + case LOAD: + print("Load"); + if(filename !== null) { + Avatar.loadRecording(filename); + } + break; case DO_NOTHING: break; default: