www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: cefengxu on October 23, 2015, 10:39:30 am

Title: [topic-1-1]how to use the jpct-ae matrix as well as the OPENGL ES 2.0
Post by: cefengxu on October 23, 2015, 10:39:30 am
Dear Master :

Purpose :
i need to set a  [ real-time matrix ] for the obj to realize the AR ;

as the normally, i can use the "fucntion GLES20.glUniformMatrix4fv" to set a matrix to the shader , and then calculate the right position of the model on the screen;

i can get the translate matrix output by ARToolkit in real-time ;
 but  i do not know how to set the matrix when i use the jpct-ae to rendering.

i have tried to use the "jpct-ae-fucniton model.setTranslationMatrix(mat);" , but all the result  for scale , position and direction  are wrong.


question : how to use the translationmatrix in jpct as will as GLES20function::GLES20.glUniformMatrix4fv??
Title: Re: how to use the jpct-ae matrix as well as the OPENGL ES 2.0
Post by: EgonOlsen on October 23, 2015, 12:30:56 pm
Maybe this helps: http://stackoverflow.com/questions/32661506/integrating-jpct-ae-and-artoolkit-in-android (http://stackoverflow.com/questions/32661506/integrating-jpct-ae-and-artoolkit-in-android)?
Title: Re: how to use the jpct-ae matrix as well as the OPENGL ES 2.0
Post by: cefengxu on October 27, 2015, 10:15:34 am
i have fix this issue , i will post a tutorial later.

Question: and then , the model could not be change ( always be laid on the mark ,as shown as the attached ) even i use the function rotationMatirx ;

my code as belown:

Code: [Select]
    public void onDrawFrame(GL10 unused) {
float[] projection = ARNativeActivity.getProjectM();
Matrix projMatrix = new Matrix();
projMatrix.setDump(projection);
projMatrix.transformToGL();
SimpleVector translation = projMatrix.getTranslation();
SimpleVector dir = projMatrix.getZAxis();
SimpleVector up = projMatrix.getYAxis();
cam.setPosition(translation);
cam.setOrientation(dir, up);

float[] transformation = ARNativeActivity.getTransformationM();
Matrix dump = new Matrix();
dump.setDump(transformation);
dump.transformToGL();
alita.clearTranslation();
alita.translate(dump.getTranslation());
alita.setRotationMatrix(dump);

alita.setState(stat);
alita.animate(ticks);
}