use of com.ardor3d.scenegraph.Spatial 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.Spatial 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);
}
}
}
}
use of com.ardor3d.scenegraph.Spatial in project energy3d by concord-consortium.
the class Roof method drawRoof.
private void drawRoof() {
applyOverhang(wallUpperPoints, wallNormals);
processRoofEditPoints(wallUpperPoints);
computeGableEditPoints();
ensureEditPointsInside();
final PolygonWithHoles polygon = makePolygon(wallUpperPoints);
applySteinerPoint(polygon);
MeshLib.fillMeshWithPolygon(mesh, polygon, null, true, null, null, null, false);
MeshLib.groupByPlanar(mesh, roofPartsRoot);
hideGableRoofParts();
int roofPartIndex = 0;
for (final Spatial child : roofPartsRoot.getChildren()) {
((Mesh) ((Node) child).getChild(0)).setUserData(new UserData(this, roofPartIndex, false));
((Mesh) ((Node) child).getChild(REAL_MESH_INDEX)).setUserData(new UserData(this, roofPartIndex, false));
roofPartIndex++;
}
final List<Window> windows = new ArrayList<Window>();
for (final HousePart part : children) {
if (part instanceof Window && part.isDrawable()) {
windows.add((Window) part);
}
}
MeshLib.applyHoles(roofPartsRoot, windows);
setAnnotationsVisible(Scene.getInstance().areAnnotationsVisible());
}
use of com.ardor3d.scenegraph.Spatial in project energy3d by concord-consortium.
the class Roof method drawDashLines.
private void drawDashLines() {
if (container == null) {
return;
}
if (lockEdit) {
for (final Spatial roofPart : roofPartsRoot.getChildren()) {
if (roofPart.getSceneHints().getCullHint() != CullHint.Always) {
final Node roofPartNode = (Node) roofPart;
final Mesh dashLinesMesh = (Mesh) roofPartNode.getChild(5);
dashLinesMesh.setVisible(false);
}
}
} else {
for (final Spatial roofPart : roofPartsRoot.getChildren()) {
if (roofPart.getSceneHints().getCullHint() != CullHint.Always) {
final Node roofPartNode = (Node) roofPart;
final Mesh roofPartMesh = (Mesh) roofPartNode.getChild(0);
final Mesh dashLinesMesh = (Mesh) roofPartNode.getChild(5);
final List<ReadOnlyVector3> result = computeDashPoints(roofPartMesh);
if (result.isEmpty()) {
dashLinesMesh.setVisible(false);
} else {
dashLinesMesh.setVisible(true);
FloatBuffer vertexBuffer = dashLinesMesh.getMeshData().getVertexBuffer();
if (vertexBuffer == null || vertexBuffer.capacity() < result.size() * 3) {
vertexBuffer = BufferUtils.createVector3Buffer(result.size());
dashLinesMesh.getMeshData().setVertexBuffer(vertexBuffer);
}
vertexBuffer.limit(result.size() * 3);
vertexBuffer.rewind();
for (final ReadOnlyVector3 p : result) {
vertexBuffer.put(p.getXf()).put(p.getYf()).put(p.getZf());
}
dashLinesMesh.getMeshData().updateVertexCount();
dashLinesMesh.updateModelBound();
}
}
}
}
updateDashLinesColor();
}
use of com.ardor3d.scenegraph.Spatial in project energy3d by concord-consortium.
the class Roof method getArea.
// return the area WITH overhang
@Override
public double getArea() {
if (areaByPartWithOverhang == null) {
return 0;
}
double a = 0;
for (final Spatial roofPart : roofPartsRoot.getChildren()) {
if (roofPart.getSceneHints().getCullHint() != CullHint.Always) {
final Node roofPartNode = (Node) roofPart;
final Mesh roofPartMesh = (Mesh) roofPartNode.getChild(REAL_MESH_INDEX);
final Double d = areaByPartWithOverhang.get(roofPartMesh);
if (d != null) {
a += d;
}
}
}
return a;
}
Aggregations