www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: Davi on October 29, 2011, 05:25:45 pm

Title: how to set my opengl es 3D projection to jpct-es
Post by: Davi on October 29, 2011, 05:25:45 pm
         I have opengl es code as blew:     
             
Code: [Select]
                gl.glMatrixMode(GL10.GL_PROJECTION);
gl.glPushMatrix();
gl.glLoadMatrixf(ProjectionBuff);
gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glPushMatrix();
gl.glLoadMatrixf(Transform);
             
      I want to know how to set jpct-es like this?
Title: Re: how to set my opengl es 3D projection to jpct-es
Post by: Davi on October 30, 2011, 03:11:44 am
anybody here,can help me? :-\
Title: Re: how to set my opengl es 3D projection to jpct-es
Post by: EgonOlsen on October 30, 2011, 07:51:47 pm
The projection matrix is implicitly created by the engine based on the current fov settings and the far and near clipping plane. There's no way to set it directly from the outside. The model view matrix in OpenGL is a combination of object space->world space and world space->camera space transformations. The matrix itself is set by the engine based on an object's transformation and the camera rotation and position. You can't take some random GL code and just extract the matrices to feed them into jPCT-AE. You have to understand what the code does and rebuild it's behaviour by using the means that the engine offers.
Title: Re: how to set my opengl es 3D projection to jpct-es
Post by: Davi on October 31, 2011, 09:49:12 am
Thank you very much ;D
Title: Re: how to set my opengl es 3D projection to jpct-es
Post by: Davi on October 31, 2011, 11:17:12 am
Code: [Select]

onDrawFrame(GL10 gl) {

matrixTrans=new Matrix();
matrixTrans.translate(a,b,c)
model.setTranslationMatrix(matrixTrans);

//doAnim(); 
world.renderScene(fb);
world.draw(fb);
fb.display();
}
   
 a,b,c is my dynamic value,it can control my model moved by my marker correctly before using jpct-ae. But with jpct, it seems can't be transformed correctly,at least not entirely correct. eg.when my marker is away from my device camera,it can be scaled correctly.but when I move my marker from up to down or from left to right,it can not moved to right place,but the  orientation is right.I don't know it is effected by wold or camra of jpct-ae. please?
Title: Re: how to set my opengl es 3D projection to jpct-es
Post by: EgonOlsen on October 31, 2011, 01:17:25 pm
I'm not 100% sure, what you are trying to do here, but keep in mind that jPCT uses this coordinate system: http://www.jpct.net/wiki/index.php/Coordinate_system (http://www.jpct.net/wiki/index.php/Coordinate_system)

Maybe you have adjust your a,b,c values to this.
Title: Re: how to set my opengl es 3D projection to jpct-es
Post by: Davi on November 21, 2011, 04:16:05 am
The projection matrix is implicitly created by the engine based on the current fov settings and the far and near clipping plane. There's no way to set it directly from the outside. The model view matrix in OpenGL is a combination of object space->world space and world space->camera space transformations. The matrix itself is set by the engine based on an object's transformation and the camera rotation and position. You can't take some random GL code and just extract the matrices to feed them into jPCT-AE. You have to understand what the code does and rebuild it's behaviour by using the means that the engine offers.
how can I understand what the code does,can you give me some open source code about that?
Title: Re: how to set my opengl es 3D projection to jpct-es
Post by: EgonOlsen on November 21, 2011, 07:58:32 am
I wasn't taking about the jPCT code. You have to understand what the OpenGL code does that you are going to port. jPCT just does the usual transformation stuff. I can post this part (6 lines or so...), but i don't see how this would help in any way. All it does is to tranform the world space transformation matrix to OpenGL's coordinate system, multiply with the camera's matrix and apply the camera's translation. Nothing special at all.
Title: Re: how to set my opengl es 3D projection to jpct-es
Post by: Davi on November 21, 2011, 02:21:53 pm
please post me that part (6 lines or so...), may be that can help me ;D
Title: Re: how to set my opengl es 3D projection to jpct-es
Post by: EgonOlsen on November 21, 2011, 02:26:03 pm
I don't see how, but here you go:

Code: [Select]
mo.setTo(transBuffer);
mat.setTo(cam.getBack());
mat.transformToGL();
mo.translate(-cam.backBx, -cam.backBy, -cam.backBz);
mo.matMul(mat);

mo is a Matrix that contains the final result, mat is a temp matrix, transBuffer contains the world transformation of that object.
Title: Re: how to set my opengl es 3D projection to jpct-es
Post by: Davi on November 21, 2011, 03:47:49 pm
"-cam.backBx, -cam.backBy, -cam.backBz",how to get them? :-[
Title: Re: how to set my opengl es 3D projection to jpct-es
Post by: EgonOlsen on November 21, 2011, 04:23:53 pm
That's simply the camera's position.