use of com.ardor3d.scenegraph.Node in project energy3d by concord-consortium.
the class Roof method drawOutline.
protected void drawOutline() {
if (container == null) {
return;
}
for (final Spatial roofPart : roofPartsRoot.getChildren()) {
if (roofPart.getSceneHints().getCullHint() != CullHint.Always) {
final Node roofPartNode = (Node) roofPart;
final Mesh outlineMesh = (Mesh) roofPartNode.getChild(4);
final Mesh mesh = (Mesh) roofPartNode.getChild(0);
final ArrayList<ReadOnlyVector3> outlinePoints = MeshLib.computeOutline(mesh.getMeshData().getVertexBuffer());
int totalVertices = outlinePoints.size();
for (final HousePart part : children) {
if (part instanceof Window) {
totalVertices += 8;
}
}
final FloatBuffer buf;
if (outlineMesh.getMeshData().getVertexBuffer().capacity() >= totalVertices * 2 * 3) {
buf = outlineMesh.getMeshData().getVertexBuffer();
buf.limit(buf.capacity());
buf.rewind();
} else {
buf = BufferUtils.createVector3Buffer(totalVertices * 2);
outlineMesh.getMeshData().setVertexBuffer(buf);
}
// draw roof outline
for (int i = 0; i < outlinePoints.size(); i++) {
final ReadOnlyVector3 p1 = outlinePoints.get(i);
final ReadOnlyVector3 p2 = outlinePoints.get((i + 1) % outlinePoints.size());
buf.put(p1.getXf()).put(p1.getYf()).put(p1.getZf());
buf.put(p2.getXf()).put(p2.getYf()).put(p2.getZf());
}
// draw skylights outline
final int[] windowIndices = new int[] { 0, 2, 3, 1 };
for (final HousePart part : children) {
if (part instanceof Window && part.isDrawable() && ((Window) part).getRoofIndex() == ((UserData) mesh.getUserData()).getEditPointIndex()) {
for (int i = 0; i < part.getPoints().size(); i++) {
final ReadOnlyVector3 p1 = part.getAbsPoint(windowIndices[i]);
final ReadOnlyVector3 p2 = part.getAbsPoint(windowIndices[(i + 1) % part.getPoints().size()]);
buf.put(p1.getXf()).put(p1.getYf()).put(p1.getZf());
buf.put(p2.getXf()).put(p2.getYf()).put(p2.getZf());
}
}
}
buf.limit(buf.position());
outlineMesh.getMeshData().updateVertexCount();
outlineMesh.updateModelBound();
}
}
}
use of com.ardor3d.scenegraph.Node 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.scenegraph.Node 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.scenegraph.Node 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;
}
}
}
}
}
use of com.ardor3d.scenegraph.Node in project energy3d by concord-consortium.
the class Roof method setAnnotationsVisible.
@Override
public void setAnnotationsVisible(final boolean visible) {
super.setAnnotationsVisible(visible);
final CullHint cull = visible ? CullHint.Inherit : CullHint.Always;
if (roofPartsRoot != null) {
for (final Spatial roofPart : roofPartsRoot.getChildren()) {
if (roofPart.getSceneHints().getCullHint() != CullHint.Always) {
((Node) roofPart).getChild(1).getSceneHints().setCullHint(cull);
((Node) roofPart).getChild(2).getSceneHints().setCullHint(cull);
}
}
}
}
Aggregations