Log in or register to post comments

How to get actual PoseMatrix in Java

June 21, 2011 - 10:33pm #1

I need the actual Posematrix in java because i want to play a sound when touching the screen depending on the actual pose. Can anybody explain me how i can get the Pose in java?


Re: How to get actual PoseMatrix in Java

June 22, 2011 - 2:35pm #2

Try something like this (untested, but should get you started):


const QCAR::Trackable* trackable = state.getActiveTrackable(tIdx);
QCAR::Matrix44F modelViewMatrix = QCAR::Tool::convertPose2GLMatrix(trackable->getPose());

jclass javaClass = env->GetObjectClass(obj);

jfloatArray modelviewArray = env->NewFloatArray(16);
env->SetFloatArrayRegion(modelviewArray, 0, 16, modelViewMatrix.data);
jmethodID method = env->GetMethodID(javaClass, "updateModelviewMatrix", "([F)V");
env->CallObjectMethod(obj, method, modelviewArray);

env and obj are passed in to the function (e.g. the renderFrame function).


public void updateModelviewMatrix(float modelviewArray[])
    // do something with the matrix here

Read up on the JNI (Java Native Interface) to understand the code.

- Kim

Log in or register to post comments