use of com.ardor3d.math.type.ReadOnlyVector3 in project energy3d by concord-consortium.
the class Roof method drawMesh.
@Override
protected void drawMesh() {
// undo the effect of wall stretch on all walls if roof is moved to new walls
if (previousContainer != container) {
previousContainer = container;
for (final Wall wall : walls) {
wall.setRoof(null);
wall.draw();
}
}
dashPointsCache.clear();
if (wallUpperPoints == null) {
wallUpperPoints = new ArrayList<ReadOnlyVector3>();
} else {
wallUpperPoints.clear();
}
if (container != null) {
initWallUpperPoints((Wall) container, walls, wallUpperPoints, wallNormals);
}
if (!isDrawable()) {
roofPartsRoot.getSceneHints().setCullHint(CullHint.Always);
setEditPointsVisible(false);
return;
}
roofPartsRoot.getSceneHints().setCullHint(CullHint.Inherit);
final ArrayList<Vector3> orgPoints = new ArrayList<Vector3>(points.size());
for (final ReadOnlyVector3 p : points) {
orgPoints.add(p.clone());
}
wallUpperPointsWithoutOverhang = new ArrayList<ReadOnlyVector3>(wallUpperPoints);
drawRoof();
switch(type) {
case TRANSPARENT:
for (final Spatial child : roofPartsRoot.getChildren()) {
((Mesh) ((Node) child).getChild(0)).getSceneHints().setCullHint(CullHint.Always);
((Mesh) ((Node) child).getChild(REAL_MESH_INDEX)).getSceneHints().setCullHint(CullHint.Always);
}
break;
default:
for (final Spatial child : roofPartsRoot.getChildren()) {
((Mesh) ((Node) child).getChild(0)).getSceneHints().setCullHint(CullHint.Inherit);
((Mesh) ((Node) child).getChild(REAL_MESH_INDEX)).getSceneHints().setCullHint(CullHint.Inherit);
}
}
roofPartsRoot.updateWorldBound(true);
drawOutline();
if (Scene.getInstance().areDashedLinesOnRoofShown()) {
drawDashLines();
} else {
for (final Spatial roofPart : roofPartsRoot.getChildren()) {
if (roofPart.getSceneHints().getCullHint() != CullHint.Always) {
final Mesh dashLinesMesh = (Mesh) ((Node) roofPart).getChild(5);
dashLinesMesh.setVisible(false);
}
}
}
}
use of com.ardor3d.math.type.ReadOnlyVector3 in project energy3d by concord-consortium.
the class Roof method drawHeatFlux.
@Override
public void drawHeatFlux() {
FloatBuffer arrowsVertices = heatFlux.getMeshData().getVertexBuffer();
final Foundation foundation = getTopContainer();
final int cols = (int) Math.max(2, foundation.getAbsPoint(0).distance(foundation.getAbsPoint(2)) / Scene.getInstance().getHeatVectorGridSize());
final int rows = (int) Math.max(2, foundation.getAbsPoint(0).distance(foundation.getAbsPoint(1)) / Scene.getInstance().getHeatVectorGridSize());
arrowsVertices = BufferUtils.createVector3Buffer(rows * cols * 6);
heatFlux.getMeshData().setVertexBuffer(arrowsVertices);
final ReadOnlyVector3 o = foundation.getAbsPoint(0);
final ReadOnlyVector3 u = foundation.getAbsPoint(2).subtract(o, null);
final ReadOnlyVector3 v = foundation.getAbsPoint(1).subtract(o, null);
final Vector3 a = new Vector3();
double g, h;
boolean init = true;
for (int j = 0; j < cols; j++) {
h = j + 0.5;
for (int i = 0; i < rows; i++) {
g = i + 0.5;
a.setX(o.getX() + g * v.getX() / rows + h * u.getX() / cols);
a.setY(o.getY() + g * v.getY() / rows + h * u.getY() / cols);
a.setZ(o.getZ());
if (insideWalls(a.getX(), a.getY(), init)) {
ReadOnlyVector3 b = null;
Node node = null;
Mesh mesh = null;
for (final Spatial child : roofPartsRoot.getChildren()) {
if (child.getSceneHints().getCullHint() != CullHint.Always) {
node = (Node) child;
mesh = (Mesh) node.getChild(REAL_MESH_INDEX);
b = findRoofIntersection(mesh, a);
if (b != null) {
break;
}
}
}
if (b != null) {
final ReadOnlyVector3 normal = (ReadOnlyVector3) node.getUserData();
final double heat = calculateHeatVector(mesh);
drawArrow(b, normal, arrowsVertices, heat);
}
}
if (init) {
init = false;
}
}
heatFlux.getMeshData().updateVertexCount();
heatFlux.updateModelBound();
}
updateHeatFluxVisibility();
}
use of com.ardor3d.math.type.ReadOnlyVector3 in project energy3d by concord-consortium.
the class Roof method initWallUpperPoints.
private void initWallUpperPoints(final Wall startWall, final List<Wall> walls, final List<ReadOnlyVector3> wallUpperPoints, final List<ReadOnlyVector3> wallNormals) {
walls.clear();
wallUpperPoints.clear();
wallNormals.clear();
startWall.visitNeighbors(new WallVisitor() {
@Override
public void visit(final Wall currentWall, final Snap prevSnap, final Snap nextSnap) {
if (currentWall.isFirstPointInserted()) {
walls.add(currentWall);
currentWall.setRoof(Roof.this);
final int pointIndex2 = nextSnap != null ? nextSnap.getSnapPointIndexOf(currentWall) + 1 : 1;
final int pointIndex1 = pointIndex2 == 1 ? 3 : 1;
final Vector3 p1 = currentWall.getAbsPoint(pointIndex1);
final Vector3 p2 = currentWall.getAbsPoint(pointIndex2);
final ReadOnlyVector3 normal = currentWall.getNormal();
addPointToPolygon(p1, normal, wallUpperPoints, wallNormals);
addPointToPolygon(p2, normal, wallUpperPoints, wallNormals);
}
}
});
}
use of com.ardor3d.math.type.ReadOnlyVector3 in project energy3d by concord-consortium.
the class Roof method computeGableEditPoints.
private void computeGableEditPoints() {
if (gableEditPointToWallMap == null) {
return;
}
for (final int editPointIndex : gableEditPointToWallMap.keySet()) {
// if (editPointIndex >= points.size()) {
// gableEditPointToWallMap.clear();
// break;
// }
final Vector3 editPoint = getAbsPoint(editPointIndex);
final List<Wall> gableWalls = gableEditPointToWallMap.get(editPointIndex);
final List<ReadOnlyVector3> wallPoints = new ArrayList<ReadOnlyVector3>(gableWalls.size() * 2);
final List<ReadOnlyVector3> wallNormals = new ArrayList<ReadOnlyVector3>(gableWalls.size() * 2);
for (final Wall wall : gableWalls) {
addPointToPolygon(wall.getAbsPoint(0), wall.getNormal(), wallPoints, wallNormals);
addPointToPolygon(wall.getAbsPoint(2), wall.getNormal(), wallPoints, wallNormals);
}
applyOverhang(wallPoints, wallNormals);
if (gableWalls.size() == 1) {
final ReadOnlyVector2 p2D = Util.snapToPolygon(editPoint, wallPoints, wallNormals);
editPoint.setX(p2D.getX());
editPoint.setY(p2D.getY());
} else if (gableWalls.size() > 1) {
final Vector3 p0 = gableWalls.get(0).getAbsPoint(0);
final Wall secondWall = gableWalls.get(1);
final ReadOnlyVector3 cornerPoint;
final int cornerIndex;
if (Util.isEqual(p0, secondWall.getAbsPoint(0)) || Util.isEqual(p0, secondWall.getAbsPoint(2))) {
cornerIndex = 0;
} else {
cornerIndex = 1;
}
cornerPoint = wallPoints.get(cornerIndex).subtract(wallNormals.get(cornerIndex).multiply(0.01, null), null);
editPoint.setX(cornerPoint.getX());
editPoint.setY(cornerPoint.getY());
}
points.get(editPointIndex).set(toRelative(editPoint));
}
}
use of com.ardor3d.math.type.ReadOnlyVector3 in project energy3d by concord-consortium.
the class Roof method hideGableRoofParts.
private void hideGableRoofParts() {
if (gableEditPointToWallMap == null) {
return;
}
// Two Options: hide using estimating direction with wall. Or, hide using roof part number (it be wrong))
for (final List<Wall> walls : gableEditPointToWallMap.values()) {
for (final HousePart wall : walls) {
final Vector3[] base_i = { wall.getAbsPoint(0), wall.getAbsPoint(2) };
for (final Spatial roofPart : getRoofPartsRoot().getChildren()) {
final ReadOnlyVector3[] base = findBasePoints((Mesh) ((Node) roofPart).getChild(0), null);
if (base != null && isSameBasePoints(base_i[0], base_i[1], base[0], base[1])) {
roofPart.getSceneHints().setCullHint(CullHint.Always);
roofPart.getSceneHints().setAllPickingHints(false);
break;
}
}
}
}
}
Aggregations