Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.atm959.openglgame;
- import android.opengl.Matrix;
- import static java.lang.Math.cos;
- import static java.lang.Math.sin;
- public class Camera {
- private float posX, posY, posZ;
- private float lookX, lookY, lookZ;
- public Camera(){
- this.posX = 0.0f; this.posY = 0.0f; this.posZ = 0.0f;
- this.lookX = 0.0f; this.lookY = 0.0f; this.lookZ = 2.0f;
- }
- public void setPosX(float x){
- this.posX = x;
- }
- public void setPosY(float y){
- this.posY = y;
- }
- public void setPosZ(float z){
- this.posZ = z;
- }
- public void setPosition(float x, float y, float z){
- this.posX = x;
- this.posY = y;
- this.posZ = z;
- }
- public void setYaw(float angle){
- this.lookX = this.posX + (float)(5 * sin(angle));
- this.lookZ = this.posZ + (float)(5 * cos(angle));
- }
- public void setPitch(float angle){
- this.lookY = this.posY + (float)(5 * sin(angle));
- }
- public float[] calculateCamMatrix(){
- float[] camMatrix = new float[16];
- Matrix.setLookAtM(camMatrix, 0, this.posX, this.posY, this.posZ, this.lookX, this.lookY, this.lookZ, 0f, 1.0f, 0.0f);
- return camMatrix;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment