SimplePlane.java :  » Graphics-3D-2D-OpenGL » my-opengl-texture-test » com » pdager » opengl » mesh » Android Open Source

Android Open Source » Graphics 3D 2D OpenGL » my opengl texture test 
my opengl texture test » com » pdager » opengl » mesh » SimplePlane.java
package com.pdager.opengl.mesh;

/*Copyright 2010 Per-Erik Bergman (per-erik.bergman@jayway.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *     */

public class SimplePlane extends Mesh {

  /**
   * Create a plane with a default with and height of 1 unit.
   */
  public SimplePlane() {
    this(1, 1);
  }

  /**
   * Create a plane.
   */
  public SimplePlane(float width, float height) {
    // Mapping coordinates for the vertices
    float textureCoordinates[] = { 
        0.0f, 1.0f, 
        1.0f, 1.0f, 
        0.0f, 0.0f, 
        1.0f, 0.0f, 
    };

    short[] indices = new short[] { 0, 1, 2, 1, 3, 2 };

    float[] vertices = new float[] { 
        -1.0f, -1.0f, 0.0f, 
         1.0f, -1.0f, 0.0f,
        -1.0f,  1.0f, 0.0f, 
         1.0f,  1.0f, 0.0f };

    setIndices(indices);
    setVertices(vertices);
    setTextureCoordinates(textureCoordinates);
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.