use of com.ardor3d.scenegraph.Mesh 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.Mesh 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.Mesh 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.Mesh 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;
}
use of com.ardor3d.scenegraph.Mesh in project energy3d by concord-consortium.
the class Roof method computeOrientedBoundingBox.
@Override
public void computeOrientedBoundingBox() {
orgCenters.clear();
for (final Spatial roofPartNode : roofPartsRoot.getChildren()) {
if (roofPartNode.getSceneHints().getCullHint() != CullHint.Always) {
final Mesh roofPartMesh = (Mesh) ((Node) roofPartNode).getChild(0);
computeOrientedBoundingBox(roofPartMesh);
orgCenters.put((Node) roofPartNode, new Vector3(roofPartMesh.getWorldBound().getCenter()));
}
}
}
Aggregations