Android Open Source - OpenGlDraw_Android Shape Cube






From Project

Back to project page OpenGlDraw_Android.

License

The source code is released under:

GNU General Public License

If you think the Android project OpenGlDraw_Android 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.example.opengldraw.shapes;
//w w w.  j  a v a  2  s.c o  m
import com.example.opengldraw.utils.ShapeDataInterface;

public class ShapeCube extends Object implements ShapeDataInterface {

  float vertices[] = {
      -1.000000f, -1.000000f, 1.000000f,
      -1.000000f, -1.000000f, -1.000000f,
      1.000000f, -1.000000f, -1.000000f,
      1.000000f, -1.000000f, 1.000000f,
      -1.000000f, 1.000000f, 1.000000f,
      -1.000000f, 1.000000f, -1.000000f,
      1.000000f, 1.000000f, -1.000000f,
      1.000000f, 1.000000f, 1.000000f
  };

  /* set the materials to the same color values (or at least one of the materials) */
  float colors[] = {
      50/255f, 205/255f, 50/255f, 1.0f,  50/255f, 205/255f, 50/255f, 1.0f,  50/255f, 205/255f, 50/255f, 1.0f,
      50/255f, 205/255f, 50/255f, 1.0f,  50/255f, 205/255f, 50/255f, 1.0f,  50/255f, 205/255f, 50/255f, 1.0f,
      50/255f, 205/255f, 50/255f, 1.0f,  50/255f, 205/255f, 50/255f, 1.0f
  };

  short indices[] = {
      4, 5, 0,//1
      5, 6, 1,//2
      6, 7, 3,//3
      7, 4, 0,//4
      0, 1, 2,//5
      7, 6, 5,//6
      5, 1, 0,//1
      6, 2, 1,//2
      2, 6, 3,//3
      3, 7, 0,//4
      3, 0, 2,//5
      4, 7, 5//6
  };
  float normals[] = {
      -1.000000f, 0.000000f, 0.000000f,
      0.000000f, 0.000000f, -1.000000f,
      1.000000f, -0.000000f, 0.000000f,
      0.000000f, 0.000000f, 1.000000f,
      0.000000f, -1.000000f, 0.000000f,
      0.000000f, 1.000000f, 0.000000f };
  
  float textCoords[] = { 0 };
  
  @Override
  public float[] getVertices() {
    return vertices;
  }

  @Override
  public float[] getColors() {
    return colors;
  }

  @Override
  public float[] getNormals() {
    return normals;
  }

  @Override
  public short[] getDrawOrder() {
    return indices;
  }
  
  @Override
  public float[] getTextCoords() {
    return textCoords;
  }
}




Java Source Code List

com.example.opengldraw.MainActivity.java
com.example.opengldraw.gl.GLSurfaceViewDraw.java
com.example.opengldraw.gl.RendererDraw.java
com.example.opengldraw.gl.ShapeDrawer.java
com.example.opengldraw.shapes.FireEngine.java
com.example.opengldraw.shapes.ShapeCube.java
com.example.opengldraw.shapes.ShapeCup10Verts.java
com.example.opengldraw.shapes.ShapeCup64Verts.java
com.example.opengldraw.shapes.ShapeSquare.java
com.example.opengldraw.utils.IndexOrderObj.java
com.example.opengldraw.utils.ShapeDataInterface.java
com.example.opengldraw.utils.WavefrontObj.java