Log in or register to post comments

How can I transfer Matrix44F from ndk to java platform ?

April 1, 2012 - 11:05pm #1

Hi. I want to transfer modelViewMatrix, projectionMatrix and modelViewProjection to java platform to use android.opengl's gluUnProject function. I want to get object's position matrix in real world.

Re: How can I transfer Matrix44F from ndk to java platform ?

June 11, 2012 - 2:22am #5

Could you try:

env->CallVoidMethod(obj, method, modelviewArray);

instead of:

env->CallObjectMethod(obj, method, modelviewArray);

Not sure if that'll make a whole lot of difference...

Rob.

Re: How can I transfer Matrix44F from ndk to java platform ?

June 9, 2012 - 10:13am #4

Can you post the code that you're using?

Where are you seeing the null value? - on the C++ or Java side?

Re: How can I transfer Matrix44F from ndk to java platform ?

June 9, 2012 - 12:28am #3

hey kim ,i followed the steps in your reply to do what calibronbon is trying to do but modelviewArray returns null value,i tried many things but got no clue why this is happening,plz help me for this

Re: How can I transfer Matrix44F from ndk to java platform ?

April 2, 2012 - 9:51am #2

Use JNI calls to pass up the array. For example:

ImageTargetsRenderer.java

public void updateModelviewMatrix(float modelviewArray[])
{
    // do something with the array
}

ImageTargets.cpp

Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargetsRenderer_renderFrame(JNIEnv *env, jobject obj)
{
...
    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->DeleteLocalRef(modelviewArray);
...
}

- Kim

Log in or register to post comments