mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 14:33:31 +02:00
store avatar position and yaw in file to restore on relaunch
This commit is contained in:
parent
90a08b4dd8
commit
1a8564f9d9
3 changed files with 28 additions and 1 deletions
|
@ -1539,3 +1539,23 @@ glm::vec3 Avatar::getGravity(glm::vec3 pos) {
|
|||
return glm::vec3(0.f, 0.f, 0.f);
|
||||
}
|
||||
}
|
||||
|
||||
const char AVATAR_DATA_FILENAME[] = "avatar.ifd";
|
||||
|
||||
void Avatar::writeAvatarDataToFile() {
|
||||
// write the avatar position and yaw to a local file
|
||||
FILE* avatarFile = fopen(AVATAR_DATA_FILENAME, "w");
|
||||
|
||||
if (avatarFile) {
|
||||
fprintf(avatarFile, "%f,%f,%f %f", _position.x, _position.y, _position.z, _bodyYaw);
|
||||
fclose(avatarFile);
|
||||
}
|
||||
}
|
||||
|
||||
void Avatar::readAvatarDataFromFile() {
|
||||
FILE* avatarFile = fopen(AVATAR_DATA_FILENAME, "r");
|
||||
|
||||
if (avatarFile) {
|
||||
fscanf(avatarFile, "%f,%f,%f %f", &_position.x, &_position.y, &_position.z, &_bodyYaw);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -145,6 +145,9 @@ public:
|
|||
|
||||
// Find out what the local gravity vector is at this location
|
||||
glm::vec3 getGravity(glm::vec3 pos);
|
||||
|
||||
void writeAvatarDataToFile();
|
||||
void readAvatarDataFromFile();
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -344,7 +344,9 @@ void init(void)
|
|||
|
||||
void terminate () {
|
||||
// Close serial port
|
||||
//close(serial_fd);
|
||||
// close(serial_fd);
|
||||
|
||||
myAvatar.writeAvatarDataToFile();
|
||||
|
||||
#ifndef _WIN32
|
||||
audio.terminate();
|
||||
|
@ -1944,6 +1946,8 @@ int main(int argc, const char * argv[])
|
|||
printLog("Network receive thread created.\n");
|
||||
}
|
||||
|
||||
myAvatar.readAvatarDataFromFile();
|
||||
|
||||
glutTimerFunc(1000, Timer, 0);
|
||||
glutMainLoop();
|
||||
|
||||
|
|
Loading…
Reference in a new issue