I want to pass a 3d float array(float[][][]) from java to c edit it and return the array back to java
Curretly i can do this only with 1D arrays with this
jfloat* valuesjf = NULL;
float* valuesf = NULL;
void Java_Grids_Grid5_Update( JNIEnv* env,jobject thiz,jfloatArray values )
{
valuesjf = (*env)->GetFloatArrayElements(env,values,NULL);
valuesf = valuesjf;
valuesf[0]=121+valuesf[0];//do some calculations
(*env)->ReleaseFloatArrayElements(env, values, valuesjf, JNI_ABORT);
}
How do i do it with 3D array?
You could flatten the 3d float array in Java into a 1d array. You can then access each element of the original 3d array by generating the correct index into the 1d array. You would also need to pass the length of each dimension of the array to the native method so that the native method can also generate the correct indices into the 1d array
Java:
C++: