Package com.ardor3d.math

Examples of com.ardor3d.math.Rectangle2


        nrTextures++;

        parameterObject.setAtlasIndex(index);

        final Rectangle2 rectangle = node.getRectangle();
        final ByteBuffer data = dataBuffers.get(index);
        final ByteBuffer lightData = parameterObject.getTexture().getImage().getData(0);

        boolean hasAlpha = false;
        if (format == ImageDataFormat.RGBA) {
            hasAlpha = true;
        }

        for (int y = 0; y < textureHeight; y++) {
            for (int x = 0; x < textureWidth; x++) {
                setDataPixel(rectangle, textureWidth, textureHeight, lightData, data, y, x, hasAlpha);
            }
        }

        final WrapMode mode = parameterObject.getTexture().getWrap(WrapAxis.S);
        switch (mode) {
            case BorderClamp:
            case MirrorBorderClamp:
                final ReadOnlyColorRGBA col = parameterObject.getTexture().getBorderColor();
                borderClamp(data, rectangle, textureWidth, textureHeight, parameterObject, col);
                break;

            case Clamp:
            case MirrorClamp:
                borderClamp(data, rectangle, textureWidth, textureHeight, parameterObject, ColorRGBA.BLACK);
                break;

            case EdgeClamp:
            case MirrorEdgeClamp:
                edgeClamp(data, rectangle, textureWidth, textureHeight, parameterObject);
                break;

            case MirroredRepeat:
            case Repeat:
                repeat(data, rectangle, textureWidth, textureHeight, parameterObject);
                break;
            default:
        }

        final float invAtlasWidth = 1f / atlasWidth;
        final float invAtlasHeight = 1f / atlasHeight;

        final float diffX = textureWidth * invAtlasWidth;
        final float diffY = textureHeight * invAtlasHeight;

        final float offsetX = (rectangle.getX() + 1) * invAtlasWidth;
        final float offsetY = (rectangle.getY() + 1) * invAtlasHeight;

        parameterObject.setDiffX(diffX);
        parameterObject.setDiffY(diffY);
        parameterObject.setOffsetX(offsetX);
        parameterObject.setOffsetY(offsetY);
View Full Code Here


    private Rectangle2 localRectangle;

    private AtlasNode() {}

    public AtlasNode(final int width, final int height) {
        localRectangle = new Rectangle2(0, 0, width, height);
    }
View Full Code Here

            final int dw = localRectangle.getWidth() - rectangle.getWidth();
            final int dh = localRectangle.getHeight() - rectangle.getHeight();

            if (dw > dh) {
                child[0].localRectangle = new Rectangle2(localRectangle.getX(), localRectangle.getY(),
                        rectangle.getWidth(), localRectangle.getHeight());
                child[1].localRectangle = new Rectangle2(localRectangle.getX() + rectangle.getWidth(),
                        localRectangle.getY(), dw, localRectangle.getHeight());
            } else {
                child[0].localRectangle = new Rectangle2(localRectangle.getX(), localRectangle.getY(),
                        localRectangle.getWidth(), rectangle.getHeight());
                child[1].localRectangle = new Rectangle2(localRectangle.getX(), localRectangle.getY()
                        + rectangle.getHeight(), localRectangle.getWidth(), dh);
            }

            return child[0].insert(rectangle);
        }
View Full Code Here

    private void recursiveDrawNode(final Graphics2D g2, final AtlasNode node) {
        if (node == null) {
            return;
        }
        final Rectangle2 im = node.getRectangle();
        if (node.isSet()) {
            g2.setColor(Color.red);
        } else {
            g2.setColor(Color.green);
        }
        g2.fillRect(im.getX(), im.getY(), im.getWidth(), im.getHeight());
        if (node.isSet()) {
            g2.setColor(Color.red.darker());
        } else {
            g2.setColor(Color.green.darker());
        }
        g2.drawRect(im.getX(), im.getY(), im.getWidth(), im.getHeight());
        recursiveDrawNode(g2, node.getChild(0));
        recursiveDrawNode(g2, node.getChild(1));
    }
View Full Code Here

TOP

Related Classes of com.ardor3d.math.Rectangle2

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.