3
0
Fork 0
mirror of https://github.com/lubosz/overte.git synced 2025-04-27 06:35:32 +02:00

first prototype

This commit is contained in:
Dante Ruiz 2017-04-24 22:09:01 +01:00
parent f69691afd5
commit 367a6ac03c
3 changed files with 58 additions and 33 deletions
interface/resources/qml/hifi/tablet
libraries/controllers/src/controllers

View file

@ -24,6 +24,7 @@ Rectangle {
color: hifi.colors.baseGray;
property string path: ""
property var dialog: null;
property bool recording: false;
Component { id: fileDialog; TabletFileDialog { } }
Row {
@ -37,36 +38,50 @@ Rectangle {
top: parent.top
topMargin: 10
}
HifiControls.Button {
id: start
text: "Start"
color: hifi.buttons.blue
text: "Start Recoring"
color: hifi.buttons.black
enabled: true
onClicked: {
sendToScript({method: "Start"});
}
}
HifiControls.Button {
id: stop
text: "Stop"
color: hifi.buttons.blue
enabled: true
onClicked: {
sendToScript({method: "Stop"});
if (inputRecorder.recording) {
sendToScript({method: "Stop"});
inputRecorder.recording = false;
start.text = "Start Recording";
} else {
sendToScript({method: "Start"});
inputRecorder.recording = true;
start.text = "Stop Recording";
}
}
}
HifiControls.Button {
id: save
text: "Save"
color: hifi.buttons.blue
text: "Save Recording"
color: hifi.buttons.black
enabled: true
onClicked: {
sendToScript({method: "Save"});
}
}
HifiControls.Button {
id: playBack
anchors.right: browse.left
anchors.top: selectedFile.bottom
anchors.topMargin: 10
text: "Play Recording"
color: hifi.buttons.black
enabled: true
onClicked: {
sendToScript({method: "playback"});
HMD.closeTablet();
}
}
}
HifiControls.VerticalSpacer {}
@ -110,24 +125,25 @@ Rectangle {
}
}
HifiControls.Button {
id: playBack
anchors.right: browse.left
anchors.top: selectedFile.bottom
anchors.topMargin: 10
text: "Playback"
color: hifi.buttons.black
enabled: true
onClicked: {
sendToScript({method: "playback"});
Column {
id: notes
anchors.centerIn: parent;
spacing: 20
Text {
text: "All files are saved under the folder 'hifi-input-recording' in your home directory";
color: "white"
font.pointSize: 10
}
Text {
text: "To cancel a recording playback press Alt-B"
color: "white"
font.pointSize: 10
}
}
function getFileSelected(file) {
console.log("------------> file selected <----------------");
//sendToScript({ method: "Load", params: { file: file} });
selectedFile.text = file;
inputRecorder.path = file;
}

View file

@ -166,6 +166,10 @@ namespace controller {
}
void InputRecorder::loadRecording(const QString& path) {
_recording = false;
_playback = false;
_loading = true;
_playCount = 0;
resetFrame();
_poseStateList.clear();
_actionStateList.clear();
@ -174,16 +178,16 @@ namespace controller {
QFileInfo info(filePath);
QString extension = info.suffix();
if (extension != "gz") {
qWarning() << "Could not open file of type " << extension;
qWarning() << "can not load file with exentsion of " << extension;
return;
}
bool success = false;
QJsonObject data = openFile(info.absoluteFilePath(), success);
int count = 0;
if (success) {
_framesRecorded = data["frameCount"].toInt();
QJsonArray actionArrayList = data["actionList"].toArray();
QJsonArray poseArrayList = data["poseList"].toArray();
for (int actionIndex = 0; actionIndex < actionArrayList.size(); actionIndex++) {
QJsonArray actionState = actionArrayList[actionIndex].toArray();
for (int index = 0; index < actionState.size(); index++) {
@ -202,6 +206,8 @@ namespace controller {
_currentFramePoses = PoseStates(toInt(Action::NUM_ACTIONS));
}
}
_loading = false;
}
void InputRecorder::stopRecording() {
@ -211,10 +217,12 @@ namespace controller {
void InputRecorder::startPlayback() {
_playback = true;
_recording = false;
_playCount = 0;
}
void InputRecorder::stopPlayback() {
_playback = false;
_playCount = 0;
}
void InputRecorder::setActionState(controller::Action action, float value) {

View file

@ -39,7 +39,7 @@ namespace controller {
void togglePlayback() { _playback = !_playback; }
void resetFrame();
bool isRecording() { return _recording; }
bool isPlayingback() { return _playback; }
bool isPlayingback() { return (_playback && !_loading); }
void setActionState(controller::Action action, float value);
void setActionState(controller::Action action, const controller::Pose pose);
float getActionState(controller::Action action);
@ -48,6 +48,7 @@ namespace controller {
private:
bool _recording { false };
bool _playback { false };
bool _loading { false };
std::vector<PoseStates> _poseStateList = std::vector<PoseStates>();
std::vector<ActionStates> _actionStateList = std::vector<ActionStates>();
PoseStates _currentFramePoses = PoseStates(toInt(Action::NUM_ACTIONS));