mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 19:59:28 +02:00
Merge pull request #6424 from AlessandroSigna/groupRecording
Group recording - upgraded to the new messages system
This commit is contained in:
commit
b47aadff2b
3 changed files with 36 additions and 73 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
var PARAMS_SCRIPT_URL = Script.resolvePath('recordingEntityScript.js');
|
||||||
var rotation = Quat.safeEulerAngles(Camera.getOrientation());
|
var rotation = Quat.safeEulerAngles(Camera.getOrientation());
|
||||||
rotation = Quat.fromPitchYawRollDegrees(0, rotation.y, 0);
|
rotation = Quat.fromPitchYawRollDegrees(0, rotation.y, 0);
|
||||||
var center = Vec3.sum(MyAvatar.position, Vec3.multiply(6, Quat.getFront(rotation)));
|
var center = Vec3.sum(MyAvatar.position, Vec3.multiply(6, Quat.getFront(rotation)));
|
||||||
|
@ -17,5 +18,6 @@ var recordAreaEntity = Entities.addEntity({
|
||||||
blue: 255
|
blue: 255
|
||||||
},
|
},
|
||||||
visible: true,
|
visible: true,
|
||||||
script: "https://hifi-public.s3.amazonaws.com/sam/record/recordingEntityScript.js",
|
script: PARAMS_SCRIPT_URL,
|
||||||
|
ignoreForCollision: true,
|
||||||
});
|
});
|
|
@ -12,31 +12,25 @@
|
||||||
// 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
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
|
|
||||||
HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
|
|
||||||
Script.include(HIFI_PUBLIC_BUCKET + "scripts/libraries/utils.js");
|
|
||||||
|
|
||||||
var insideRecorderArea = false;
|
|
||||||
var enteredInTime = false;
|
|
||||||
var isAvatarRecording = false;
|
|
||||||
var _this;
|
var _this;
|
||||||
|
var isAvatarRecording = false;
|
||||||
|
var channel = "groupRecordingChannel";
|
||||||
|
var startMessage = "RECONDING STARTED";
|
||||||
|
var stopMessage = "RECONDING ENDED";
|
||||||
|
|
||||||
function recordingEntity() {
|
function recordingEntity() {
|
||||||
_this = this;
|
_this = this;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function update() {
|
function receivingMessage(channel, message, senderID) {
|
||||||
var isRecordingStarted = getEntityCustomData("recordingKey", _this.entityID, { isRecordingStarted: false }).isRecordingStarted;
|
print("message received on channel:" + channel + ", message:" + message + ", senderID:" + senderID);
|
||||||
if (isRecordingStarted && !isAvatarRecording) {
|
if(message === startMessage) {
|
||||||
_this.startRecording();
|
_this.startRecording();
|
||||||
} else if ((!isRecordingStarted && isAvatarRecording) || (isAvatarRecording && !insideRecorderArea)) {
|
} else if(message === stopMessage) {
|
||||||
_this.stopRecording();
|
_this.stopRecording();
|
||||||
} else if (!isRecordingStarted && insideRecorderArea && !enteredInTime) {
|
|
||||||
//if an avatar enters the zone while a recording is started he will be able to participate to the next group recording
|
|
||||||
enteredInTime = true;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -45,37 +39,29 @@
|
||||||
preload: function (entityID) {
|
preload: function (entityID) {
|
||||||
print("RECORDING ENTITY PRELOAD");
|
print("RECORDING ENTITY PRELOAD");
|
||||||
this.entityID = entityID;
|
this.entityID = entityID;
|
||||||
|
|
||||||
var entityProperties = Entities.getEntityProperties(_this.entityID);
|
var entityProperties = Entities.getEntityProperties(_this.entityID);
|
||||||
if (!entityProperties.ignoreForCollisions) {
|
if (!entityProperties.ignoreForCollisions) {
|
||||||
Entities.editEntity(_this.entityID, { ignoreForCollisions: true });
|
Entities.editEntity(_this.entityID, { ignoreForCollisions: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
//print(JSON.stringify(entityProperties));
|
Messages.messageReceived.connect(receivingMessage);
|
||||||
var recordingKey = getEntityCustomData("recordingKey", _this.entityID, undefined);
|
|
||||||
if (recordingKey === undefined) {
|
|
||||||
setEntityCustomData("recordingKey", _this.entityID, { isRecordingStarted: false });
|
|
||||||
}
|
|
||||||
|
|
||||||
Script.update.connect(update);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
enterEntity: function (entityID) {
|
enterEntity: function (entityID) {
|
||||||
print("entering in the recording area");
|
print("entering in the recording area");
|
||||||
insideRecorderArea = true;
|
Messages.subscribe(channel);
|
||||||
var isRecordingStarted = getEntityCustomData("recordingKey", _this.entityID, { isRecordingStarted: false }).isRecordingStarted;
|
|
||||||
if (!isRecordingStarted) {
|
|
||||||
//i'm in the recording area in time (before the event starts)
|
|
||||||
enteredInTime = true;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
leaveEntity: function (entityID) {
|
leaveEntity: function (entityID) {
|
||||||
print("leaving the recording area");
|
print("leaving the recording area");
|
||||||
insideRecorderArea = false;
|
_this.stopRecording();
|
||||||
enteredInTime = false;
|
Messages.unsubscribe(channel);
|
||||||
},
|
},
|
||||||
|
|
||||||
startRecording: function (entityID) {
|
startRecording: function (entityID) {
|
||||||
if (enteredInTime && !isAvatarRecording) {
|
if (!isAvatarRecording) {
|
||||||
print("RECORDING STARTED");
|
print("RECORDING STARTED");
|
||||||
Recording.startRecording();
|
Recording.startRecording();
|
||||||
isAvatarRecording = true;
|
isAvatarRecording = true;
|
||||||
|
@ -86,7 +72,6 @@
|
||||||
if (isAvatarRecording) {
|
if (isAvatarRecording) {
|
||||||
print("RECORDING ENDED");
|
print("RECORDING ENDED");
|
||||||
Recording.stopRecording();
|
Recording.stopRecording();
|
||||||
Recording.loadLastRecording();
|
|
||||||
isAvatarRecording = false;
|
isAvatarRecording = false;
|
||||||
recordingFile = Window.save("Save recording to file", "./groupRecording", "Recordings (*.hfr)");
|
recordingFile = Window.save("Save recording to file", "./groupRecording", "Recordings (*.hfr)");
|
||||||
if (!(recordingFile === "null" || recordingFile === null || recordingFile === "")) {
|
if (!(recordingFile === "null" || recordingFile === null || recordingFile === "")) {
|
||||||
|
@ -94,13 +79,14 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
unload: function (entityID) {
|
unload: function (entityID) {
|
||||||
print("RECORDING ENTITY UNLOAD");
|
print("RECORDING ENTITY UNLOAD");
|
||||||
Script.update.disconnect(update);
|
_this.stopRecording();
|
||||||
|
Messages.unsubscribe(channel);
|
||||||
|
Messages.messageReceived.disconnect(receivingMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return new recordingEntity();
|
return new recordingEntity();
|
||||||
});
|
});
|
|
@ -5,18 +5,15 @@
|
||||||
// Created by Alessandro Signa on 11/12/15.
|
// Created by Alessandro Signa on 11/12/15.
|
||||||
// Copyright 2015 High Fidelity, Inc.
|
// Copyright 2015 High Fidelity, Inc.
|
||||||
//
|
//
|
||||||
// Run this script to find the recorder (created by crateRecorder.js) and drive the start/end of the recording for anyone who is inside the box
|
// Run this script to spawn a box (recorder) and drive the start/end of the recording for anyone who is inside the box
|
||||||
//
|
//
|
||||||
// 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
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
|
||||||
|
|
||||||
HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
|
HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
|
||||||
Script.include(HIFI_PUBLIC_BUCKET + "scripts/libraries/toolBars.js");
|
Script.include(HIFI_PUBLIC_BUCKET + "scripts/libraries/toolBars.js");
|
||||||
Script.include(HIFI_PUBLIC_BUCKET + "scripts/libraries/utils.js");
|
Script.include(HIFI_PUBLIC_BUCKET + "scripts/libraries/utils.js");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var rotation = Quat.safeEulerAngles(Camera.getOrientation());
|
var rotation = Quat.safeEulerAngles(Camera.getOrientation());
|
||||||
rotation = Quat.fromPitchYawRollDegrees(0, rotation.y, 0);
|
rotation = Quat.fromPitchYawRollDegrees(0, rotation.y, 0);
|
||||||
var center = Vec3.sum(MyAvatar.position, Vec3.multiply(1, Quat.getFront(rotation)));
|
var center = Vec3.sum(MyAvatar.position, Vec3.multiply(1, Quat.getFront(rotation)));
|
||||||
|
@ -28,27 +25,9 @@ var COLOR_TOOL_BAR = { red: 0, green: 0, blue: 0 };
|
||||||
|
|
||||||
var toolBar = null;
|
var toolBar = null;
|
||||||
var recordIcon;
|
var recordIcon;
|
||||||
|
|
||||||
var isRecordingEntityFound = false;
|
|
||||||
|
|
||||||
var isRecording = false;
|
var isRecording = false;
|
||||||
|
var channel = "groupRecordingChannel";
|
||||||
var recordAreaEntity = null;
|
Messages.subscribe(channel);
|
||||||
findRecorder();
|
|
||||||
|
|
||||||
function findRecorder() {
|
|
||||||
foundEntities = Entities.findEntities(MyAvatar.position, 50);
|
|
||||||
for (var i = 0; i < foundEntities.length; i++) {
|
|
||||||
var name = Entities.getEntityProperties(foundEntities[i], "name").name;
|
|
||||||
if (name === "recorderEntity") {
|
|
||||||
recordAreaEntity = foundEntities[i];
|
|
||||||
isRecordingEntityFound = true;
|
|
||||||
print("Found recorder Entity!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setupToolBar();
|
setupToolBar();
|
||||||
|
|
||||||
function setupToolBar() {
|
function setupToolBar() {
|
||||||
|
@ -58,9 +37,7 @@ function setupToolBar() {
|
||||||
}
|
}
|
||||||
Tool.IMAGE_HEIGHT /= 2;
|
Tool.IMAGE_HEIGHT /= 2;
|
||||||
Tool.IMAGE_WIDTH /= 2;
|
Tool.IMAGE_WIDTH /= 2;
|
||||||
|
|
||||||
toolBar = new ToolBar(0, 100, ToolBar.HORIZONTAL); //put the button in the up-left corner
|
toolBar = new ToolBar(0, 100, ToolBar.HORIZONTAL); //put the button in the up-left corner
|
||||||
|
|
||||||
toolBar.setBack(COLOR_TOOL_BAR, ALPHA_OFF);
|
toolBar.setBack(COLOR_TOOL_BAR, ALPHA_OFF);
|
||||||
|
|
||||||
recordIcon = toolBar.addTool({
|
recordIcon = toolBar.addTool({
|
||||||
|
@ -70,7 +47,7 @@ function setupToolBar() {
|
||||||
width: Tool.IMAGE_WIDTH,
|
width: Tool.IMAGE_WIDTH,
|
||||||
height: Tool.IMAGE_HEIGHT,
|
height: Tool.IMAGE_HEIGHT,
|
||||||
alpha: Recording.isPlaying() ? ALPHA_OFF : ALPHA_ON,
|
alpha: Recording.isPlaying() ? ALPHA_OFF : ALPHA_ON,
|
||||||
visible: isRecordingEntityFound,
|
visible: true,
|
||||||
}, true, isRecording);
|
}, true, isRecording);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,24 +56,22 @@ function mousePressEvent(event) {
|
||||||
if (recordIcon === toolBar.clicked(clickedOverlay, false)) {
|
if (recordIcon === toolBar.clicked(clickedOverlay, false)) {
|
||||||
if (!isRecording) {
|
if (!isRecording) {
|
||||||
print("I'm the master. I want to start recording");
|
print("I'm the master. I want to start recording");
|
||||||
|
var message = "RECONDING STARTED";
|
||||||
|
Messages.sendMessage(channel, message);
|
||||||
isRecording = true;
|
isRecording = true;
|
||||||
setEntityCustomData("recordingKey", recordAreaEntity, {isRecordingStarted: true});
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
print("I want to stop recording");
|
print("I want to stop recording");
|
||||||
|
var message = "RECONDING ENDED";
|
||||||
|
Messages.sendMessage(channel, message);
|
||||||
isRecording = false;
|
isRecording = false;
|
||||||
setEntityCustomData("recordingKey", recordAreaEntity, {isRecordingStarted: false});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function cleanup() {
|
function cleanup() {
|
||||||
toolBar.cleanup();
|
toolBar.cleanup();
|
||||||
|
Messages.unsubscribe(channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Script.scriptEnding.connect(cleanup);
|
||||||
|
Controller.mousePressEvent.connect(mousePressEvent);
|
||||||
Script.scriptEnding.connect(cleanup);
|
|
||||||
Controller.mousePressEvent.connect(mousePressEvent);
|
|
||||||
|
|
Loading…
Reference in a new issue