mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 11:45:36 +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:
|
||||
if (isShifted) {
|
||||
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;
|
||||
case Qt::Key_Percent:
|
||||
|
|
|
@ -507,17 +507,16 @@ bool MyAvatar::setJointReferential(int id, int jointIndex) {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
QString recordingFile = "recording.rec";
|
||||
bool MyAvatar::isRecording() const {
|
||||
return _recorder && _recorder->isRecording();
|
||||
}
|
||||
|
||||
RecorderPointer MyAvatar::startRecording() {
|
||||
void MyAvatar::startRecording() {
|
||||
if (!_recorder) {
|
||||
_recorder = RecorderPointer(new Recorder(this));
|
||||
}
|
||||
_recorder->startRecording();
|
||||
return _recorder;
|
||||
}
|
||||
|
||||
void MyAvatar::stopRecording() {
|
||||
|
@ -526,19 +525,41 @@ void MyAvatar::stopRecording() {
|
|||
}
|
||||
}
|
||||
|
||||
void MyAvatar::saveRecording(QString filename) {
|
||||
if (_recorder) {
|
||||
_recorder->saveToFile(filename);
|
||||
}
|
||||
}
|
||||
|
||||
bool MyAvatar::isPlaying() const {
|
||||
return _player && _player->isPlaying();
|
||||
}
|
||||
|
||||
PlayerPointer MyAvatar::startPlaying() {
|
||||
void MyAvatar::loadRecording(QString filename) {
|
||||
if (!_player) {
|
||||
_player = PlayerPointer(new Player(this));
|
||||
}
|
||||
if (_recorder) {
|
||||
_player->loadRecording(_recorder->getRecording());
|
||||
_player->startPlaying();
|
||||
|
||||
_player->loadFromFile(filename);
|
||||
}
|
||||
|
||||
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() {
|
||||
|
@ -955,7 +976,7 @@ void MyAvatar::clearJointsData() {
|
|||
for (int i = 0; i < _jointData.size(); ++i) {
|
||||
Avatar::clearJointData(i);
|
||||
if (QThread::currentThread() == thread()) {
|
||||
_skeletonModel.clearJointState(i);
|
||||
_skeletonModel.clearJointAnimationPriority(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -134,6 +134,10 @@ public:
|
|||
/// Renders a laser pointer for UI picking
|
||||
void renderLaserPointers();
|
||||
glm::vec3 getLaserPointerTipPosition(const PalmData* palm);
|
||||
|
||||
const RecorderPointer getRecorder() const { return _recorder; }
|
||||
const PlayerPointer getPlayer() const { return _player; }
|
||||
|
||||
public slots:
|
||||
void goHome();
|
||||
void increaseSize();
|
||||
|
@ -157,14 +161,15 @@ public slots:
|
|||
bool setModelReferential(int id);
|
||||
bool setJointReferential(int id, int jointIndex);
|
||||
|
||||
const RecorderPointer getRecorder() const { return _recorder; }
|
||||
bool isRecording() const;
|
||||
RecorderPointer startRecording();
|
||||
void startRecording();
|
||||
void stopRecording();
|
||||
void saveRecording(QString filename);
|
||||
|
||||
const PlayerPointer getPlayer() const { return _player; }
|
||||
bool isPlaying() const;
|
||||
PlayerPointer startPlaying();
|
||||
void loadRecording(QString filename);
|
||||
void loadLastRecording();
|
||||
void startPlaying();
|
||||
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) {
|
||||
if (index != -1 && index < _jointStates.size()) {
|
||||
JointState& state = _jointStates[index];
|
||||
|
|
|
@ -121,6 +121,9 @@ public:
|
|||
/// Clear the joint states
|
||||
void clearJointState(int index);
|
||||
|
||||
/// Clear the joint animation priority
|
||||
void clearJointAnimationPriority(int 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);
|
||||
|
||||
|
|
|
@ -687,7 +687,7 @@ QVector<glm::quat> AvatarData::getJointRotations() const {
|
|||
if (QThread::currentThread() != thread()) {
|
||||
QVector<glm::quat> result;
|
||||
QMetaObject::invokeMethod(const_cast<AvatarData*>(this),
|
||||
"getJointRotation", Qt::BlockingQueuedConnection,
|
||||
"getJointRotations", Qt::BlockingQueuedConnection,
|
||||
Q_RETURN_ARG(QVector<glm::quat>, result));
|
||||
return result;
|
||||
}
|
||||
|
@ -702,7 +702,7 @@ void AvatarData::setJointRotations(QVector<glm::quat> jointRotations) {
|
|||
if (QThread::currentThread() != thread()) {
|
||||
QVector<glm::quat> result;
|
||||
QMetaObject::invokeMethod(const_cast<AvatarData*>(this),
|
||||
"setJointRotation", Qt::BlockingQueuedConnection,
|
||||
"setJointRotations", Qt::BlockingQueuedConnection,
|
||||
Q_ARG(QVector<glm::quat>, jointRotations));
|
||||
}
|
||||
for (int i = 0; i < jointRotations.size(); ++i) {
|
||||
|
|
Loading…
Reference in a new issue