Skip to content

Instantly share code, notes, and snippets.

@ChristophHaag
Last active March 28, 2018 04:21
Show Gist options
  • Save ChristophHaag/3e1c058a9bfbb350a4c3f9d545b0ca74 to your computer and use it in GitHub Desktop.
Save ChristophHaag/3e1c058a9bfbb350a4c3f9d545b0ca74 to your computer and use it in GitHub Desktop.
//gcc osvrexample.c -losvrClientKit
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <osvr/ClientKit/ContextC.h>
#include <osvr/ClientKit/InterfaceC.h>
#include <osvr/ClientKit/InterfaceStateC.h>
int main() {
OSVR_ClientContext osvrctx = osvrClientInit("com.osvr.osvrexample", 0);
OSVR_ClientInterface head;
osvrClientGetInterface(osvrctx, "/me/head", &head);
while (1) {
osvrClientUpdate(osvrctx);
OSVR_TimeValue timestamp;
OSVR_PoseState state;
OSVR_ReturnCode ret = osvrGetPoseState(head, &timestamp, &state);
if (OSVR_RETURN_SUCCESS != ret) {
//No pose state;
continue;
}
printf("Head Roation: %f %f %f %f; Head Position: %f %f %f\n", osvrQuatGetX(&state.rotation), osvrQuatGetY(&state.rotation), osvrQuatGetZ(&state.rotation), osvrQuatGetW(&state.rotation), osvrVec3GetX(&state.translation), osvrVec3GetY(&state.translation), osvrVec3GetZ(&state.translation));
usleep(100 * 1000);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment