Merge branch 'master' of github.com:highfidelity/hifi into model-scripting-1

This commit is contained in:
Seth Alves 2017-03-16 09:38:56 -07:00
commit a3fadbc367
5 changed files with 64 additions and 46 deletions

View file

@ -154,9 +154,12 @@ MyAvatar::MyAvatar(RigPointer rig) :
if (recordingInterface->getPlayFromCurrentLocation()) {
setRecordingBasis();
}
_wasCharacterControllerEnabled = _characterController.isEnabled();
_characterController.setEnabled(false);
} else {
clearRecordingBasis();
useFullAvatarURL(_fullAvatarURLFromPreferences, _fullAvatarModelName);
_characterController.setEnabled(_wasCharacterControllerEnabled);
}
auto audioIO = DependencyManager::get<AudioClient>();

View file

@ -411,6 +411,7 @@ private:
SharedSoundPointer _collisionSound;
MyCharacterController _characterController;
bool _wasCharacterControllerEnabled { true };
AvatarWeakPointer _lookAtTargetAvatar;
glm::vec3 _targetAvatarPosition;

View file

@ -33,6 +33,7 @@ void Deck::queueClip(ClipPointer clip, float timeOffset) {
// FIXME disabling multiple clips for now
_clips.clear();
_length = 0.0f;
// if the time offset is not zero, wrap in an OffsetClip
if (timeOffset != 0.0f) {
@ -153,8 +154,8 @@ void Deck::processFrames() {
// if doing relative movement
emit looped();
} else {
// otherwise pause playback
pause();
// otherwise stop playback
stop();
}
return;
}

View file

@ -9,12 +9,14 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
/* globals HIFI_PUBLIC_BUCKET:true, Tool, ToolBar */
HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
Script.include("/~/system/libraries/toolBars.js");
var recordingFile = "recording.hfr";
function setPlayerOptions() {
function setDefaultPlayerOptions() {
Recording.setPlayFromCurrentLocation(true);
Recording.setPlayerUseDisplayName(false);
Recording.setPlayerUseAttachments(false);
@ -38,16 +40,16 @@ var saveIcon;
var loadIcon;
var spacing;
var timerOffset;
setupToolBar();
var timer = null;
var slider = null;
setupToolBar();
setupTimer();
var watchStop = false;
function setupToolBar() {
if (toolBar != null) {
if (toolBar !== null) {
print("Multiple calls to Recorder.js:setupToolBar()");
return;
}
@ -56,6 +58,8 @@ function setupToolBar() {
toolBar = new ToolBar(0, 0, ToolBar.HORIZONTAL);
toolBar.onMove = onToolbarMove;
toolBar.setBack(COLOR_TOOL_BAR, ALPHA_OFF);
recordIcon = toolBar.addTool({
@ -86,7 +90,7 @@ function setupToolBar() {
visible: true
}, false);
timerOffset = toolBar.width;
timerOffset = toolBar.width + ToolBar.SPACING;
spacing = toolBar.addSpacing(0);
saveIcon = toolBar.addTool({
@ -112,15 +116,15 @@ function setupTimer() {
text: (0.00).toFixed(3),
backgroundColor: COLOR_OFF,
x: 0, y: 0,
width: 0, height: 0,
leftMargin: 10, topMargin: 10,
width: 200, height: 25,
leftMargin: 5, topMargin: 3,
alpha: 1.0, backgroundAlpha: 1.0,
visible: true
});
slider = { x: 0, y: 0,
w: 200, h: 20,
pos: 0.0, // 0.0 <= pos <= 1.0
pos: 0.0 // 0.0 <= pos <= 1.0
};
slider.background = Overlays.addOverlay("text", {
text: "",
@ -144,20 +148,40 @@ function setupTimer() {
});
}
function onToolbarMove(newX, newY, deltaX, deltaY) {
Overlays.editOverlay(timer, {
x: newX + timerOffset - ToolBar.SPACING,
y: newY
});
slider.x = newX - ToolBar.SPACING;
slider.y = newY - slider.h - ToolBar.SPACING;
Overlays.editOverlay(slider.background, {
x: slider.x,
y: slider.y
});
Overlays.editOverlay(slider.foreground, {
x: slider.x,
y: slider.y
});
}
function updateTimer() {
var text = "";
if (Recording.isRecording()) {
text = formatTime(Recording.recorderElapsed());
} else {
text = formatTime(Recording.playerElapsed()) + " / " +
formatTime(Recording.playerLength());
text = formatTime(Recording.playerElapsed()) + " / " + formatTime(Recording.playerLength());
}
var timerWidth = text.length * 8 + ((Recording.isRecording()) ? 15 : 0);
Overlays.editOverlay(timer, {
text: text
})
toolBar.changeSpacing(text.length * 8 + ((Recording.isRecording()) ? 15 : 0), spacing);
text: text,
width: timerWidth
});
toolBar.changeSpacing(timerWidth + ToolBar.SPACING, spacing);
if (Recording.isRecording()) {
slider.pos = 1.0;
@ -173,7 +197,7 @@ function updateTimer() {
function formatTime(time) {
var MIN_PER_HOUR = 60;
var SEC_PER_MIN = 60;
var MSEC_PER_SEC = 1000;
var MSEC_DIGITS = 3;
var hours = Math.floor(time / (SEC_PER_MIN * MIN_PER_HOUR));
time -= hours * (SEC_PER_MIN * MIN_PER_HOUR);
@ -184,37 +208,19 @@ function formatTime(time) {
var seconds = time;
var text = "";
text += (hours > 0) ? hours + ":" :
"";
text += (minutes > 0) ? ((minutes < 10 && text != "") ? "0" : "") + minutes + ":" :
"";
text += ((seconds < 10 && text != "") ? "0" : "") + seconds.toFixed(3);
text += (hours > 0) ? hours + ":" : "";
text += (minutes > 0) ? ((minutes < 10 && text !== "") ? "0" : "") + minutes + ":" : "";
text += ((seconds < 10 && text !== "") ? "0" : "") + seconds.toFixed(MSEC_DIGITS);
return text;
}
function moveUI() {
var relative = { x: 70, y: 40 };
toolBar.move(relative.x, windowDimensions.y - relative.y);
Overlays.editOverlay(timer, {
x: relative.x + timerOffset - ToolBar.SPACING,
y: windowDimensions.y - relative.y - ToolBar.SPACING
});
slider.x = relative.x - ToolBar.SPACING;
slider.y = windowDimensions.y - relative.y - slider.h - ToolBar.SPACING;
Overlays.editOverlay(slider.background, {
x: slider.x,
y: slider.y,
});
Overlays.editOverlay(slider.foreground, {
x: slider.x,
y: slider.y,
});
}
function mousePressEvent(event) {
clickedOverlay = Overlays.getOverlayAtPoint({ x: event.x, y: event.y });
var clickedOverlay = Overlays.getOverlayAtPoint({ x: event.x, y: event.y });
if (recordIcon === toolBar.clicked(clickedOverlay, false) && !Recording.isPlaying()) {
if (!Recording.isRecording()) {
@ -226,7 +232,11 @@ function mousePressEvent(event) {
toolBar.setAlpha(ALPHA_OFF, loadIcon);
} else {
Recording.stopRecording();
toolBar.selectTool(recordIcon, true );
toolBar.selectTool(recordIcon, true);
setDefaultPlayerOptions();
// Plays the recording at the same spot as you recorded it
Recording.setPlayFromCurrentLocation(false);
Recording.setPlayerTime(0);
Recording.loadLastRecording();
toolBar.setAlpha(ALPHA_ON, playIcon);
toolBar.setAlpha(ALPHA_ON, playLoopIcon);
@ -240,7 +250,6 @@ function mousePressEvent(event) {
toolBar.setAlpha(ALPHA_ON, saveIcon);
toolBar.setAlpha(ALPHA_ON, loadIcon);
} else if (Recording.playerLength() > 0) {
setPlayerOptions();
Recording.setPlayerLoop(false);
Recording.startPlaying();
toolBar.setAlpha(ALPHA_OFF, recordIcon);
@ -255,7 +264,6 @@ function mousePressEvent(event) {
toolBar.setAlpha(ALPHA_ON, saveIcon);
toolBar.setAlpha(ALPHA_ON, loadIcon);
} else if (Recording.playerLength() > 0) {
setPlayerOptions();
Recording.setPlayerLoop(true);
Recording.startPlaying();
toolBar.setAlpha(ALPHA_OFF, recordIcon);
@ -263,7 +271,7 @@ function mousePressEvent(event) {
toolBar.setAlpha(ALPHA_OFF, loadIcon);
}
} else if (saveIcon === toolBar.clicked(clickedOverlay)) {
if (!Recording.isRecording() && !Recording.isPlaying() && Recording.playerLength() != 0) {
if (!Recording.isRecording() && !Recording.isPlaying() && Recording.playerLength() !== 0) {
recordingFile = Window.save("Save recording to file", ".", "Recordings (*.hfr)");
if (!(recordingFile === "null" || recordingFile === null || recordingFile === "")) {
Recording.saveRecording(recordingFile);
@ -274,6 +282,7 @@ function mousePressEvent(event) {
recordingFile = Window.browse("Load recording from file", ".", "Recordings (*.hfr *.rec *.HFR *.REC)");
if (!(recordingFile === "null" || recordingFile === null || recordingFile === "")) {
Recording.loadRecording(recordingFile);
setDefaultPlayerOptions();
}
if (Recording.playerLength() > 0) {
toolBar.setAlpha(ALPHA_ON, playIcon);
@ -282,8 +291,8 @@ function mousePressEvent(event) {
}
}
} else if (Recording.playerLength() > 0 &&
slider.x < event.x && event.x < slider.x + slider.w &&
slider.y < event.y && event.y < slider.y + slider.h) {
slider.x < event.x && event.x < slider.x + slider.w &&
slider.y < event.y && event.y < slider.y + slider.h) {
isSliding = true;
slider.pos = (event.x - slider.x) / slider.w;
Recording.setPlayerTime(slider.pos * Recording.playerLength());
@ -308,7 +317,7 @@ function mouseReleaseEvent(event) {
function update() {
var newDimensions = Controller.getViewportDimensions();
if (windowDimensions.x != newDimensions.x || windowDimensions.y != newDimensions.y) {
if (windowDimensions.x !== newDimensions.x || windowDimensions.y !== newDimensions.y) {
windowDimensions = newDimensions;
moveUI();
}

View file

@ -160,6 +160,7 @@ ToolBar = function(x, y, direction, optionalPersistenceKey, optionalInitialPosit
visible: false
});
this.spacing = [];
this.onMove = null;
this.addTool = function(properties, selectable, selected) {
if (direction == ToolBar.HORIZONTAL) {
@ -254,6 +255,9 @@ ToolBar = function(x, y, direction, optionalPersistenceKey, optionalInitialPosit
y: y - ToolBar.SPACING
});
}
if (this.onMove !== null) {
this.onMove(x, y, dx, dy);
};
}
this.setAlpha = function(alpha, tool) {