use of javax.vecmath.Point2d in project chordatlas by twak.
the class SliceSolver method dataFit.
private static double dataFit(LineSoup filtered, LoopL<Point2d> out) {
if (out.isEmpty() || filtered.all.isEmpty())
return Double.MAX_VALUE;
double totalDist = 0;
for (Line sl : filtered.all) {
double bestDist = Double.MAX_VALUE;
for (Loop<Point2d> loop : out) for (Loopable<Point2d> ll : loop.loopableIterator()) bestDist = Math.min(bestDist, new Line(ll.get(), ll.getNext().get()).distance(sl));
totalDist += bestDist;
}
return totalDist / filtered.all.size();
}
use of javax.vecmath.Point2d in project chordatlas by twak.
the class FRect method mouseDragged.
@Override
public void mouseDragged(MouseEvent e, PanMouseAdaptor ma) {
Point2d pt = flip(ma.from(e));
Point2d delta = new Point2d(pt);
delta.sub(lastPoint);
if (dragging == null) {
Point2d n = new Point2d(get(Bounds.XCEN) + delta.x, get(Bounds.YCEN) + delta.y);
set(Bounds.XCEN, n.x);
set(Bounds.YCEN, n.y);
} else {
double value = get(dragging) + (dragging.name().charAt(0) == 'Y' ? delta.y : delta.x);
set(dragging, value, true);
}
lastPoint = pt;
}
use of javax.vecmath.Point2d in project chordatlas by twak.
the class GreebleCGA method cga.
protected double cga(Loop<Point2d> rect, Matrix4d to3d, WallTag wallTag, MeshBuilder normalWall, MeshBuilder ground, Cache<float[], MeshBuilder> mbs, List<DRectangle> occlusions) {
double[] bounds = Loopz.minMax2d(rect);
GreebleGrid gg = new GreebleGrid(tweed, new MMeshBuilderCache());
DRectangle all = new DRectangle(bounds[0], bounds[2], bounds[1] - bounds[0], bounds[3] - bounds[2]);
// for (DRectangle d : occlusions)
// mbs.get( new float[] {1,1,0,1} ).add( d, to3d );
float[] windowColor = new float[] { 0.8f, .8f, 0.8f, 1 }, glassColor = new float[] { 0.3f, 0.3f, 1, 1 }, mouldingColor = new float[] { 0.7f, .7f, 0.7f, 1 };
double groundFloorHeight = 0;
List<DRectangle> floors = all.splitY(r -> splitFloors(r, 3, 2.5, 2));
for (int f = 0; f < floors.size(); f++) {
boolean isGround = f == 0 && wallTag.isGroundFloor;
DRectangle floor = floors.get(f);
MeshBuilder wall = isGround ? ground : normalWall;
List<DRectangle> edges = floor.splitX(r -> split3(r, 1, 1));
if (isGround)
groundFloorHeight = floor.height;
if (edges.size() != 3) {
wall.add(floor, to3d);
} else {
wall.add(edges.get(0), to3d);
wall.add(edges.get(edges.size() - 1), to3d);
DRectangle cen = edges.get(1);
if (cen.height < 1.8)
wall.add(cen, to3d);
else {
if (f == 0 && wallTag.isGroundFloor) {
List<DRectangle> groundPanel = cen.splitX(r -> split1(r, 0.9));
if (groundPanel.get(0).width < 0.7)
wall.add(groundPanel.get(0), to3d);
else if (wallTag.makeDoor) {
List<DRectangle> doorHeight = groundPanel.get(0).splitY(r -> split1(r, 2.2));
if (visible(doorHeight.get(0), occlusions))
greebleGrid.createDoor(doorHeight.get(0), to3d, wall, mbs.get(windowColor), wallTag.doorDepth);
else
wall.add(doorHeight.get(0), to3d);
if (doorHeight.size() > 1)
wall.add(doorHeight.get(1), to3d);
if (groundPanel.size() > 1) {
List<DRectangle> gWindowPanelH = groundPanel.get(1).splitX(r -> split3(r, 0.5, 0.0));
if (gWindowPanelH.size() > 2) {
wall.add(gWindowPanelH.get(0), to3d);
wall.add(gWindowPanelH.get(2), to3d);
List<DRectangle> gWindowPanelV = gWindowPanelH.get(1).splitY(r -> split3(r, 0.5, 0.5));
if (gWindowPanelV.size() > 2) {
wall.add(gWindowPanelV.get(0), to3d);
wall.add(gWindowPanelV.get(2), to3d);
if (visible(gWindowPanelV.get(1), occlusions))
greebleGrid.createWindow(gWindowPanelV.get(1), to3d, wall, mbs.get(windowColor), mbs.get(glassColor), wallTag.windowDepth, -1, -1, -1, 0.6, 0.9);
else
wall.add(gWindowPanelV.get(1), to3d);
} else
for (DRectangle d : gWindowPanelV) wall.add(d, to3d);
} else
for (DRectangle d : gWindowPanelH) wall.add(d, to3d);
}
} else
windowStrip(to3d, wallTag, mbs.get(windowColor), mbs.get(glassColor), wall, cen, false, occlusions, greebleGrid);
} else {
windowStrip(to3d, wallTag, mbs.get(windowColor), mbs.get(glassColor), wall, cen, f > 0 && f < floors.size() - 1 && wallTag.makeBalcony, occlusions, greebleGrid);
if (f == 1 && wallTag.isGroundFloor)
greebleGrid.moulding(to3d, new DRectangle(floor.x, floor.y, floor.width, 0.5), mbs.get(mouldingColor));
}
}
}
}
return groundFloorHeight;
}
use of javax.vecmath.Point2d in project chordatlas by twak.
the class FacadeTool method facadeSelected.
public void facadeSelected(LoopL<Point3d> list, BlockGen block) {
// if (block == null) {
// JOptionPane.showMessageDialog( null, "generate mesh for block first" );
// return;
// }
// Polygonz.findBounds( polies, min, max );
double[] minMax = Loopz.minMax(list);
Loopz.expand(minMax, 30);
Map<Point2d, Pano> panos = new HashMap<>();
for (Gen gen : tweed.frame.gens(PanoGen.class)) for (Pano pg : ((PanoGen) gen).getPanos()) {
Point2d pt = new Point2d(pg.location.x, pg.location.z);
if (pt.x > minMax[0] && pt.x < minMax[1] && pt.y > minMax[4] && pt.y < minMax[5])
panos.put(pt, pg);
}
List<Point3d> objPoints = null;
if (block != null) {
objPoints = new ObjRead(block.getCroppedFile()).points();
}
FacadeFinder ff = new FacadeFinder(Loopz.toXZLoop(list), panos, objPoints, block, tweed.frame.getGenOf(PlanesGen.class));
Point2d cen = Loopz.average(Loopz.to2dLoop(list, 1, null));
renderFacades(block == null ? null : block.gNode, cen.x + "_" + cen.y, ff);
}
use of javax.vecmath.Point2d in project chordatlas by twak.
the class HouseTool method clickedOn.
@Override
public void clickedOn(Spatial target, Vector3f loc, Vector2f cursorPosition) {
// (Line) new XStream().fromXML( new File( "/home/twak/data/regent/March_30/congo/1/line.xml" ) ));
MegaFeatures mf = new MegaFeatures(new Line(0, 0, 10, 0));
// FeatureCache.readFeatures( new File( "/home/twak/data/regent/March_30/congo/1/0" ), mf );
ImageFeatures imf = new ImageFeatures();
imf.mega = mf;
double[] minMax = new double[] { 0, 15, 0, 25 };
HalfMesh2.Builder builder = new HalfMesh2.Builder(SuperEdge.class, SuperFace.class);
builder.newPoint(new Point2d(minMax[0] + loc.x, minMax[3] + loc.z));
builder.newPoint(new Point2d(minMax[1] + loc.x, minMax[3] + loc.z));
builder.newPoint(new Point2d(minMax[1] + loc.x, minMax[2] + loc.z));
builder.newPoint(new Point2d(minMax[0] + loc.x, minMax[2] + loc.z));
builder.newFace();
HalfMesh2 mesh = builder.done();
Prof p = new Prof();
p.add(new Point2d(0, 0));
p.add(new Point2d(0, 20));
p.add(new Point2d(-5, 25));
boolean first = true;
for (HalfFace f : mesh) {
for (HalfEdge e : f) {
SuperEdge se = (SuperEdge) e;
se.prof = p;
MiniFacade mini = newMini(imf, se.length());
if (true) {
se.addMini(mini);
se.proceduralFacade = mf;
se.toEdit = mini;
if (first)
se.addMini(mini);
}
first = false;
}
SuperFace sf = (SuperFace) f;
sf.maxProfHeights = new ArrayList();
sf.maxProfHeights.add(Double.valueOf(100));
sf.height = 100;
}
SkelGen sg = new SkelGen(mesh, tweed, null);
tweed.frame.addGen(sg, true);
}
Aggregations