og-libsurvive/api_example.c

36 lines
1 KiB
C
Raw Permalink Normal View History

2018-04-03 16:08:00 -06:00
#include <stdio.h>
#include <string.h>
#include <survive_api.h>
#include <os_generic.h>
int main(int argc, char **argv) {
2018-04-10 23:44:36 -06:00
SurviveSimpleContext *actx = survive_simple_init(argc, argv);
2018-04-03 16:08:00 -06:00
if (actx == 0) // implies -help or similiar
return 0;
2018-04-10 23:44:36 -06:00
survive_simple_start_thread(actx);
2018-04-03 16:08:00 -06:00
2018-04-10 23:44:36 -06:00
while (survive_simple_is_running(actx)) {
2018-04-03 16:08:00 -06:00
OGUSleep(30000);
SurvivePose pose;
2018-04-10 23:44:36 -06:00
for (const SurviveSimpleObject *it = survive_simple_get_first_object(actx); it != 0;
it = survive_simple_get_next_object(actx, it)) {
uint32_t timecode = survive_simple_object_get_latest_pose(it, &pose);
printf("%s (%u): %f %f %f %f %f %f %f\n", survive_simple_object_name(it), timecode, pose.Pos[0],
pose.Pos[1], pose.Pos[2], pose.Rot[0], pose.Rot[1], pose.Rot[2], pose.Rot[3]);
2018-04-03 16:08:00 -06:00
}
OGUSleep(30000);
2018-04-10 23:44:36 -06:00
for (const SurviveSimpleObject *it = survive_simple_get_next_updated(actx); it != 0;
it = survive_simple_get_next_updated(actx)) {
printf("%s changed since last checked\n", survive_simple_object_name(it));
2018-04-03 16:08:00 -06:00
}
}
2018-04-10 23:44:36 -06:00
survive_simple_close(actx);
2018-04-03 16:08:00 -06:00
return 0;
}