/** * Creates the matrices that are used for the projection from the 3D-space onto a 2D-screen. * (Result=ViewMatrix*ProjectionMatrix*ViewportMatrix) * * @return the complete matrix */ private Matrix4f createMatrices() { Matrix4f staticMatrix = new Matrix4f(mRenderer.getViewportMatrix()); Matrix4f projMatrix = mRenderer.getSceneManager().getFrustum().getProjectionMatrix(); staticMatrix.mul(projMatrix); Matrix4f cameraMatrix = mRenderer.getSceneManager().getCamera().getCameraMatrix(); staticMatrix.mul(cameraMatrix); return staticMatrix; }
/** * Instantiates a new GLViewer. Needs a reference to the RenderContext, which renders everything * to the screen. * * @param context The context that the application is running in. * @param renderer The RenderContext that is used for rendering. * @param openGLES20 A flag that makes sure that all the OpenGL settings are set appropriately if * you use version 1.1 or 2.0 */ public GLViewer(Context context, RendererInterface renderer) { super(context); mRenderer = renderer; mRenderer.setViewer(this); if (renderer.supportsOpenGLES20()) { setEGLContextClientVersion(2); } setRenderer(mRenderer); setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); }
/** * Callback method from the framework if the surface has changed. This usually happens when you * rotate the screen. * * @param width The new width of the view * @param height The new height of the view */ public void surfaceHasChanged(int width, int height) { mWidth = width; mHeight = height; mRenderer.getSceneManager().getFrustum().setAspectRatio((float) width / height); }