Want more features on Pastebin? Sign Up, it's FREE!
Guest

QuadArray: ArrayIndexOutOfBoundsException on TextureCoordinate set

By: a guest on Feb 13th, 2011  |  syntax: Java  |  size: 0.83 KB  |  views: 188  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. public Cube() {
  2.         faces = new Shape3D[6]; //yes there are more faces than just this one, but they're all the same, aside from vertices
  3.         QuadArray qa1 = new QuadArray(4, QuadArray.COORDINATES | QuadArray.TEXTURE_COORDINATE_2);
  4.         qa1.setCapability(QuadArray.ALLOW_TEXCOORD_READ);
  5.         qa1.setCapability(QuadArray.ALLOW_TEXCOORD_WRITE);
  6.         float[] coordinates1 = {-0.5f,-0.5f,-0.5f, 0.5f,-0.5f,-0.5f, 0.5f,-0.5f,0.5f, -0.5f,-0.5f,0.5f}; //bottom face
  7.         qa1.setCoordinates(0, coordinates1);
  8.         applyTextureCoords(qa1); //apply our coordinates
  9.         faces[0] = new Shape3D(qa1);
  10.         ...
  11. }
  12.  
  13. //...
  14. public void applyTextureCoords(QuadArray array) {
  15.         float[] textureCoordinates = {0.0f,0.0f, 1.0f,0.0f, 1.0f,1.0f, 0.0f,1.0f}; //all of them are going to be the same
  16.         array.setTextureCoordinates(QuadArray.TEXTURE_COORDINATE_2, 0, textureCoordinates);
  17. }
clone this paste RAW Paste Data