61
Support / Re: [Tips] Android, augmented reality 3D with JPCT + Camera.
« on: December 01, 2011, 03:10:16 pm »
Awesome, thanks Egon. Let me know and I'll test.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
setEGLContextClientVersion(2);
setEGLConfigChooser(new AAConfigChooser(this));
getHolder().setFormat(PixelFormat.RGBA_8888);
frameBuffer.clear(new RGBColor(0,0,0,0));
theWorld.renderScene(frameBuffer);
theWorld.draw(frameBuffer);
frameBuffer.display();
private float[] mLookMatrix = new float[16];
public void setCameraPosition(CamPosition newCamera) {
Matrix.setLookAtM(mLookMatrix, 0,
newCamera.eyeX,
newCamera.eyeY,
newCamera.eyeZ,
newCamera.frontX + newCamera.eyeX,
newCamera.frontY + newCamera.eyeY,
newCamera.frontZ + newCamera.eyeZ,
newCamera.upX,
newCamera.upY,
newCamera.upZ);
}
private void setViewAndProjection() {
float[] modelMatrix = new float[16]; // model matrix (identity)
Matrix.setIdentityM(modelMatrix, 0);
Matrix.translateM(modelMatrix, 0, 0, 0, 0);
// calculating the current model-view-projection matrix
Matrix.frustumM(mProjMatrix, 0,
-fSize, fSize,
-fSize / ratio, fSize / ratio,
zNear, viewRange);
// multiply matrices
Matrix.multiplyMM(mWorldMatrix, 0, mProjMatrix, 0, mLookMatrix, 0);
Matrix.multiplyMM(modelViewProjectionMatrix, 0, mWorldMatrix, 0, modelMatrix, 0);
GLES20.glUniformMatrix4fv(muMVPMatrixHandle, 1, false, modelViewProjectionMatrix, 0);
}
public void setCameraPosition(CamPosition newCamera) {
SimpleVector dir = new SimpleVector(
newCamera.frontX + newCamera.eyeX,
newCamera.frontY + newCamera.eyeY,
newCamera.frontZ + newCamera.eyeZ
);
SimpleVector up = new SimpleVector(
newCamera.upX,
newCamera.upY,
newCamera.upZ);
worldCamera.setOrientation(dir, up);
worldCamera.setPosition(newCamera.eyeX, newCamera.eyeY, newCamera.eyeZ);
}