Set clip for ControlledAC

This commit is contained in:
EdgarPironti 2015-11-06 18:58:50 -08:00
parent 0402933c51
commit 0f057d7229
2 changed files with 40 additions and 5 deletions

View file

@ -17,17 +17,21 @@ var NAMES = new Array("Craig", "Clement", "Jeff"); // ACs names ordered by IDs (
// Those variables MUST be common to every scripts // Those variables MUST be common to every scripts
var controlEntitySize = 0.25; 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. DO NOT MODIFY BEYOND THIS LINE.
Script.include("../libraries/toolBars.js"); Script.include("../libraries/toolBars.js");
var filename = null;
var fileloaded = null;
var DO_NOTHING = 0; var DO_NOTHING = 0;
var PLAY = 1; var PLAY = 1;
var PLAY_LOOP = 2; var PLAY_LOOP = 2;
var STOP = 3; var STOP = 3;
var SHOW = 4; var SHOW = 4;
var HIDE = 5; var HIDE = 5;
var LOAD = 6;
var COLORS = []; var COLORS = [];
COLORS[PLAY] = { red: PLAY, green: 0, blue: 0 }; 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[STOP] = { red: STOP, green: 0, blue: 0 };
COLORS[SHOW] = { red: SHOW, green: 0, blue: 0 }; COLORS[SHOW] = { red: SHOW, green: 0, blue: 0 };
COLORS[HIDE] = { red: HIDE, 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 playIcon = new Array();
var playLoopIcon = new Array(); var playLoopIcon = new Array();
var stopIcon = new Array(); var stopIcon = new Array();
var loadIcon = new Array();
setupToolBars(); setupToolBars();
@ -104,6 +110,14 @@ function setupToolBars() {
alpha: ALPHA_OFF, alpha: ALPHA_OFF,
visible: true visible: true
}, false); }, 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", { nameOverlays.push(Overlays.addOverlay("text", {
backgroundColor: { red: 0, green: 0, blue: 0 }, 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, playIcon[id]);
toolBars[id].setAlpha(ALPHA_ON, playLoopIcon[id]); toolBars[id].setAlpha(ALPHA_ON, playLoopIcon[id]);
toolBars[id].setAlpha(ALPHA_ON, stopIcon[id]); toolBars[id].setAlpha(ALPHA_ON, stopIcon[id]);
toolBars[id].setAlpha(ALPHA_ON, loadIcon[id]);
} else if (action === HIDE) { } else if (action === HIDE) {
toolBars[id].selectTool(onOffIcon[id], true); toolBars[id].selectTool(onOffIcon[id], true);
toolBars[id].setAlpha(ALPHA_OFF, playIcon[id]); toolBars[id].setAlpha(ALPHA_OFF, playIcon[id]);
toolBars[id].setAlpha(ALPHA_OFF, playLoopIcon[id]); toolBars[id].setAlpha(ALPHA_OFF, playLoopIcon[id]);
toolBars[id].setAlpha(ALPHA_OFF, stopIcon[id]); toolBars[id].setAlpha(ALPHA_OFF, stopIcon[id]);
toolBars[id].setAlpha(ALPHA_OFF, loadIcon[id]);
} else if (toolBars[id].toolSelected(onOffIcon[id])) { } else if (toolBars[id].toolSelected(onOffIcon[id])) {
return; return;
} }
@ -148,6 +164,7 @@ function sendCommand(id, action) {
var position = { x: controlEntityPosition.x + id * controlEntitySize, var position = { x: controlEntityPosition.x + id * controlEntitySize,
y: controlEntityPosition.y, z: controlEntityPosition.z }; y: controlEntityPosition.y, z: controlEntityPosition.z };
Entities.addEntity({ Entities.addEntity({
name: filename,
type: "Box", type: "Box",
position: position, position: position,
dimensions: { x: controlEntitySize, y: controlEntitySize, z: controlEntitySize }, dimensions: { x: controlEntitySize, y: controlEntitySize, z: controlEntitySize },
@ -173,6 +190,8 @@ function mousePressEvent(event) {
sendCommand(i, PLAY_LOOP); sendCommand(i, PLAY_LOOP);
} else if (stopIcon[i] === toolBars[i].clicked(clickedOverlay, false)) { } else if (stopIcon[i] === toolBars[i].clicked(clickedOverlay, false)) {
sendCommand(i, STOP); sendCommand(i, STOP);
} else if (loadIcon[i] === toolBars[i].clicked(clickedOverlay, false)) {
sendCommand(i, LOAD);
} else { } else {
// Check individual controls // Check individual controls
for (i = 0; i < NUM_AC; i++) { for (i = 0; i < NUM_AC; i++) {
@ -188,6 +207,12 @@ function mousePressEvent(event) {
sendCommand(i, PLAY_LOOP); sendCommand(i, PLAY_LOOP);
} else if (stopIcon[i] === toolBars[i].clicked(clickedOverlay, false)) { } else if (stopIcon[i] === toolBars[i].clicked(clickedOverlay, false)) {
sendCommand(i, STOP); 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 { } else {
} }
@ -231,4 +256,4 @@ Controller.mousePressEvent.connect(mousePressEvent);
Script.update.connect(update); Script.update.connect(update);
Script.scriptEnding.connect(scriptEnding); Script.scriptEnding.connect(scriptEnding);
moveUI(); moveUI();

View file

@ -22,7 +22,7 @@ var useAvatarModel = true;
var id = 0; var id = 0;
// Set avatar model URL // 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 // Set position/orientation/scale here if playFromCurrentLocation is true
Avatar.position = { x:1, y: 1, z: 1 }; Avatar.position = { x:1, y: 1, z: 1 };
Avatar.orientation = Quat.fromPitchYawRollDegrees(0, 0, 0); Avatar.orientation = Quat.fromPitchYawRollDegrees(0, 0, 0);
@ -30,7 +30,7 @@ Avatar.scale = 1.0;
// Those variables MUST be common to every scripts // Those variables MUST be common to every scripts
var controlEntitySize = 0.25; 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. DO NOT MODIFY BEYOND THIS LINE.
var DO_NOTHING = 0; var DO_NOTHING = 0;
@ -39,6 +39,7 @@ var PLAY_LOOP = 2;
var STOP = 3; var STOP = 3;
var SHOW = 4; var SHOW = 4;
var HIDE = 5; var HIDE = 5;
var LOAD = 6;
var COLORS = []; var COLORS = [];
COLORS[PLAY] = { red: PLAY, green: 0, blue: 0 }; 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[STOP] = { red: STOP, green: 0, blue: 0 };
COLORS[SHOW] = { red: SHOW, green: 0, blue: 0 }; COLORS[SHOW] = { red: SHOW, green: 0, blue: 0 };
COLORS[HIDE] = { red: HIDE, green: 0, blue: 0 }; COLORS[HIDE] = { red: HIDE, green: 0, blue: 0 };
COLORS[LOAD] = { red: LOAD, green: 0, blue: 0 };
controlEntityPosition.x += id * controlEntitySize; controlEntityPosition.x += id * controlEntitySize;
@ -68,7 +70,9 @@ function setupEntityViewer() {
EntityViewer.queryOctree(); EntityViewer.queryOctree();
} }
function getAction(controlEntity) { function getAction(controlEntity) {
filename = controlEntity.name;
if (controlEntity === null || if (controlEntity === null ||
controlEntity.position.x !== controlEntityPosition.x || controlEntity.position.x !== controlEntityPosition.x ||
controlEntity.position.y !== controlEntityPosition.y || controlEntity.position.y !== controlEntityPosition.y ||
@ -141,6 +145,12 @@ function update(event) {
} }
Agent.isAvatar = false; Agent.isAvatar = false;
break; break;
case LOAD:
print("Load");
if(filename !== null) {
Avatar.loadRecording(filename);
}
break;
case DO_NOTHING: case DO_NOTHING:
break; break;
default: default: