mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-08 18:47:46 +02:00
JS API for recording
This commit is contained in:
parent
db8869a34d
commit
b13604f968
6 changed files with 50 additions and 29 deletions
|
@ -1051,20 +1051,6 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
||||||
case Qt::Key_R:
|
case Qt::Key_R:
|
||||||
if (isShifted) {
|
if (isShifted) {
|
||||||
Menu::getInstance()->triggerOption(MenuOption::FrustumRenderMode);
|
Menu::getInstance()->triggerOption(MenuOption::FrustumRenderMode);
|
||||||
} else if (isMeta) {
|
|
||||||
if (_myAvatar->isRecording()) {
|
|
||||||
_myAvatar->stopRecording();
|
|
||||||
} else {
|
|
||||||
_myAvatar->startRecording();
|
|
||||||
_audio.setRecorder(_myAvatar->getRecorder());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (_myAvatar->isPlaying()) {
|
|
||||||
_myAvatar->stopPlaying();
|
|
||||||
} else {
|
|
||||||
_myAvatar->startPlaying();
|
|
||||||
_audio.setPlayer(_myAvatar->getPlayer());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Qt::Key_Percent:
|
case Qt::Key_Percent:
|
||||||
|
|
|
@ -507,17 +507,16 @@ bool MyAvatar::setJointReferential(int id, int jointIndex) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
QString recordingFile = "recording.rec";
|
||||||
bool MyAvatar::isRecording() const {
|
bool MyAvatar::isRecording() const {
|
||||||
return _recorder && _recorder->isRecording();
|
return _recorder && _recorder->isRecording();
|
||||||
}
|
}
|
||||||
|
|
||||||
RecorderPointer MyAvatar::startRecording() {
|
void MyAvatar::startRecording() {
|
||||||
if (!_recorder) {
|
if (!_recorder) {
|
||||||
_recorder = RecorderPointer(new Recorder(this));
|
_recorder = RecorderPointer(new Recorder(this));
|
||||||
}
|
}
|
||||||
_recorder->startRecording();
|
_recorder->startRecording();
|
||||||
return _recorder;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyAvatar::stopRecording() {
|
void MyAvatar::stopRecording() {
|
||||||
|
@ -526,19 +525,41 @@ void MyAvatar::stopRecording() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MyAvatar::saveRecording(QString filename) {
|
||||||
|
if (_recorder) {
|
||||||
|
_recorder->saveToFile(filename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool MyAvatar::isPlaying() const {
|
bool MyAvatar::isPlaying() const {
|
||||||
return _player && _player->isPlaying();
|
return _player && _player->isPlaying();
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerPointer MyAvatar::startPlaying() {
|
void MyAvatar::loadRecording(QString filename) {
|
||||||
if (!_player) {
|
if (!_player) {
|
||||||
_player = PlayerPointer(new Player(this));
|
_player = PlayerPointer(new Player(this));
|
||||||
}
|
}
|
||||||
if (_recorder) {
|
|
||||||
_player->loadRecording(_recorder->getRecording());
|
_player->loadFromFile(filename);
|
||||||
_player->startPlaying();
|
}
|
||||||
|
|
||||||
|
void MyAvatar::loadLastRecording() {
|
||||||
|
if (!_recorder) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
return _player;
|
if (!_player) {
|
||||||
|
_player = PlayerPointer(new Player(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
_player->loadRecording(_recorder->getRecording());
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyAvatar::startPlaying() {
|
||||||
|
if (!_player) {
|
||||||
|
_player = PlayerPointer(new Player(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
_player->startPlaying();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyAvatar::stopPlaying() {
|
void MyAvatar::stopPlaying() {
|
||||||
|
@ -955,7 +976,7 @@ void MyAvatar::clearJointsData() {
|
||||||
for (int i = 0; i < _jointData.size(); ++i) {
|
for (int i = 0; i < _jointData.size(); ++i) {
|
||||||
Avatar::clearJointData(i);
|
Avatar::clearJointData(i);
|
||||||
if (QThread::currentThread() == thread()) {
|
if (QThread::currentThread() == thread()) {
|
||||||
_skeletonModel.clearJointState(i);
|
_skeletonModel.clearJointAnimationPriority(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,6 +134,10 @@ public:
|
||||||
/// Renders a laser pointer for UI picking
|
/// Renders a laser pointer for UI picking
|
||||||
void renderLaserPointers();
|
void renderLaserPointers();
|
||||||
glm::vec3 getLaserPointerTipPosition(const PalmData* palm);
|
glm::vec3 getLaserPointerTipPosition(const PalmData* palm);
|
||||||
|
|
||||||
|
const RecorderPointer getRecorder() const { return _recorder; }
|
||||||
|
const PlayerPointer getPlayer() const { return _player; }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void goHome();
|
void goHome();
|
||||||
void increaseSize();
|
void increaseSize();
|
||||||
|
@ -157,14 +161,15 @@ public slots:
|
||||||
bool setModelReferential(int id);
|
bool setModelReferential(int id);
|
||||||
bool setJointReferential(int id, int jointIndex);
|
bool setJointReferential(int id, int jointIndex);
|
||||||
|
|
||||||
const RecorderPointer getRecorder() const { return _recorder; }
|
|
||||||
bool isRecording() const;
|
bool isRecording() const;
|
||||||
RecorderPointer startRecording();
|
void startRecording();
|
||||||
void stopRecording();
|
void stopRecording();
|
||||||
|
void saveRecording(QString filename);
|
||||||
|
|
||||||
const PlayerPointer getPlayer() const { return _player; }
|
|
||||||
bool isPlaying() const;
|
bool isPlaying() const;
|
||||||
PlayerPointer startPlaying();
|
void loadRecording(QString filename);
|
||||||
|
void loadLastRecording();
|
||||||
|
void startPlaying();
|
||||||
void stopPlaying();
|
void stopPlaying();
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -700,6 +700,12 @@ void Model::clearJointState(int index) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Model::clearJointAnimationPriority(int index) {
|
||||||
|
if (index != -1 && index < _jointStates.size()) {
|
||||||
|
_jointStates[index]._animationPriority = 0.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Model::setJointState(int index, bool valid, const glm::quat& rotation, float priority) {
|
void Model::setJointState(int index, bool valid, const glm::quat& rotation, float priority) {
|
||||||
if (index != -1 && index < _jointStates.size()) {
|
if (index != -1 && index < _jointStates.size()) {
|
||||||
JointState& state = _jointStates[index];
|
JointState& state = _jointStates[index];
|
||||||
|
|
|
@ -121,6 +121,9 @@ public:
|
||||||
/// Clear the joint states
|
/// Clear the joint states
|
||||||
void clearJointState(int index);
|
void clearJointState(int index);
|
||||||
|
|
||||||
|
/// Clear the joint animation priority
|
||||||
|
void clearJointAnimationPriority(int index);
|
||||||
|
|
||||||
/// Sets the joint state at the specified index.
|
/// Sets the joint state at the specified index.
|
||||||
void setJointState(int index, bool valid, const glm::quat& rotation = glm::quat(), float priority = 1.0f);
|
void setJointState(int index, bool valid, const glm::quat& rotation = glm::quat(), float priority = 1.0f);
|
||||||
|
|
||||||
|
|
|
@ -687,7 +687,7 @@ QVector<glm::quat> AvatarData::getJointRotations() const {
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) {
|
||||||
QVector<glm::quat> result;
|
QVector<glm::quat> result;
|
||||||
QMetaObject::invokeMethod(const_cast<AvatarData*>(this),
|
QMetaObject::invokeMethod(const_cast<AvatarData*>(this),
|
||||||
"getJointRotation", Qt::BlockingQueuedConnection,
|
"getJointRotations", Qt::BlockingQueuedConnection,
|
||||||
Q_RETURN_ARG(QVector<glm::quat>, result));
|
Q_RETURN_ARG(QVector<glm::quat>, result));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -702,7 +702,7 @@ void AvatarData::setJointRotations(QVector<glm::quat> jointRotations) {
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) {
|
||||||
QVector<glm::quat> result;
|
QVector<glm::quat> result;
|
||||||
QMetaObject::invokeMethod(const_cast<AvatarData*>(this),
|
QMetaObject::invokeMethod(const_cast<AvatarData*>(this),
|
||||||
"setJointRotation", Qt::BlockingQueuedConnection,
|
"setJointRotations", Qt::BlockingQueuedConnection,
|
||||||
Q_ARG(QVector<glm::quat>, jointRotations));
|
Q_ARG(QVector<glm::quat>, jointRotations));
|
||||||
}
|
}
|
||||||
for (int i = 0; i < jointRotations.size(); ++i) {
|
for (int i = 0; i < jointRotations.size(); ++i) {
|
||||||
|
|
Loading…
Reference in a new issue