Android Open Source - 4est Gl View






From Project

Back to project page 4est.

License

The source code is released under:

MIT License

If you think the Android project 4est 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.forest;
/*w w  w. j  a  v  a  2s.  c om*/
import android.content.Context;
import android.opengl.GLSurfaceView;
import android.util.AttributeSet;
import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.MotionEvent;

import com.wordsaretoys.rise.geometry.Vector;

public class GlView extends GLSurfaceView {

  // gesture detector & listener
  GestureDetector gestureDetector;
  GestureListener gestureListener;
  
  /**
   * xml-compatible ctor
   */
  public GlView(Context context, AttributeSet attrs) {
    super(context, attrs);
    
    Shared.glView = this;
    setEGLContextClientVersion(2);
    setRenderer(new Render());
    
    gestureListener = new GestureListener();
    gestureDetector = new GestureDetector(context, gestureListener);
    gestureDetector.setIsLongpressEnabled(false);
  }
  
  /**
   * periodic update
   */
  public void update() {
/*    String target = "nothing";
    Camera camera = Shared.player.camera;
    Vector p = Shared.debris.locate(camera.position);
    if (p != null) {
      t_p.copy(p).sub(camera.position);
      float dd = t_p.length();
      t_p.norm();
      float dp = t_p.dot(camera.front);
      target = dp + ", " + dd;
    }
    Shared.dbg.set("target", target); */
  }
  Vector t_p = new Vector();

  @Override
  public boolean onTouchEvent(MotionEvent e) {
    // handle raw events for movement
    switch (e.getActionMasked()) {
    case MotionEvent.ACTION_DOWN:
      Shared.player.setMove(true);
      break;
    case MotionEvent.ACTION_UP:
      Shared.player.setMove(false);
      break;
    }
    return gestureDetector.onTouchEvent(e) || super.onTouchEvent(e);
  }

  /**
   * gesture detector listener
   */
  class GestureListener extends SimpleOnGestureListener {
    
    @Override
    public boolean onDown(MotionEvent e) {
      // must return true for other events to happen
      return true;
    }
    
    @Override
    public boolean onScroll(MotionEvent e0, MotionEvent e1, float dx, float dy) {
      Shared.player.setLook(dx, dy);
      return true;
    }
    
  }
  
}




Java Source Code List

com.wordsaretoys.forest.Audio.java
com.wordsaretoys.forest.Debris.java
com.wordsaretoys.forest.Game.java
com.wordsaretoys.forest.GlView.java
com.wordsaretoys.forest.MainActivity.java
com.wordsaretoys.forest.Map.java
com.wordsaretoys.forest.Player.java
com.wordsaretoys.forest.Render.java
com.wordsaretoys.forest.Rotors.java
com.wordsaretoys.forest.Shared.java
com.wordsaretoys.forest.Skybox.java
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