Search in sources :

Example 1 with Griddable

use of org.twak.viewTrace.facades.Grid.Griddable in project chordatlas by twak.

the class GreebleGrid method textureGrid.

protected void textureGrid(DRectangle all, Matrix4d to3d, MiniFacade mf) {
    if (mf != null && mf.texture != null) {
        Grid g = new Grid(.10, all.x, all.getMaxX(), all.y, all.getMaxY());
        MatMeshBuilder mmb = mbs.get("texture_" + mf.texture, mf.texture);
        mmb.spec = mf.spec;
        mmb.normal = mf.normal;
        for (FRect w : mf.rects.get(Feature.WINDOW)) {
            if (all.contains(w))
                g.insert(w, new Griddable() {

                    @Override
                    public void instance(DRectangle rect) {
                        createInnie(rect, all.normalize(rect), to3d, mmb, 0.2f);
                    }
                });
        }
        for (FRect w : mf.rects.get(Feature.DOOR)) {
            if (all.contains(w))
                g.insert(w, new Griddable() {

                    @Override
                    public void instance(DRectangle rect) {
                        createInnie(rect, all.normalize(rect), to3d, mmb, 0.5f);
                    }
                });
        }
        for (FRect w : mf.getRects(Feature.MOULDING, Feature.CORNICE, Feature.SILL)) {
            if (all.contains(w))
                g.insert(w, new Griddable() {

                    @Override
                    public void instance(DRectangle rect) {
                        createInnie(rect, all.normalize(rect), to3d, mmb, -0.2f);
                    }
                });
        }
        for (DRectangle b : mf.rects.get(Feature.BALCONY)) {
            if (all.contains(b))
                g.insert(b, new Griddable() {

                    @Override
                    public void instance(DRectangle rect) {
                        createBalcony(rect, to3d, mbs.BALCONY, 0.3);
                    }

                    @Override
                    public boolean noneBehind() {
                        return true;
                    }
                });
        }
        g.instance(new Griddable() {

            @Override
            public void instance(DRectangle rect) {
                mmb.add(rect, all.normalize(rect), to3d);
            }
        });
    }
}
Also used : DRectangle(org.twak.utils.geom.DRectangle) Griddable(org.twak.viewTrace.facades.Grid.Griddable)

Example 2 with Griddable

use of org.twak.viewTrace.facades.Grid.Griddable in project chordatlas by twak.

the class GreebleGrid method buildGrid.

protected void buildGrid(DRectangle all, Matrix4d to3d, MiniFacade mf, MeshBuilder wallColorMat, WallTag wallTag) {
    Grid g = new Grid(.10, all.x, all.getMaxX(), all.y, all.getMaxY());
    if (mf != null) {
        for (FRect w : mf.rects.get(Feature.WINDOW)) {
            if (all.contains(w))
                g.insert(w, new Griddable() {

                    @Override
                    public void instance(DRectangle rect) {
                        createWindow(rect, to3d, wallColorMat, mbs.WOOD, mbs.GLASS, wallTag.windowDepth, (float) wallTag.sillDepth, (float) w.attachedHeight.get(Feature.SILL).d, (float) w.attachedHeight.get(Feature.CORNICE).d, 0.6, 0.9);
                    }
                });
            double bHeight = w.attachedHeight.get(Feature.BALCONY).d;
            if (bHeight > 0) {
                DRectangle balcon = new DRectangle();
                balcon.setFrom(w);
                balcon.grow(0.2);
                balcon.height = bHeight;
                createBalcony(balcon, to3d, mbs.BALCONY, wallTag.balconyDepth);
            }
        }
        for (FRect s_ : mf.rects.get(Feature.SHOP)) {
            FRect s = new FRect(s_);
            DRectangle rect = all.intersect(s);
            if (rect != null) {
                s.setFrom(rect);
                g.insert(s, new Griddable() {

                    @Override
                    public void instance(DRectangle rect) {
                        createWindow(rect, to3d, wallColorMat, mbs.WOOD, mbs.GLASS, wallTag.windowDepth, (float) wallTag.sillDepth, (float) s.attachedHeight.get(Feature.SILL).d, (float) s.attachedHeight.get(Feature.CORNICE).d, 1.5, 2);
                    }
                });
            }
        }
        for (DRectangle d : mf.rects.get(Feature.DOOR)) {
            if (all.contains(d))
                g.insert(d, new Griddable() {

                    @Override
                    public void instance(DRectangle rect) {
                        createDoor(rect, to3d, wallColorMat, mbs.get("wood", new float[] { 0, 0, 0.3f, 1 }), wallTag.doorDepth);
                    }
                });
        }
        for (DRectangle b : mf.rects.get(Feature.BALCONY)) {
            if (all.contains(b))
                g.insert(b, new Griddable() {

                    @Override
                    public void instance(DRectangle rect) {
                        createBalcony(rect, to3d, mbs.BALCONY, wallTag.balconyDepth);
                    }

                    @Override
                    public boolean noneBehind() {
                        return true;
                    }
                });
        }
        for (DRectangle b : mf.rects.get(Feature.MOULDING)) {
            if (all.contains(b))
                g.insert(b, new Griddable() {

                    @Override
                    public void instance(DRectangle rect) {
                        moulding(to3d, rect, mbs.MOULDING);
                    }
                });
        }
    }
    g.instance(new Griddable() {

        @Override
        public void instance(DRectangle rect) {
            wallColorMat.add(rect, to3d);
        }
    });
}
Also used : DRectangle(org.twak.utils.geom.DRectangle) Griddable(org.twak.viewTrace.facades.Grid.Griddable)

Aggregations

DRectangle (org.twak.utils.geom.DRectangle)2 Griddable (org.twak.viewTrace.facades.Grid.Griddable)2