Android Open Source - 4est Height Mapper






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.rise.meshutil;
//w ww .j  av  a 2s.co m

/**
 * generates an indexed grid of vertexes
 * use for heightmaps
 */

public class HeightMapper {

  protected VertexBuffer vbuffer;
  protected IndexBuffer ibuffer;
  protected int stride;

  /**
   * override in your own subclass
   */
  public void handle(VertexBuffer vb, boolean cw, float ir, float jr) {}
  
  /**
   * constructor
   * @param vb vertex buffer
   * @param ib index buffer
   * @param stride stride length (maintained in mesh)
   */
  public HeightMapper(VertexBuffer vb, IndexBuffer ib, int stride) {
    vbuffer = vb;
    ibuffer = ib;
    this.stride = stride;
  }
  
  /**
   * execute a mapping
   * @param il, jl number of steps in each dimension
   * @param cw true if clockwise winding, false if ccw
   */
  public void run(int il, int jl, boolean cw) {
    int im = il - 1;
    int jm = jl - 1;
    int k = vbuffer.length / stride;
    int i, j;

    for (i = 0; i < il; i++) {
      for (j = 0; j < jl; j++, k++) {
        handle(vbuffer, cw, (float)i / (float)im, (float)j / (float)jm);
        if (i < im && j < jm) {
          if (cw) {
            ibuffer.set((short)(k), (short)(k + jl), (short)(k + 1));
            ibuffer.set((short)(k + jl), (short)(k + jl + 1), (short)(k + 1));
          } else {
            ibuffer.set((short)(k), (short)(k + 1), (short)(k + jl));
            ibuffer.set((short)(k + jl), (short)(k + 1), (short)(k + jl + 1));
          }
        }
      }
    }
  }
  
}




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