use of com.ardor3d.math.type.ReadOnlyVector3 in project energy3d by concord-consortium.
the class PyramidRoof method setPreviewPoint.
@Override
public void setPreviewPoint(final int x, final int y) {
final Foundation foundation = getTopContainer();
if (foundation != null && foundation.getLockEdit()) {
return;
}
final EditState editState = new EditState();
if (editPointIndex == -1) {
pickContainer(x, y, Wall.class);
recalculateEditPoints = true;
} else {
final ReadOnlyVector3 base = new Vector3(getAbsPoint(0).getX(), getAbsPoint(0).getY(), getCenter().getZ());
final Vector3 p = Util.closestPoint(base, Vector3.UNIT_Z, x, y);
if (p != null) {
snapToGrid(p, getAbsPoint(editPointIndex), getGridSize());
height = Math.max(0, p.getZ() - base.getZ());
}
}
postEdit(editState);
}
use of com.ardor3d.math.type.ReadOnlyVector3 in project energy3d by concord-consortium.
the class PyramidRoof method processRoofEditPoints.
@Override
protected void processRoofEditPoints(final List<? extends ReadOnlyVector3> wallUpperPoints) {
final ReadOnlyVector3 center = getCenter();
if (recalculateEditPoints) {
recalculateEditPoints = false;
points.get(0).set(toRelative(center));
computeHeight(wallUpperPoints);
applyHeight();
} else {
applyHeight();
}
}
use of com.ardor3d.math.type.ReadOnlyVector3 in project energy3d by concord-consortium.
the class Roof method insideWalls.
public boolean insideWalls(final double x, final double y, final boolean init) {
if (walls.isEmpty()) {
return false;
}
if (init) {
if (underlyingWallVerticesOnFoundation == null) {
underlyingWallVerticesOnFoundation = new ArrayList<Vector2>();
} else {
underlyingWallVerticesOnFoundation.clear();
}
walls.get(0).visitNeighbors(new WallVisitor() {
@Override
public void visit(final Wall currentWall, final Snap prev, final Snap next) {
int pointIndex = 0;
if (next != null) {
pointIndex = next.getSnapPointIndexOf(currentWall);
}
pointIndex++;
addUnderlyingWallVertex(currentWall.getAbsPoint(pointIndex == 1 ? 3 : 1));
addUnderlyingWallVertex(currentWall.getAbsPoint(pointIndex));
}
private void addUnderlyingWallVertex(final ReadOnlyVector3 v3) {
final Vector2 v2 = new Vector2(v3.getX(), v3.getY());
boolean b = false;
for (final Vector2 x : underlyingWallVerticesOnFoundation) {
if (Util.isEqual(x, v2)) {
b = true;
break;
}
}
if (!b) {
underlyingWallVerticesOnFoundation.add(v2);
}
}
});
if (underlyingWallPath == null) {
underlyingWallPath = new Path2D.Double();
} else {
underlyingWallPath.reset();
}
final Vector2 v0 = underlyingWallVerticesOnFoundation.get(0);
underlyingWallPath.moveTo(v0.getX(), v0.getY());
for (int i = 1; i < underlyingWallVerticesOnFoundation.size(); i++) {
final Vector2 v = underlyingWallVerticesOnFoundation.get(i);
underlyingWallPath.lineTo(v.getX(), v.getY());
}
underlyingWallPath.lineTo(v0.getX(), v0.getY());
underlyingWallPath.closePath();
}
return underlyingWallPath != null ? underlyingWallPath.contains(x, y) : false;
}
use of com.ardor3d.math.type.ReadOnlyVector3 in project energy3d by concord-consortium.
the class Roof method setGable.
public void setGable(final int roofPartIndex, final boolean isGable, final UndoManager undoManager) {
final ArrayList<ReadOnlyVector3> roofPartMeshUpperPoints = new ArrayList<ReadOnlyVector3>();
final Wall wall = findGableWall(roofPartIndex, roofPartMeshUpperPoints);
if (wall != null) {
if (undoManager != null) {
undoManager.addEdit(new MakeGableCommand(this, wall, roofPartMeshUpperPoints));
}
setGable(wall, isGable, true, roofPartMeshUpperPoints);
}
}
use of com.ardor3d.math.type.ReadOnlyVector3 in project energy3d by concord-consortium.
the class Roof method init.
@Override
protected void init() {
super.init();
if (Util.isZero(uValue)) {
uValue = 0.15;
}
if (Util.isZero(overhangLength)) {
overhangLength = 2;
}
if (Util.isZero(volumetricHeatCapacity)) {
volumetricHeatCapacity = 0.5;
}
orgCenters = new HashMap<Node, ReadOnlyVector3>();
wallNormals = new ArrayList<ReadOnlyVector3>();
walls = new ArrayList<Wall>();
roofPartPrintVerticalMap = new HashMap<Spatial, Boolean>();
dashPointsCache = new HashMap<Mesh, List<ReadOnlyVector3>>();
roofPartsRoot = new Node("Roof Meshes Root");
root.attachChild(roofPartsRoot);
mesh = new Mesh("Roof");
mesh.setModelBound(null);
getEditPointShape(0).setDefaultColor(ColorRGBA.CYAN);
// cleanup
if (gableEditPointToWallMap != null) {
for (final List<Wall> wallList : gableEditPointToWallMap.values()) {
final Iterator<Wall> walls = wallList.iterator();
while (walls.hasNext()) {
if (Scene.getInstance().getParts().indexOf(walls.next()) == -1) {
walls.remove();
}
}
}
}
}
Aggregations