Android Open Source - splott Camera






From Project

Back to project page splott.

License

The source code is released under:

MIT License

If you think the Android project splott listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.wordsaretoys.rise.geometry;
//w  w  w .  j  av a  2s  .c o  m
import android.opengl.GLES20;

/**
 * maintain a camera: a special case of mote
 * that implements a projection matrix
 * 
 * @author chris
 *
 */
public class Camera extends Mote {

  public float viewFactor;
  public float[] projector;
  
  /**
   * constructor
   */
  public Camera(float viewAngle, float nearLimit, float farLimit) {
    viewFactor = 1f / (float) Math.tan(viewAngle * Math.PI / 180f);
    // set fixed matrix elements
    projector = new float[16];
    float d = (float)(nearLimit - farLimit);
    projector[0] = (float)viewFactor;
    projector[5] = (float)viewFactor;
    projector[10] = (float) ((farLimit + nearLimit) / d);
    projector[11] = -1;
    projector[14] = (float)(2 * nearLimit * farLimit / d);
  }
  
  /**
   * set camera aspect ratio and viewport
   * @param width, height dimensions of viewport
   */
  public void size(int width, int height) {
    float aspectRatio = (float)width / (float)height;
    projector[0] = (float)viewFactor / aspectRatio;
    GLES20.glViewport(0, 0, width, height);
  }
  
}




Java Source Code List

com.wordsaretoys.rise.geometry.Camera.java
com.wordsaretoys.rise.geometry.Geom.java
com.wordsaretoys.rise.geometry.Mote.java
com.wordsaretoys.rise.geometry.Ortho.java
com.wordsaretoys.rise.geometry.Quaternion.java
com.wordsaretoys.rise.geometry.Vector.java
com.wordsaretoys.rise.glwrapper.Mesh.java
com.wordsaretoys.rise.glwrapper.Shader.java
com.wordsaretoys.rise.glwrapper.Texture.java
com.wordsaretoys.rise.meshutil.HeightMapper.java
com.wordsaretoys.rise.meshutil.IndexBuffer.java
com.wordsaretoys.rise.meshutil.SurfaceMapper.java
com.wordsaretoys.rise.meshutil.VertexBuffer.java
com.wordsaretoys.rise.meshutil.Vindexer.java
com.wordsaretoys.rise.pattern.Bitmap.java
com.wordsaretoys.rise.pattern.F2FSumMap.java
com.wordsaretoys.rise.pattern.I2FCutMap.java
com.wordsaretoys.rise.pattern.I2FMap.java
com.wordsaretoys.rise.pattern.I2IMap.java
com.wordsaretoys.rise.pattern.Pattern.java
com.wordsaretoys.rise.pattern.Ring.java
com.wordsaretoys.rise.utility.Asset.java
com.wordsaretoys.rise.utility.Board.java
com.wordsaretoys.rise.utility.Dbg.java
com.wordsaretoys.rise.utility.Interval.java
com.wordsaretoys.rise.utility.Misc.java
com.wordsaretoys.rise.utility.Needle.java
com.wordsaretoys.splott.MainActivity.java
com.wordsaretoys.splott.parser.Compiler.java
com.wordsaretoys.splott.parser.SurfaceBaseListener.java
com.wordsaretoys.splott.parser.SurfaceLexer.java
com.wordsaretoys.splott.parser.SurfaceListener.java
com.wordsaretoys.splott.parser.SurfaceParser.java
com.wordsaretoys.splott.parser.SyntaxChecker.java
com.wordsaretoys.splott.parser.Vm.java
com.wordsaretoys.splott.plotter.GlView.java
com.wordsaretoys.splott.plotter.Render.java
com.wordsaretoys.splott.plotter.Surface.java