mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 01:00:44 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into virtualEntities
This commit is contained in:
commit
0f2a14a359
4 changed files with 71 additions and 20 deletions
|
@ -12,12 +12,15 @@
|
||||||
|
|
||||||
var filename = "http://your.recording.url";
|
var filename = "http://your.recording.url";
|
||||||
var playFromCurrentLocation = true;
|
var playFromCurrentLocation = true;
|
||||||
|
var loop = true;
|
||||||
|
|
||||||
Avatar.faceModelURL = "http://public.highfidelity.io/models/heads/EvilPhilip_v7.fst";
|
Avatar.faceModelURL = "http://public.highfidelity.io/models/heads/EvilPhilip_v7.fst";
|
||||||
Avatar.skeletonModelURL = "http://public.highfidelity.io/models/skeletons/Philip_Carl_Body_A-Pose.fst";
|
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 };
|
||||||
|
Avatar.orientation = Quat.fromPitchYawRollDegrees(0, 0, 0);
|
||||||
|
Avatar.scale = 1.0;
|
||||||
|
|
||||||
Agent.isAvatar = true;
|
Agent.isAvatar = true;
|
||||||
|
|
||||||
|
@ -30,7 +33,9 @@ function update(event) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
Avatar.startPlaying(playFromCurrentLocation);
|
Avatar.setPlayFromCurrentLocation(playFromCurrentLocation);
|
||||||
|
Avatar.setPlayerLoop(loop);
|
||||||
|
Avatar.startPlaying();
|
||||||
Avatar.play();
|
Avatar.play();
|
||||||
Vec3.print("Playing from ", Avatar.position);
|
Vec3.print("Playing from ", Avatar.position);
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
Script.include("toolBars.js");
|
Script.include("toolBars.js");
|
||||||
|
|
||||||
var recordingFile = "recording.rec";
|
var recordingFile = "recording.rec";
|
||||||
|
var playFromCurrentLocation = true;
|
||||||
|
var loop = true;
|
||||||
|
|
||||||
var windowDimensions = Controller.getViewportDimensions();
|
var windowDimensions = Controller.getViewportDimensions();
|
||||||
var TOOL_ICON_URL = "http://s3-us-west-1.amazonaws.com/highfidelity-public/images/tools/";
|
var TOOL_ICON_URL = "http://s3-us-west-1.amazonaws.com/highfidelity-public/images/tools/";
|
||||||
|
@ -139,8 +141,6 @@ function moveUI() {
|
||||||
function mousePressEvent(event) {
|
function mousePressEvent(event) {
|
||||||
clickedOverlay = Overlays.getOverlayAtPoint({ x: event.x, y: event.y });
|
clickedOverlay = Overlays.getOverlayAtPoint({ x: event.x, y: event.y });
|
||||||
|
|
||||||
print("Status: isPlaying=" + MyAvatar.isPlaying() + ", isRecording=" + MyAvatar.isRecording());
|
|
||||||
|
|
||||||
if (recordIcon === toolBar.clicked(clickedOverlay) && !MyAvatar.isPlaying()) {
|
if (recordIcon === toolBar.clicked(clickedOverlay) && !MyAvatar.isPlaying()) {
|
||||||
if (!MyAvatar.isRecording()) {
|
if (!MyAvatar.isRecording()) {
|
||||||
MyAvatar.startRecording();
|
MyAvatar.startRecording();
|
||||||
|
@ -154,19 +154,23 @@ function mousePressEvent(event) {
|
||||||
if (MyAvatar.isPlaying()) {
|
if (MyAvatar.isPlaying()) {
|
||||||
MyAvatar.stopPlaying();
|
MyAvatar.stopPlaying();
|
||||||
} else {
|
} else {
|
||||||
MyAvatar.setPlayFromCurrentLocation(true);
|
MyAvatar.setPlayFromCurrentLocation(playFromCurrentLocation);
|
||||||
MyAvatar.setPlayerLoop(true);
|
MyAvatar.setPlayerLoop(loop);
|
||||||
MyAvatar.startPlaying(true);
|
MyAvatar.startPlaying(true);
|
||||||
}
|
}
|
||||||
} else if (saveIcon === toolBar.clicked(clickedOverlay)) {
|
} else if (saveIcon === toolBar.clicked(clickedOverlay)) {
|
||||||
if (!MyAvatar.isRecording()) {
|
if (!MyAvatar.isRecording()) {
|
||||||
recordingFile = Window.save("Save recording to file", ".", "*.rec");
|
recordingFile = Window.save("Save recording to file", ".", "*.rec");
|
||||||
MyAvatar.saveRecording(recordingFile);
|
if (recordingFile != null) {
|
||||||
|
MyAvatar.saveRecording(recordingFile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (loadIcon === toolBar.clicked(clickedOverlay)) {
|
} else if (loadIcon === toolBar.clicked(clickedOverlay)) {
|
||||||
if (!MyAvatar.isRecording()) {
|
if (!MyAvatar.isRecording()) {
|
||||||
recordingFile = Window.browse("Load recorcding from file", ".", "*.rec");
|
recordingFile = Window.browse("Load recorcding from file", ".", "*.rec");
|
||||||
MyAvatar.loadRecording(recordingFile);
|
if (recordingFile != "null") {
|
||||||
|
MyAvatar.loadRecording(recordingFile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,9 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <GLMHelpers.h>
|
#include <GLMHelpers.h>
|
||||||
|
#include <NetworkAccessManager.h>
|
||||||
|
|
||||||
|
#include <QEventLoop>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QMetaObject>
|
#include <QMetaObject>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
@ -57,6 +59,25 @@ Recording::~Recording() {
|
||||||
delete _audio;
|
delete _audio;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Recording::getLength() const {
|
||||||
|
if (_timestamps.isEmpty()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return _timestamps.last();
|
||||||
|
}
|
||||||
|
|
||||||
|
qint32 Recording::getFrameTimestamp(int i) const {
|
||||||
|
if (i >= _timestamps.size()) {
|
||||||
|
return getLength();
|
||||||
|
}
|
||||||
|
return _timestamps[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
const RecordingFrame& Recording::getFrame(int i) const {
|
||||||
|
assert(i < _timestamps.size());
|
||||||
|
return _frames[i];
|
||||||
|
}
|
||||||
|
|
||||||
void Recording::addFrame(int timestamp, RecordingFrame &frame) {
|
void Recording::addFrame(int timestamp, RecordingFrame &frame) {
|
||||||
_timestamps << timestamp;
|
_timestamps << timestamp;
|
||||||
_frames << frame;
|
_frames << frame;
|
||||||
|
@ -492,18 +513,40 @@ void writeRecordingToFile(RecordingPointer recording, QString filename) {
|
||||||
}
|
}
|
||||||
|
|
||||||
RecordingPointer readRecordingFromFile(RecordingPointer recording, QString filename) {
|
RecordingPointer readRecordingFromFile(RecordingPointer recording, QString filename) {
|
||||||
qDebug() << "Reading recording from " << filename << ".";
|
QElapsedTimer timer;
|
||||||
|
timer.start();
|
||||||
|
|
||||||
|
QByteArray byteArray;
|
||||||
|
QUrl url(filename);
|
||||||
|
if (url.scheme() == "http" || url.scheme() == "https" || url.scheme() == "ftp") {
|
||||||
|
qDebug() << "Downloading recording at" << url;
|
||||||
|
NetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();
|
||||||
|
QNetworkReply* reply = networkAccessManager.get(QNetworkRequest(url));
|
||||||
|
QEventLoop loop;
|
||||||
|
QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
|
||||||
|
loop.exec();
|
||||||
|
if (reply->error() != QNetworkReply::NoError) {
|
||||||
|
qDebug() << "Error while downloading recording: " << reply->error();
|
||||||
|
reply->deleteLater();
|
||||||
|
return recording;
|
||||||
|
}
|
||||||
|
byteArray = reply->readAll();
|
||||||
|
reply->deleteLater();
|
||||||
|
} else {
|
||||||
|
qDebug() << "Reading recording from " << filename << ".";
|
||||||
|
QFile file(filename);
|
||||||
|
if (!file.open(QIODevice::ReadOnly)){
|
||||||
|
return recording;
|
||||||
|
}
|
||||||
|
byteArray = file.readAll();
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
if (!recording) {
|
if (!recording) {
|
||||||
recording.reset(new Recording());
|
recording.reset(new Recording());
|
||||||
}
|
}
|
||||||
|
|
||||||
QElapsedTimer timer;
|
QDataStream fileStream(byteArray);
|
||||||
QFile file(filename);
|
|
||||||
if (!file.open(QIODevice::ReadOnly)){
|
|
||||||
return recording;
|
|
||||||
}
|
|
||||||
timer.start();
|
|
||||||
QDataStream fileStream(&file);
|
|
||||||
|
|
||||||
fileStream >> recording->_timestamps;
|
fileStream >> recording->_timestamps;
|
||||||
RecordingFrame baseFrame;
|
RecordingFrame baseFrame;
|
||||||
|
@ -603,7 +646,7 @@ RecordingPointer readRecordingFromFile(RecordingPointer recording, QString filen
|
||||||
recording->addAudioPacket(audioArray);
|
recording->addAudioPacket(audioArray);
|
||||||
|
|
||||||
|
|
||||||
qDebug() << "Read " << file.size() << " bytes in " << timer.elapsed() << " ms.";
|
qDebug() << "Read " << byteArray.size() << " bytes in " << timer.elapsed() << " ms.";
|
||||||
return recording;
|
return recording;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,11 +81,11 @@ public:
|
||||||
~Recording();
|
~Recording();
|
||||||
|
|
||||||
bool isEmpty() const { return _timestamps.isEmpty(); }
|
bool isEmpty() const { return _timestamps.isEmpty(); }
|
||||||
int getLength() const { return _timestamps.last(); } // in ms
|
int getLength() const; // in ms
|
||||||
|
|
||||||
int getFrameNumber() const { return _frames.size(); }
|
int getFrameNumber() const { return _frames.size(); }
|
||||||
qint32 getFrameTimestamp(int i) const { return _timestamps[i]; }
|
qint32 getFrameTimestamp(int i) const;
|
||||||
const RecordingFrame& getFrame(int i) const { return _frames[i]; }
|
const RecordingFrame& getFrame(int i) const;
|
||||||
Sound* getAudio() const { return _audio; }
|
Sound* getAudio() const { return _audio; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -97,7 +97,6 @@ private:
|
||||||
QVector<qint32> _timestamps;
|
QVector<qint32> _timestamps;
|
||||||
QVector<RecordingFrame> _frames;
|
QVector<RecordingFrame> _frames;
|
||||||
|
|
||||||
bool _stereo;
|
|
||||||
Sound* _audio;
|
Sound* _audio;
|
||||||
|
|
||||||
friend class Recorder;
|
friend class Recorder;
|
||||||
|
|
Loading…
Reference in a new issue