mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 08:21:24 +02:00
Fix recording scripts
This commit is contained in:
parent
c6c578e48c
commit
07b3597ae3
6 changed files with 146 additions and 144 deletions
|
@ -16,11 +16,11 @@ var NUM_AC = 3; // This is the number of AC. Their ID need to be unique and betw
|
||||||
var NAMES = new Array("Craig", "Clement", "Jeff"); // ACs names ordered by IDs (Default name is "ACx", x = ID + 1))
|
var NAMES = new Array("Craig", "Clement", "Jeff"); // ACs names ordered by IDs (Default name is "ACx", x = ID + 1))
|
||||||
|
|
||||||
// Those variables MUST be common to every scripts
|
// Those variables MUST be common to every scripts
|
||||||
var controlVoxelSize = 0.25;
|
var controlEntitySize = 0.25;
|
||||||
var controlVoxelPosition = { x: 2000 , y: 0, z: 0 };
|
var controlEntityPosition = { x: 2000 , 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 DO_NOTHING = 0;
|
var DO_NOTHING = 0;
|
||||||
var PLAY = 1;
|
var PLAY = 1;
|
||||||
|
@ -138,16 +138,22 @@ function sendCommand(id, action) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id === toolBars.length - 1) {
|
if (id === (toolBars.length - 1)) {
|
||||||
for (i = 0; i < NUM_AC; i++) {
|
for (i = 0; i < NUM_AC; i++) {
|
||||||
sendCommand(i, action);
|
sendCommand(i, action);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Fix this to use some mechanism other than voxels
|
var position = { x: controlEntityPosition.x + id * controlEntitySize,
|
||||||
//Voxels.setVoxel(controlVoxelPosition.x + id * controlVoxelSize, controlVoxelPosition.y, controlVoxelPosition.z,
|
y: controlEntityPosition.y, z: controlEntityPosition.z };
|
||||||
// controlVoxelSize, COLORS[action].red, COLORS[action].green, COLORS[action].blue);
|
Entities.addEntity({
|
||||||
|
type: "Box",
|
||||||
|
position: position,
|
||||||
|
dimensions: { x: controlEntitySize, y: controlEntitySize, z: controlEntitySize },
|
||||||
|
color: COLORS[action],
|
||||||
|
lifetime: 5
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function mousePressEvent(event) {
|
function mousePressEvent(event) {
|
||||||
|
|
|
@ -12,27 +12,25 @@
|
||||||
HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
|
HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
|
||||||
|
|
||||||
// Set the following variables to the values needed
|
// Set the following variables to the values needed
|
||||||
var filename = HIFI_PUBLIC_BUCKET + "ozan/bartender.rec";
|
var filename = "/Users/clement/Desktop/recording.hfr";
|
||||||
var playFromCurrentLocation = true;
|
var playFromCurrentLocation = true;
|
||||||
var useDisplayName = true;
|
var useDisplayName = true;
|
||||||
var useAttachments = true;
|
var useAttachments = true;
|
||||||
var useHeadModel = true;
|
var useAvatarModel = true;
|
||||||
var useSkeletonModel = true;
|
|
||||||
|
|
||||||
// ID of the agent. Two agents can't have the same ID.
|
// ID of the agent. Two agents can't have the same ID.
|
||||||
var id = 0;
|
var id = 0;
|
||||||
|
|
||||||
// Set head and skeleton models
|
// Set avatar model URL
|
||||||
Avatar.faceModelURL = "http://public.highfidelity.io/models/heads/EvilPhilip_v7.fst";
|
Avatar.skeletonModelURL = "https://hifi-public.s3.amazonaws.com/marketplace/contents/e21c0b95-e502-4d15-8c41-ea2fc40f1125/3585ddf674869a67d31d5964f7b52de1.fst?1427169998";
|
||||||
Avatar.skeletonModelURL = "http://public.highfidelity.io/models/skeletons/Philip_Carl_Body_A-Pose.fst";
|
|
||||||
// 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);
|
||||||
Avatar.scale = 1.0;
|
Avatar.scale = 1.0;
|
||||||
|
|
||||||
// Those variables MUST be common to every scripts
|
// Those variables MUST be common to every scripts
|
||||||
var controlVoxelSize = 0.25;
|
var controlEntitySize = 0.25;
|
||||||
var controlVoxelPosition = { x: 2000 , y: 0, z: 0 };
|
var controlEntityPosition = { x: 2000, 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;
|
||||||
|
@ -49,113 +47,111 @@ 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 };
|
||||||
|
|
||||||
controlVoxelPosition.x += id * controlVoxelSize;
|
controlEntityPosition.x += id * controlEntitySize;
|
||||||
|
|
||||||
Avatar.loadRecording(filename);
|
Avatar.loadRecording(filename);
|
||||||
|
|
||||||
Avatar.setPlayFromCurrentLocation(playFromCurrentLocation);
|
Avatar.setPlayFromCurrentLocation(playFromCurrentLocation);
|
||||||
Avatar.setPlayerUseDisplayName(useDisplayName);
|
Avatar.setPlayerUseDisplayName(useDisplayName);
|
||||||
Avatar.setPlayerUseAttachments(useAttachments);
|
Avatar.setPlayerUseAttachments(useAttachments);
|
||||||
Avatar.setPlayerUseHeadModel(useHeadModel);
|
Avatar.setPlayerUseHeadModel(false);
|
||||||
Avatar.setPlayerUseSkeletonModel(useSkeletonModel);
|
Avatar.setPlayerUseSkeletonModel(useAvatarModel);
|
||||||
|
|
||||||
function setupVoxelViewer() {
|
function setupEntityViewer() {
|
||||||
var voxelViewerOffset = 10;
|
var entityViewerOffset = 10;
|
||||||
var voxelViewerPosition = JSON.parse(JSON.stringify(controlVoxelPosition));
|
var entityViewerPosition = { x: controlEntityPosition.x - entityViewerOffset,
|
||||||
voxelViewerPosition.x -= voxelViewerOffset;
|
y: controlEntityPosition.y, z: controlEntityPosition.z };
|
||||||
var voxelViewerOrientation = Quat.fromPitchYawRollDegrees(0, -90, 0);
|
var entityViewerOrientation = Quat.fromPitchYawRollDegrees(0, -90, 0);
|
||||||
|
|
||||||
VoxelViewer.setPosition(voxelViewerPosition);
|
EntityViewer.setPosition(entityViewerPosition);
|
||||||
VoxelViewer.setOrientation(voxelViewerOrientation);
|
EntityViewer.setOrientation(entityViewerOrientation);
|
||||||
VoxelViewer.queryOctree();
|
EntityViewer.queryOctree();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAction(controlVoxel) {
|
function getAction(controlEntity) {
|
||||||
if (controlVoxel.x != controlVoxelPosition.x ||
|
if (controlEntity === null ||
|
||||||
controlVoxel.y != controlVoxelPosition.y ||
|
controlEntity.position.x !== controlEntityPosition.x ||
|
||||||
controlVoxel.z != controlVoxelPosition.z ||
|
controlEntity.position.y !== controlEntityPosition.y ||
|
||||||
controlVoxel.s != controlVoxelSize) {
|
controlEntity.position.z !== controlEntityPosition.z ||
|
||||||
return DO_NOTHING;
|
controlEntity.dimensions.x !== controlEntitySize) {
|
||||||
}
|
return DO_NOTHING;
|
||||||
|
|
||||||
for (i in COLORS) {
|
|
||||||
if (controlVoxel.red === COLORS[i].red &&
|
|
||||||
controlVoxel.green === COLORS[i].green &&
|
|
||||||
controlVoxel.blue === COLORS[i].blue) {
|
|
||||||
|
|
||||||
// TODO: Fix this to use some mechanism other than voxels
|
|
||||||
//Voxels.eraseVoxel(controlVoxelPosition.x, controlVoxelPosition.y, controlVoxelPosition.z, controlVoxelSize);
|
|
||||||
return parseInt(i);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
for (i in COLORS) {
|
||||||
return DO_NOTHING;
|
if (controlEntity.color.red === COLORS[i].red &&
|
||||||
|
controlEntity.color.green === COLORS[i].green &&
|
||||||
|
controlEntity.color.blue === COLORS[i].blue) {
|
||||||
|
Entities.deleteEntity(controlEntity.id);
|
||||||
|
return parseInt(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return DO_NOTHING;
|
||||||
}
|
}
|
||||||
|
|
||||||
count = 300; // This is necessary to wait for the audio mixer to connect
|
count = 100; // This is necessary to wait for the audio mixer to connect
|
||||||
function update(event) {
|
function update(event) {
|
||||||
VoxelViewer.queryOctree();
|
EntityViewer.queryOctree();
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
count--;
|
count--;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Fix this to use some mechanism other than voxels
|
|
||||||
// Voxels.getVoxelAt(controlVoxelPosition.x, controlVoxelPosition.y, controlVoxelPosition.z, controlVoxelSize);
|
var controlEntity = Entities.findClosestEntity(controlEntityPosition, controlEntitySize);
|
||||||
var controlVoxel = false;
|
var action = getAction(Entities.getEntityProperties(controlEntity));
|
||||||
var action = getAction(controlVoxel);
|
|
||||||
|
switch(action) {
|
||||||
switch(action) {
|
case PLAY:
|
||||||
case PLAY:
|
print("Play");
|
||||||
print("Play");
|
if (!Agent.isAvatar) {
|
||||||
if (!Agent.isAvatar) {
|
Agent.isAvatar = true;
|
||||||
Agent.isAvatar = true;
|
}
|
||||||
}
|
if (!Avatar.isPlaying()) {
|
||||||
if (!Avatar.isPlaying()) {
|
Avatar.startPlaying();
|
||||||
Avatar.startPlaying();
|
}
|
||||||
}
|
Avatar.setPlayerLoop(false);
|
||||||
Avatar.setPlayerLoop(false);
|
break;
|
||||||
break;
|
case PLAY_LOOP:
|
||||||
case PLAY_LOOP:
|
print("Play loop");
|
||||||
print("Play loop");
|
if (!Agent.isAvatar) {
|
||||||
if (!Agent.isAvatar) {
|
Agent.isAvatar = true;
|
||||||
Agent.isAvatar = true;
|
}
|
||||||
}
|
if (!Avatar.isPlaying()) {
|
||||||
if (!Avatar.isPlaying()) {
|
Avatar.startPlaying();
|
||||||
Avatar.startPlaying();
|
}
|
||||||
}
|
Avatar.setPlayerLoop(true);
|
||||||
Avatar.setPlayerLoop(true);
|
break;
|
||||||
break;
|
case STOP:
|
||||||
case STOP:
|
print("Stop");
|
||||||
print("Stop");
|
if (Avatar.isPlaying()) {
|
||||||
if (Avatar.isPlaying()) {
|
Avatar.stopPlaying();
|
||||||
Avatar.stopPlaying();
|
}
|
||||||
}
|
break;
|
||||||
break;
|
case SHOW:
|
||||||
case SHOW:
|
print("Show");
|
||||||
print("Show");
|
if (!Agent.isAvatar) {
|
||||||
if (!Agent.isAvatar) {
|
Agent.isAvatar = true;
|
||||||
Agent.isAvatar = true;
|
}
|
||||||
}
|
break;
|
||||||
break;
|
case HIDE:
|
||||||
case HIDE:
|
print("Hide");
|
||||||
print("Hide");
|
if (Avatar.isPlaying()) {
|
||||||
if (Avatar.isPlaying()) {
|
Avatar.stopPlaying();
|
||||||
Avatar.stopPlaying();
|
}
|
||||||
}
|
Agent.isAvatar = false;
|
||||||
Agent.isAvatar = false;
|
break;
|
||||||
break;
|
case DO_NOTHING:
|
||||||
case DO_NOTHING:
|
break;
|
||||||
break;
|
default:
|
||||||
default:
|
print("Unknown action: " + action);
|
||||||
print("Unknown action: " + action);
|
break;
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
|
if (Avatar.isPlaying()) {
|
||||||
if (Avatar.isPlaying()) {
|
Avatar.play();
|
||||||
Avatar.play();
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Script.update.connect(update);
|
Script.update.connect(update);
|
||||||
setupVoxelViewer();
|
setupEntityViewer();
|
||||||
|
|
|
@ -14,8 +14,7 @@ var filename = "http://your.recording.url";
|
||||||
var playFromCurrentLocation = true;
|
var playFromCurrentLocation = true;
|
||||||
var loop = true;
|
var loop = true;
|
||||||
|
|
||||||
Avatar.faceModelURL = "http://public.highfidelity.io/models/heads/EvilPhilip_v7.fst";
|
Avatar.skeletonModelURL = "https://hifi-public.s3.amazonaws.com/marketplace/contents/e21c0b95-e502-4d15-8c41-ea2fc40f1125/3585ddf674869a67d31d5964f7b52de1.fst?1427169998";
|
||||||
Avatar.skeletonModelURL = "http://public.highfidelity.io/models/skeletons/Philip_Carl_Body_A-Pose.fst";
|
|
||||||
|
|
||||||
// Set position here if playFromCurrentLocation is true
|
// Set position here if playFromCurrentLocation is true
|
||||||
Avatar.position = { x:1, y: 1, z: 1 };
|
Avatar.position = { x:1, y: 1, z: 1 };
|
||||||
|
@ -23,30 +22,34 @@ Avatar.orientation = Quat.fromPitchYawRollDegrees(0, 0, 0);
|
||||||
Avatar.scale = 1.0;
|
Avatar.scale = 1.0;
|
||||||
|
|
||||||
Agent.isAvatar = true;
|
Agent.isAvatar = true;
|
||||||
|
|
||||||
Avatar.loadRecording(filename);
|
Avatar.loadRecording(filename);
|
||||||
|
|
||||||
count = 300; // This is necessary to wait for the audio mixer to connect
|
count = 300; // This is necessary to wait for the audio mixer to connect
|
||||||
function update(event) {
|
function update(event) {
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
count--;
|
count--;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
Avatar.setPlayFromCurrentLocation(playFromCurrentLocation);
|
Avatar.setPlayFromCurrentLocation(playFromCurrentLocation);
|
||||||
Avatar.setPlayerLoop(loop);
|
Avatar.setPlayerLoop(loop);
|
||||||
Avatar.startPlaying();
|
Avatar.setPlayerUseDisplayName(true);
|
||||||
Avatar.play();
|
Avatar.setPlayerUseAttachments(true);
|
||||||
Vec3.print("Playing from ", Avatar.position);
|
Avatar.setPlayerUseHeadModel(false);
|
||||||
|
Avatar.setPlayerUseSkeletonModel(true);
|
||||||
count--;
|
Avatar.startPlaying();
|
||||||
}
|
Avatar.play();
|
||||||
|
Vec3.print("Playing from ", Avatar.position);
|
||||||
if (Avatar.isPlaying()) {
|
|
||||||
Avatar.play();
|
count--;
|
||||||
} else {
|
}
|
||||||
Script.update.disconnect(update);
|
|
||||||
}
|
if (Avatar.isPlaying()) {
|
||||||
|
Avatar.play();
|
||||||
|
} else {
|
||||||
|
Script.update.disconnect(update);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Script.update.connect(update);
|
Script.update.connect(update);
|
||||||
|
|
|
@ -112,10 +112,9 @@ function setupTimer() {
|
||||||
text: (0.00).toFixed(3),
|
text: (0.00).toFixed(3),
|
||||||
backgroundColor: COLOR_OFF,
|
backgroundColor: COLOR_OFF,
|
||||||
x: 0, y: 0,
|
x: 0, y: 0,
|
||||||
width: 0,
|
width: 0, height: 0,
|
||||||
height: 0,
|
leftMargin: 10, topMargin: 10,
|
||||||
alpha: 1.0,
|
alpha: 1.0, backgroundAlpha: 1.0,
|
||||||
backgroundAlpha: 1.0,
|
|
||||||
visible: true
|
visible: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -397,16 +397,15 @@ bool Player::computeCurrentFrame() {
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 elapsed = glm::clamp(Player::elapsed() - _audioOffset, (qint64)0, (qint64)_recording->getLength());
|
qint64 elapsed = glm::clamp(Player::elapsed() - _audioOffset, (qint64)0, (qint64)_recording->getLength());
|
||||||
while(_currentFrame >= 0 &&
|
|
||||||
_recording->getFrameTimestamp(_currentFrame) > elapsed) {
|
|
||||||
--_currentFrame;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (_currentFrame < _recording->getFrameNumber() &&
|
while (_currentFrame < _recording->getFrameNumber() &&
|
||||||
_recording->getFrameTimestamp(_currentFrame) < elapsed) {
|
_recording->getFrameTimestamp(_currentFrame) < elapsed) {
|
||||||
++_currentFrame;
|
++_currentFrame;
|
||||||
}
|
}
|
||||||
--_currentFrame;
|
|
||||||
|
while(_currentFrame > 0 &&
|
||||||
|
_recording->getFrameTimestamp(_currentFrame) > elapsed) {
|
||||||
|
--_currentFrame;
|
||||||
|
}
|
||||||
|
|
||||||
if (_currentFrame == _recording->getFrameNumber() - 1) {
|
if (_currentFrame == _recording->getFrameNumber() - 1) {
|
||||||
--_currentFrame;
|
--_currentFrame;
|
||||||
|
|
|
@ -43,7 +43,6 @@ public slots:
|
||||||
void record();
|
void record();
|
||||||
void recordAudio(const QByteArray& audioArray);
|
void recordAudio(const QByteArray& audioArray);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QElapsedTimer _timer;
|
QElapsedTimer _timer;
|
||||||
RecordingPointer _recording;
|
RecordingPointer _recording;
|
||||||
|
|
Loading…
Reference in a new issue