-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHeadTracking.cpp
More file actions
65 lines (52 loc) · 1.7 KB
/
HeadTracking.cpp
File metadata and controls
65 lines (52 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "HeadTracking.h"
HeadTracking::HeadTracking(){
if(Engine::headTrackingMethod == HeadTrackingMethods::OFF)
return;
#ifdef ANDROID
env = NULL;
zeissVRoneMethodID = 0;
zeissVRoneActivity = NULL;
#endif
init();
}
HeadTracking::~HeadTracking(){
}
void HeadTracking::init(){
if (Engine::headTrackingMethod == HeadTrackingMethods::ZEISS_VR_ONE)
initZeissVRone();
else if(Engine::headTrackingMethod == HeadTrackingMethods::ZEISS_VR_ONE)
initGoogleCardBoard();
else
cout << "No head tracking." << endl;
}
void HeadTracking::initZeissVRone(){
#ifdef ANDROID
// retrieve the JNI environment.
if(!env){
env = (JNIEnv*)SDL_AndroidGetJNIEnv();
}
if(zeissVRoneMethodID == 0){
// retrieve the Java instance of the SDLActivity
zeissVRoneActivity = (jobject)SDL_AndroidGetActivity();
// find the Java class of the activity. It should be SDLActivity or a subclass of it.
jclass clazz(env->GetObjectClass(zeissVRoneActivity));
// find the identifier of the method to call
zeissVRoneMethodID = env->GetMethodID(clazz, "getRotation", "()[D");
}
// clean up the local references. - skip this for now
//env->DeleteLocalRef(activity);
//env->DeleteLocalRef(clazz);
#endif
}
void HeadTracking::initGoogleCardBoard(){
}
void HeadTracking::getHeadOrientationQuaternion(double* x, double* y, double* z, double* w){
#ifdef ANDROID
// is CallDoubleMethodA A = array ???????????? DOES NOT COMPILE, SO I COMMENTED THIS OUT FOR NOW
//double* returnedQuaternion = env->CallDoubleMethodA(zeissVRoneActivity, zeissVRoneMethodID);
//*x = returnedQuaternion[0];
//*y = returnedQuaternion[1];
//*z = returnedQuaternion[2];
//*w = returnedQuaternion[3];
#endif
}