Advertisement
Guest User

jCPT textureBox

a guest
Sep 27th, 2011
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.11 KB | None | 0 0
  1.     public TextureBox(Context context, float ext_X, float ext_Y, float ext_Z,int[] imgsID, int texture_scale) {
  2.         super(12);
  3.         if (imgsID.length != 6)
  4.             throw new IllegalArgumentException();
  5.        
  6.         SimpleVector upperLeftFront = new SimpleVector(-ext_X, -ext_Y, -ext_Z);
  7.         SimpleVector upperRightFront = new SimpleVector(ext_X, -ext_Y, -ext_Z);
  8.         SimpleVector lowerLeftFront = new SimpleVector(-ext_X, ext_Y, -ext_Z);
  9.         SimpleVector lowerRightFront = new SimpleVector(ext_X, ext_Y, -ext_Z);
  10.  
  11.         SimpleVector upperLeftBack = new SimpleVector(-ext_X, -ext_Y, ext_Z);
  12.         SimpleVector upperRightBack = new SimpleVector(ext_X, -ext_Y, ext_Z);
  13.         SimpleVector lowerLeftBack = new SimpleVector(-ext_X, ext_Y, ext_Z);
  14.         SimpleVector lowerRightBack = new SimpleVector(ext_X, ext_Y, ext_Z);
  15.        
  16.         //method that return an array of strings with and ID append
  17.         String[] faces = getFacesStringArray();
  18.         TextureManager t_manager = TextureManager.getInstance();
  19.         Texture texture;
  20.         for (int i = 0; i < imgsID.length; i++) {
  21.             texture = new Texture(BitmapHelper.BitmapHelper.convert(context.getResources().getDrawable(imgsID[i])), 64, 64));  
  22.             t_manager.addTexture(faces[i], texture);  
  23.         }
  24.        
  25.         // Front
  26.         addTriangle(upperLeftFront, 0, 0, lowerLeftFront, 0, texture_scale,
  27.                 upperRightFront, texture_scale, 0, t_manager.getTextureID(faces[0]));
  28.         addTriangle(upperRightFront, texture_scale, 0, lowerLeftFront, 0, texture_scale,
  29.                 lowerRightFront, texture_scale, texture_scale, t_manager.getTextureID(faces[0]));
  30.  
  31.         // Back
  32.         addTriangle(upperLeftBack, 0, 0, upperRightBack, texture_scale, 0,
  33.                 lowerLeftBack, 0, texture_scale, t_manager.getTextureID(faces[1]));
  34.         addTriangle(upperRightBack, texture_scale, 0, lowerRightBack, texture_scale, texture_scale,
  35.                 lowerLeftBack, 0, texture_scale, t_manager.getTextureID(faces[1]));
  36.  
  37.         // Upper
  38.         addTriangle(upperLeftBack, 0, 0, upperLeftFront, 0, texture_scale,
  39.                 upperRightBack, texture_scale, 0, t_manager.getTextureID(faces[2]));
  40.         addTriangle(upperRightBack, texture_scale, 0, upperLeftFront, 0, texture_scale,
  41.                 upperRightFront, texture_scale, texture_scale, t_manager.getTextureID(faces[2]));
  42.  
  43.         // Lower
  44.         addTriangle(lowerLeftBack, 0, 0, lowerRightBack, texture_scale, 0,
  45.                 lowerLeftFront, 0, texture_scale, t_manager.getTextureID(faces[3]));
  46.         addTriangle(lowerRightBack, texture_scale, 0, lowerRightFront, texture_scale, texture_scale,
  47.                 lowerLeftFront, 0, texture_scale, t_manager.getTextureID(faces[3]));
  48.  
  49.         // Left
  50.         addTriangle(upperLeftFront, 0, 0, upperLeftBack, texture_scale, 0,
  51.                 lowerLeftFront, 0, texture_scale, t_manager.getTextureID(faces[4]));
  52.         addTriangle(upperLeftBack, texture_scale, 0, lowerLeftBack, texture_scale, texture_scale,
  53.                 lowerLeftFront, 0, texture_scale, t_manager.getTextureID(faces[4]));
  54.  
  55.         // Right
  56.         addTriangle(upperRightFront, 0, 0, lowerRightFront, 0, texture_scale,
  57.                 upperRightBack, texture_scale, 0, t_manager.getTextureID(faces[3]));
  58.         addTriangle(upperRightBack, texture_scale, 0, lowerRightFront, 0, texture_scale,
  59.                 lowerRightBack, texture_scale, texture_scale, t_manager.getTextureID(faces[3]));
  60.        
  61.         build();
  62.     }
  63.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement