need some math help (uv wrap/statue related)

Discussion in 'Plugin Development' started by xize, Jul 18, 2014.

Thread Status:
Not open for further replies.
  1. Offline



    so I'm absolutely not the best in math but I know it should be possible.

    I'm trying to uv wrap image data to a statue by using the cropped images to make a basic cuboid model first, but now I wonder how would I calculate it so that it gets the correct pixel from the full image rather than the cropped ones?

    from what ive seen for example with schematics it had a special way of calculating the data such like int data = width * length - height, forgive me for the bad math:p

    I'm pretty sure the same principe of doing that works on images to, but I'm clueless what I need todo there.

    my code what ive already(yes I know it only does it for one leg rather than 2, need to understand first how wrapping works)

    public class LegsComponent {
        private final BufferedImage image;
        private final Location loc;
        public LegsComponent(BufferedImage image, Location loc) {
            this.image = image;
            this.loc = loc;
        public BufferedImage getCroppedRightLeg() {
            return crop(0, 20, 4, 32);
        public BufferedImage getCroppedFrontLeg() {
            return crop(4, 20, 8, 32);
        public BufferedImage getCroppedLeftLeg() {
            return crop(8, 20, 12, 32);
        public BufferedImage getCroppedBackLeg() {
            return crop(12, 20, 16, 32);
        public LinkedHashMap<Location, String> getLegs() {
            LinkedHashMap<Location, String> hash = new LinkedHashMap<Location, String>();
            int height = getCroppedFrontLeg().getHeight();
            int width = getCroppedFrontLeg().getWidth();
            int length = getCroppedLeftLeg().getWidth();
            Location loc1 = loc.clone();
            for(int y = 0; y < height; y++) {
                for(int x = 0; x < width; x++) {
                    for(int z = 0; z < length; z++) {
                        //here I need to get the pixel from the full 'image' field.
            return hash;
        private BufferedImage crop(int minX, int minY, int maxX, int maxY) {
            BufferedImage img = image.getSubimage(minX, minY, maxX, maxY);
            BufferedImage copy = new BufferedImage(img.getWidth(), img.getHeight(), BufferedImage.TYPE_INT_RGB);
            Graphics g = copy.createGraphics();
            return img;
    the field above the constructor called image is the full image and is linked from

    any help is apreciated, or better workarounds are welcome:)

Thread Status:
Not open for further replies.

Share This Page