Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public TextureBox(Context context, float ext_X, float ext_Y, float ext_Z,int[] imgsID, int texture_scale) {
- super(12);
- if (imgsID.length != 6)
- throw new IllegalArgumentException();
- SimpleVector upperLeftFront = new SimpleVector(-ext_X, -ext_Y, -ext_Z);
- SimpleVector upperRightFront = new SimpleVector(ext_X, -ext_Y, -ext_Z);
- SimpleVector lowerLeftFront = new SimpleVector(-ext_X, ext_Y, -ext_Z);
- SimpleVector lowerRightFront = new SimpleVector(ext_X, ext_Y, -ext_Z);
- SimpleVector upperLeftBack = new SimpleVector(-ext_X, -ext_Y, ext_Z);
- SimpleVector upperRightBack = new SimpleVector(ext_X, -ext_Y, ext_Z);
- SimpleVector lowerLeftBack = new SimpleVector(-ext_X, ext_Y, ext_Z);
- SimpleVector lowerRightBack = new SimpleVector(ext_X, ext_Y, ext_Z);
- //method that return an array of strings with and ID append
- String[] faces = getFacesStringArray();
- TextureManager t_manager = TextureManager.getInstance();
- Texture texture;
- for (int i = 0; i < imgsID.length; i++) {
- texture = new Texture(BitmapHelper.BitmapHelper.convert(context.getResources().getDrawable(imgsID[i])), 64, 64));
- t_manager.addTexture(faces[i], texture);
- }
- // Front
- addTriangle(upperLeftFront, 0, 0, lowerLeftFront, 0, texture_scale,
- upperRightFront, texture_scale, 0, t_manager.getTextureID(faces[0]));
- addTriangle(upperRightFront, texture_scale, 0, lowerLeftFront, 0, texture_scale,
- lowerRightFront, texture_scale, texture_scale, t_manager.getTextureID(faces[0]));
- // Back
- addTriangle(upperLeftBack, 0, 0, upperRightBack, texture_scale, 0,
- lowerLeftBack, 0, texture_scale, t_manager.getTextureID(faces[1]));
- addTriangle(upperRightBack, texture_scale, 0, lowerRightBack, texture_scale, texture_scale,
- lowerLeftBack, 0, texture_scale, t_manager.getTextureID(faces[1]));
- // Upper
- addTriangle(upperLeftBack, 0, 0, upperLeftFront, 0, texture_scale,
- upperRightBack, texture_scale, 0, t_manager.getTextureID(faces[2]));
- addTriangle(upperRightBack, texture_scale, 0, upperLeftFront, 0, texture_scale,
- upperRightFront, texture_scale, texture_scale, t_manager.getTextureID(faces[2]));
- // Lower
- addTriangle(lowerLeftBack, 0, 0, lowerRightBack, texture_scale, 0,
- lowerLeftFront, 0, texture_scale, t_manager.getTextureID(faces[3]));
- addTriangle(lowerRightBack, texture_scale, 0, lowerRightFront, texture_scale, texture_scale,
- lowerLeftFront, 0, texture_scale, t_manager.getTextureID(faces[3]));
- // Left
- addTriangle(upperLeftFront, 0, 0, upperLeftBack, texture_scale, 0,
- lowerLeftFront, 0, texture_scale, t_manager.getTextureID(faces[4]));
- addTriangle(upperLeftBack, texture_scale, 0, lowerLeftBack, texture_scale, texture_scale,
- lowerLeftFront, 0, texture_scale, t_manager.getTextureID(faces[4]));
- // Right
- addTriangle(upperRightFront, 0, 0, lowerRightFront, 0, texture_scale,
- upperRightBack, texture_scale, 0, t_manager.getTextureID(faces[3]));
- addTriangle(upperRightBack, texture_scale, 0, lowerRightFront, 0, texture_scale,
- lowerRightBack, texture_scale, texture_scale, t_manager.getTextureID(faces[3]));
- build();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement