Package org.terasology.math

Examples of org.terasology.math.Rect2f


                    requestedCropRegion.minY(), requestedCropRegion.maxY() + 1);
            currentTextureCropRegion = requestedCropRegion;
        }

        Vector2f scale = mode.scaleForRegion(absoluteRegion, texture.getWidth(), texture.getHeight());
        Rect2f textureArea = texture.getRegion();
        Mesh mesh = billboard;
        switch (mode) {
            case TILED: {
                TextureCacheKey key = new TextureCacheKey(texture.size(), absoluteRegion.size());
                usedTextures.add(key);
                mesh = cachedTextures.get(key);
                if (mesh == null || mesh.isDisposed()) {
                    MeshBuilder builder = new MeshBuilder();
                    addTiles(builder, absoluteRegion, FULL_REGION, texture.size(), FULL_REGION);
                    mesh = builder.build();
                    cachedTextures.put(key, mesh);
                }
                textureMat.setFloat2("scale", scale);
                textureMat.setFloat2("offset",
                        absoluteRegion.minX(),
                        absoluteRegion.minY());

                textureMat.setFloat2("texOffset", textureArea.minX() + ux * textureArea.width(), textureArea.minY() + uy * textureArea.height());
                textureMat.setFloat2("texSize", uw * textureArea.width(), uh * textureArea.height());
                break;
            }
            case SCALE_FILL: {
                textureMat.setFloat2("offset", absoluteRegion.minX(), absoluteRegion.minY());
                textureMat.setFloat2("scale", absoluteRegion.width(), absoluteRegion.height());

                float texBorderX = (scale.x - absoluteRegion.width()) / scale.x * uw;
                float texBorderY = (scale.y - absoluteRegion.height()) / scale.y * uh;

                textureMat.setFloat2("texOffset", textureArea.minX() + (ux + 0.5f * texBorderX) * textureArea.width()
                        , textureArea.minY() + (uy + 0.5f * texBorderY) * textureArea.height());
                textureMat.setFloat2("texSize", (uw - texBorderX) * textureArea.width(), (uh - texBorderY) * textureArea.height());
                break;
            }
            default: {
                textureMat.setFloat2("scale", scale);
                textureMat.setFloat2("offset",
                        absoluteRegion.minX() + 0.5f * (absoluteRegion.width() - scale.x),
                        absoluteRegion.minY() + 0.5f * (absoluteRegion.height() - scale.y));

                textureMat.setFloat2("texOffset", textureArea.minX() + ux * textureArea.width(), textureArea.minY() + uy * textureArea.height());
                textureMat.setFloat2("texSize", uw * textureArea.width(), uh * textureArea.height());
                break;
            }
        }

        textureMat.setTexture("texture", texture.getTexture());
View Full Code Here


            cachedTextures.put(key, mesh);
        }
        textureMat.setFloat2("scale", region.width(), region.height());
        textureMat.setFloat2("offset", region.minX(), region.minY());

        Rect2f textureArea = texture.getRegion();
        textureMat.setFloat2("texOffset", textureArea.minX() + ux * textureArea.width(), textureArea.minY() + uy * textureArea.height());
        textureMat.setFloat2("texSize", uw * textureArea.width(), uh * textureArea.height());

        textureMat.setTexture("texture", texture.getTexture());
        textureMat.setFloat4("color", 1, 1, 1, alpha);
        textureMat.bindTextures();
        mesh.render();
View Full Code Here

        for (String name : grid.getTileNames()) {
            if (!name.isEmpty()) {
                Vector2f pos = new Vector2f(offset);
                pos.x += tileX * tileSize.x;
                pos.y += tileY * tileSize.y;
                Rect2f tileLocation = Rect2f.createFromMinAndSize(offset.x + tileX * tileSize.x, offset.y + tileY * tileSize.y, tileSize.x, tileSize.y);
                out.put(new Name(name), new SubtextureData(texture, tileLocation));
            }

            tileX++;
            if (tileX == grid.getGridDimensions().x) {
View Full Code Here

TOP

Related Classes of org.terasology.math.Rect2f

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.