use of org.twak.tweed.gen.SuperEdge in project chordatlas by twak.
the class SuperMeshPainter method paint.
@Override
public void paint(Object oa, Graphics2D g2, PanMouseAdaptor ma) {
HalfMesh2 o = (HalfMesh2) oa;
double scatterRadius = 0.0;
if (o.faces.isEmpty())
return;
double maxHeight = o.faces.stream().mapToDouble(x -> ((SuperFace) x).height).max().getAsDouble();
// (int) ( Math.random() * 100 );
int fc = 0;
for (HalfFace f : o.faces) {
fc++;
Polygon pwt = new Polygon();
try {
for (HalfEdge e : f.edges()) {
pwt.addPoint(ma.toX(e.start.x + Math.random() * scatterRadius), ma.toY(e.start.y + Math.random() * scatterRadius));
// PaintThing.paint(e.start, g2, ma);
}
} catch (Throwable t) {
t.printStackTrace();
}
SuperFace sf = (SuperFace) f;
Color c;
if (false) {
int h = (int) Mathz.clamp(((SuperFace) f).height * 5, 0, 255);
if (((SuperFace) f).height == -Double.MAX_VALUE)
c = Color.green;
else if (((SuperFace) f).height < 0)
c = Color.red;
else
c = new Color(h, h, h);
} else if (sf.height == -Double.MAX_VALUE) {
c = Color.yellow;
} else if (sf.classification == -1 || sf.height < 0) {
c = Color.red;
} else {
// c = Color.white;
c = Rainbow.getColour(sf.classification + 1);
// c = Rainbow.getColour( fc++ + 1 );
}
// c = Color.white;
// new Color( c.getRed(), c.getGreen(), c.getBlue(), 50 ) );
g2.setColor(c);
g2.fill(pwt);
// Loop<Point2d> pts = new Loop<>();
// for ( HalfEdge e : f.edges() )
// pts.append(e.end);
//
// if ( ( Loopz.area( pts ) ) < 0.1 ) {
// g2.setColor(Color.red);
// g2.setStroke( new BasicStroke( 4f ) );
// g2.draw( pwt );
// }
}
for (HalfFace f : o.faces) {
g2.setColor(Color.black);
try {
for (HalfEdge e : f) {
SuperEdge se = (SuperEdge) e;
g2.setColor(Color.black);
if (se.proceduralFacade != null) {
g2.setStroke(new BasicStroke(3f));
} else {
g2.setStroke(new BasicStroke(1f));
}
// if ( se.profLine != null || ( se.over != null && ((SuperEdge)se.over).profLine != null ) ) {
// g2.setStroke( new BasicStroke( 2f ) );
// g2.setColor( new Color (255, 0, 0 ) );
// }
// else
// {
// g2.setStroke( new BasicStroke( 1f ) );
// g2.setColor( Color.black );
// }
// g2.setColor( ((SuperEdge)e).profLine == null? Color.green : Color.magenta);
// PaintThing.paint ( e.line(), g2, ma );
// }
}
} catch (Throwable th) {
th.printStackTrace();
}
g2.setStroke(new BasicStroke(3));
if (false)
for (HalfEdge e : f.edges()) {
SuperEdge se = (SuperEdge) e;
if (se.profLine != null) {
// g2.setColor( Color.BLACK );
// new Line (new Point2d (e.start), new Point2d (e.end));
Line l = se.line();
// PaintThing.drawArrow( g2, ma, l, 5 );
g2.drawLine(ma.toX(l.start.x), ma.toY(l.start.y), ma.toX(l.end.x), ma.toY(l.end.y));
}
// if (e.over != null)
// {
// l.moveLeft( ma.fromZoom( 2 ) );
//
// double delta = Math.abs ( ((SuperEdge)e).localHeight - ((SuperEdge)e.over).localHeight );
//
// int h = (int) Math.min(255, delta * 10 ) ;
// g2.setColor ( new Color (0,h,h) );
// g2.setStroke (new BasicStroke( 3f ));
//
// }
// if ( ( (SuperEdge) e ).debug ) {
// if ( e.over == null || ((SuperFace)e.over.face).classification != ((SuperFace)f).classification ) {
// g2.setColor( Color.black );
// g2.setStroke( new BasicStroke( 2 ) );
// PaintThing.paint( e.line(), g2, ma );
// }
}
}
fc = 0;
if (false)
for (HalfFace f : o.faces) {
for (HalfEdge e : f.edges()) {
// Point2d pt = new Point2d(e.start);
// pt.add( off );
// Point2d pt2 = new Point2d(e.end);
// pt2.add( off );
//
// PaintThing.paint( new Line (pt, pt2) , g2, ma );
g2.setColor(new Color(255, 0, 0, 20));
if (e.line().absAngle(e.next.line()) > Math.PI - 0.001) {
g2.setColor(new Color(0, 255, 0, 255));
}
PaintThing.paint(new Line(e.start, e.end), g2, ma);
PaintThing.paint(new Line(e.next.start, e.next.end), g2, ma);
}
// for ( HalfEdge e : f.edges() ) {
// PaintThing.drawArrow( g2, ma, e.line(), 5 );
// }
}
if (false)
for (HalfFace f : o.faces) for (HalfEdge e : f.edges()) {
if (e.face != f || (e.over != null && (e.over.over != e || !o.faces.contains(e.over.face))) || e.face == null || e.start == null || e.end == null || e.next == null) {
g2.setColor(Color.red);
g2.setStroke(new BasicStroke(4));
PaintThing.paint(e.line(), g2, ma);
}
}
}
use of org.twak.tweed.gen.SuperEdge 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);
}
use of org.twak.tweed.gen.SuperEdge in project chordatlas by twak.
the class SkelGen method buildCamp.
private static PlanSkeleton buildCamp(SuperFace sf, Double cap) {
Plan plan = new Plan();
LoopL<Bar> loopl = new LoopL();
Loop<Bar> loop = new Loop();
loopl.add(loop);
Cache<Point2d, Point2d> cache = new Cache<Point2d, Point2d>() {
@Override
public Point2d create(Point2d i) {
return new Point2d(i.x, i.y);
}
};
LoopL<HalfEdge> edges = sf.findHoles();
LoopL<Point2d> lpd = new LoopL();
for (Loop<HalfEdge> loopHE : edges) {
Map<Point2d, SuperEdge> ses = new HashMap();
Loop<Point2d> lp = new Loop();
lpd.add(lp);
for (HalfEdge he : loopHE) {
SuperEdge se = (SuperEdge) he;
lp.append(se.start);
ses.put(se.start, se);
}
lp = Loopz.mergeAdjacentEdges2(lp, 0.001);
for (Loopable<Point2d> lpb : lp.loopableIterator()) {
Bar b = new Bar(cache.get(lpb.getNext().get()), cache.get(lpb.get()));
SuperEdge se = ses.get(lpb.get());
Profile profile = null;
if (se.prof == null || se.prof.size() < 2) {
List<Point2d> defpts = new ArrayList<>();
defpts.add(new Point2d(0, 0));
defpts.add(new Point2d(0, -sf.height * 1.2));
profile = new Profile(defpts);
} else {
profile = toProfile(se.prof);
}
tagWalls(profile, ((SuperFace) se.face).roofColor, se, lpb.get(), lpb.getNext().get());
plan.addLoop(profile.points.get(0), plan.root, profile);
b.tags.add(new SETag(se));
loop.prepend(b);
plan.profiles.put(b, profile);
}
}
plan.points = loopl;
if (cap != null) {
// skel.capAt( cap, a -> skel.capArea = a ); simple...but doesn't show in the siteplan ui
Ship s = new FlatRoofShip(cap, plan);
for (Profile prof : plan.profiles.values()) {
for (Loop<Bar> lb : prof.points) {
boolean addedMarker = false;
for (Bar b : lb) {
if (-b.start.y < cap && -b.end.y > cap || (!addedMarker && b == lb.start.getPrev().get())) {
Marker m = new Marker();
m.set(b.toLine().xAtY(-cap), -cap);
m.bar = b;
m.bar.mould.create(m, null);
Instance i = s.newInstance();
i.anchors[0].setProfileGen(m.generator);
addedMarker = true;
}
}
}
}
plan.ships.add(s);
}
PlanSkeleton skel = new PlanSkeleton(plan);
skel.skeleton();
return skel;
}
use of org.twak.tweed.gen.SuperEdge in project chordatlas by twak.
the class SkelGen method setSkel.
public synchronized void setSkel(PlanSkeleton skel, Output output, SuperFace sf) {
removeGeometryFor(sf);
Node house;
OnClick onclick = new OnClick() {
@Override
public void selected(Output output, Node house2, SuperEdge se) {
SkelGen.this.selected(skel, house2, sf, se);
}
};
GreebleSkel greeble = new GreebleSkel(tweed);
house = greeble.showSkeleton(output, onclick);
gNode.attachChild(house);
geometry.put(sf, house);
tweed.getRootNode().updateGeometricState();
tweed.getRootNode().updateModelBound();
tweed.gainFocus();
}
Aggregations