use of org.twak.camp.Tag in project chordatlas by twak.
the class SkelGen method tagWalls.
public static Profile tagWalls(Profile profile, float[] roofColor, SuperEdge se, Point2d s, Point2d e) {
MiniFacade mini;
if (se.toEdit == null) {
if (se.mini == null || (se.mini.isEmpty() && se.proceduralFacade == null))
mini = null;
else {
double[] range = findRange(se, s, e, se.proceduralFacade == null ? null : se.proceduralFacade.megafacade);
if (range == null)
mini = null;
else
mini = new Regularizer().go(se.mini, range[0], range[1], se.proceduralFacade);
}
} else
// second time through, use the edited results
mini = se.toEdit;
Tag wall = new WallTag(se.profLine, se.occlusions, mini), roof = new RoofTag(roofColor);
boolean first = true;
for (Loop<Bar> lb : profile.points) {
for (Loopable<Bar> ll : lb.loopableIterator()) {
Bar b = ll.get();
if (// || ll != lb.start && isRoof ( ll.getPrev().get() ) && b.start.distanceSquared( b.end ) < 16 )
isRoof(b))
b.tags.add(roof);
else {
if (first)
b.tags.add(new WallTag(se.profLine, se.occlusions, mini, true));
else
b.tags.add(wall);
}
}
first = false;
}
return profile;
}
use of org.twak.camp.Tag in project chordatlas by twak.
the class GreebleSkel method createMesh.
public void createMesh(Output output) {
float[] roofColor = new float[] { 0.3f, 0.3f, 0.3f, 1 }, wallColor = new float[] { 228 / 255f, 223 / 255f, 206 / 255f, 1.0f };
if (output.faces == null)
return;
double bestWallArea = 0, bestRoofArea = 0;
for (Face f : output.faces.values()) {
double area = Loopz.area3(f.getLoopL());
Tag t = getTag(f.profile, RoofTag.class);
if (t != null && area > bestRoofArea && ((RoofTag) t).color != null) {
roofColor = ((RoofTag) t).color;
bestRoofArea = area;
}
t = getTag(f.profile, WallTag.class);
if (t != null && area > bestWallArea && ((WallTag) t).color != null) {
wallColor = ((WallTag) t).color;
bestWallArea = area;
}
}
greebleGrid = new GreebleGrid(tweed, mbs = new MMeshBuilderCache());
output.addNonSkeletonSharedEdges(new RoofTag(roofColor));
edges(output, roofColor);
for (List<Face> chain : Campz.findChains(output)) {
// for ( Face f : output.faces.values() )
// mbs.get(roofColor).add3d( Loopz.insertInnerEdges( f.getLoopL() ), zToYup );
Optional<Tag> opt = chain.stream().flatMap(f -> f.profile.stream()).filter(tag -> tag instanceof WallTag).findAny();
WallTag wt = null;
Set<QuadF> features = new HashSet<>();
MiniFacade mf = null;
if (opt.isPresent() && (wt = (WallTag) opt.get()).miniFacade != null) {
MiniFacade mf2 = new MiniFacade(wt.miniFacade);
Line facadeLine;
{
Edge e = chain.get(0).edge;
// we might rotate the facade to apply a set of features to a different side of the building.
facadeLine = new Line(e.end.x, e.end.y, e.start.x, e.start.y);
}
if (TweedSettings.settings.snapFacadeWidth) {
// move/scale mf horizontally from mean-image-location to mesh-facade-location
double[] meshSE = findSE(wt.miniFacade, facadeLine, chain);
mf2.scaleX(meshSE[0], meshSE[1]);
}
// find window locations in 3 space
mf2.rects.values().stream().flatMap(f -> f.stream()).map(r -> new QuadF(r, facadeLine)).forEach(q -> features.add(q));
mf = mf2;
}
for (Face f : chain) {
face(f, mf, features, roofColor, wallColor);
}
for (QuadF w : features) if ((w.original.f == Feature.WINDOW || w.original.f == Feature.SHOP) && w.foundAll()) {
greebleGrid.createDormerWindow(w, mbs.WOOD, mbs.GLASS, (float) wt.sillDepth, (float) wt.sillHeight, (float) wt.corniceHeight, 0.6, 0.9);
}
// for ( String mName : mbs.cache.keySet() )
// for (float[] mCol : mbs.cache.get( mName ).keySet() )
// node.attachChild( mb2Geom( output, chain, mName, mCol ) );
greebleGrid.attachAll(node, chain, output, new ClickMe() {
@Override
public void clicked(Object data) {
try {
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
selected(output, node, findSuperEdge(output, chain));
}
});
} catch (Throwable th) {
th.printStackTrace();
}
}
});
}
}
use of org.twak.camp.Tag in project chordatlas by twak.
the class GreebleSkel method face.
private void face(Face f, MiniFacade mf, Set<QuadF> features, float[] roofColor, float[] wallColor) {
MatMeshBuilder faceColor = mbs.ERROR;
WallTag wallTag = null;
for (Tag t : f.profile) {
if (t instanceof WallTag) {
wallTag = ((WallTag) t);
faceColor = greebleGrid.mbs.get("brick", wallTag.color != null ? wallTag.color : wallColor);
} else if (t instanceof RoofTag) {
RoofTag rt = (RoofTag) t;
faceColor = greebleGrid.mbs.get("tile", rt.color != null ? rt.color : roofColor);
}
}
if (f.edge.getPlaneNormal().angle(new Vector3d(0, 0, 1)) < 0.1)
wallTag = null;
for (Loop<Point3d> ll : f.getLoopL()) {
for (Loopable<Point3d> lll : ll.loopableIterator()) if (lll.get().distance(lll.getNext().get()) > 200)
return;
}
for (Loop<LPoint3d> ll : GreebleHelper.findPerimeter(f)) {
if (wallTag != null)
wallTag.isGroundFloor = f.definingCorners.iterator().next().z < 1;
mapTo2d(f, ll, mf, wallTag, features, faceColor);
}
}
Aggregations