Android Open Source - 4est Index Buffer






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;
/*from  w  w w .j a v  a 2s.  co  m*/
/**
 * growable short int buffer
 * 
 * @namespace rise
 * @class IndexBuffer
 */

public class IndexBuffer {

  public short[] data;
  public int length;
  
  final static private double LN2 = Math.log(2);
  private int limit;
  
  public IndexBuffer() {
    data = new short[16];
    length = 0;
  }
  
  /**
   * grow the vertex buffer if necessary
   * @param n number of shorts to grow by
   */
  private void grow(int n) {
    int newSize = length + n;
    if (newSize > limit) {
      // find smallest power of 2 greater than newSize
      limit = (int) Math.pow(2, Math.ceil(Math.log(newSize) / LN2));
      short[] newBuffer = new short[limit];
      System.arraycopy(data, 0, newBuffer, 0, length);
      data = newBuffer;
    }
  }
  
  /**
   * reset the mesh for use with a new data set
   */
  public void reset() {
    length = 0;
  }
  
  /**
   * add values to the buffer
   * @param i0...in values to add
   */
  
  public void set(int i0) {
    grow(1);
    data[length++] = (short)i0;
  }
  
  public void set(int i0, int i1, int i2) {
    grow(3);
    data[length++] = (short)i0;
    data[length++] = (short)i1;
    data[length++] = (short)i2;
  }

  public void set(int i0, int i1, int i2, int i3, int i4, int i5) {
    grow(6);
    data[length++] = (short)i0;
    data[length++] = (short)i1;
    data[length++] = (short)i2;
    data[length++] = (short)i3;
    data[length++] = (short)i4;
    data[length++] = (short)i5;
  }
}




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