use of com.ardor3d.scenegraph.Node in project energy3d by concord-consortium.
the class Foundation method init.
@Override
protected void init() {
super.init();
resizeHouseMode = false;
if (Util.isZero(uValue)) {
uValue = 0.19;
}
if (Util.isZero(volumetricHeatCapacity)) {
volumetricHeatCapacity = 0.5;
}
if (Util.isZero(solarReceiverEfficiency)) {
solarReceiverEfficiency = 0.2;
}
if (Util.isZero(childGridSize)) {
childGridSize = 2.5;
}
if (thermostat == null) {
thermostat = new Thermostat();
}
mesh = new Mesh("Foundation");
mesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(6));
mesh.getMeshData().setNormalBuffer(BufferUtils.createVector3Buffer(6));
mesh.getMeshData().setTextureBuffer(BufferUtils.createVector2Buffer(6), 0);
mesh.setRenderState(offsetState);
mesh.setModelBound(new BoundingBox());
root.attachChild(mesh);
if (foundationPolygon == null) {
foundationPolygon = new FoundationPolygon(this);
} else {
foundationPolygon.draw();
}
root.attachChild(foundationPolygon.getRoot());
sideMesh = new Mesh[4];
for (int i = 0; i < 4; i++) {
final Mesh mesh_i = new Mesh("Foundation (Side " + i + ")");
mesh_i.setUserData(new UserData(this));
mesh_i.setRenderState(offsetState);
mesh_i.setModelBound(new BoundingBox());
final MeshData meshData = mesh_i.getMeshData();
meshData.setVertexBuffer(BufferUtils.createVector3Buffer(6));
meshData.setNormalBuffer(BufferUtils.createVector3Buffer(6));
mesh_i.getMeshData().setTextureBuffer(BufferUtils.createVector2Buffer(6), 0);
root.attachChild(mesh_i);
sideMesh[i] = mesh_i;
}
boundingMesh = new Line("Foundation (Bounding)");
boundingMesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(24));
boundingMesh.setModelBound(new BoundingBox());
Util.disablePickShadowLight(boundingMesh);
boundingMesh.getSceneHints().setCullHint(CullHint.Always);
root.attachChild(boundingMesh);
outlineMesh = new Line("Foundation (Outline)");
outlineMesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(24));
outlineMesh.setDefaultColor(ColorRGBA.BLACK);
outlineMesh.setModelBound(new BoundingBox());
Util.disablePickShadowLight(outlineMesh);
root.attachChild(outlineMesh);
linePatternMesh = new Line("Line Pattern");
linePatternMesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(2));
linePatternMesh.setDefaultColor(new ColorRGBA(0, 0, 0, 0.75f));
linePatternMesh.setModelBound(null);
final BlendState blendState = new BlendState();
blendState.setBlendEnabled(true);
linePatternMesh.setRenderState(blendState);
linePatternMesh.getSceneHints().setRenderBucketType(RenderBucketType.Transparent);
Util.disablePickShadowLight(linePatternMesh);
root.attachChild(linePatternMesh);
setLinePatternVisible(false);
final UserData userData = new UserData(this);
mesh.setUserData(userData);
boundingMesh.setUserData(userData);
setLabelOffset(-0.11);
label = new BMText("Floating Label", "Undefined", FontManager.getInstance().getPartNumberFont(), Align.Center, Justify.Center);
Util.initHousePartLabel(label);
label.setFontScale(0.5);
label.setVisible(false);
root.attachChild(label);
azimuthArrow = new Line("Azimuth Arrow");
azimuthArrow.setLineWidth(2);
azimuthArrow.setModelBound(null);
Util.disablePickShadowLight(azimuthArrow);
azimuthArrow.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(6));
azimuthArrow.setDefaultColor(ColorRGBA.WHITE);
root.attachChild(azimuthArrow);
solarReceiver = new Cylinder("Solar Receiver", 10, 10, 10, 0, true);
solarReceiver.setDefaultColor(ColorRGBA.WHITE);
solarReceiver.setRenderState(offsetState);
solarReceiver.setModelBound(new BoundingBox());
solarReceiver.setVisible(false);
root.attachChild(solarReceiver);
selectedMeshOutline = new Line("Outline of Selected Mesh");
selectedMeshOutline.setLineWidth(2f);
selectedMeshOutline.setStipplePattern((short) 0xf0f0);
selectedMeshOutline.setModelBound(null);
Util.disablePickShadowLight(selectedMeshOutline);
selectedMeshOutline.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(1));
selectedMeshOutline.setDefaultColor(new ColorRGBA(0f, 0f, 0f, 1f));
root.attachChild(selectedMeshOutline);
selectedNodeBoundingBox = new Line("Bounding Box of Selected Mesh");
selectedNodeBoundingBox.setLineWidth(0.01f);
selectedNodeBoundingBox.setStipplePattern((short) 0xf0f0);
selectedNodeBoundingBox.setModelBound(null);
Util.disablePickShadowLight(selectedNodeBoundingBox);
selectedNodeBoundingBox.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(24));
selectedNodeBoundingBox.setDefaultColor(new ColorRGBA(1f, 1f, 0f, 1f));
root.attachChild(selectedNodeBoundingBox);
updateTextureAndColor();
if (points.size() == 8) {
for (int i = 0; i < 4; i++) {
points.add(new Vector3());
}
}
if (importedNodeStates != null) {
try {
for (final Iterator<NodeState> it = importedNodeStates.iterator(); it.hasNext(); ) {
final NodeState ns = it.next();
final Node n = importCollada(ns.getSourceURL(), null);
if (n == null) {
it.remove();
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
try {
JOptionPane.showMessageDialog(MainFrame.getInstance(), Paths.get(ns.getSourceURL().toURI()).toFile() + " was not found!", "File problem", JOptionPane.ERROR_MESSAGE);
} catch (final HeadlessException e) {
e.printStackTrace();
} catch (final URISyntaxException e) {
e.printStackTrace();
}
}
});
} else {
final ArrayList<Integer> reversedFaceMeshes = ns.getMeshesWithReversedNormal();
if (reversedFaceMeshes != null) {
for (final Integer i : reversedFaceMeshes) {
Util.reverseFace(Util.getMesh(n, i));
}
}
final ArrayList<Integer> deletedMeshes = ns.getDeletedMeshes();
if (deletedMeshes != null && !deletedMeshes.isEmpty()) {
final List<Mesh> toDelete = new ArrayList<Mesh>();
for (final Integer i : deletedMeshes) {
toDelete.add(Util.getMesh(n, i));
}
for (final Mesh m : toDelete) {
n.detachChild(m);
}
}
final HashMap<Integer, ReadOnlyColorRGBA> meshColors = ns.getMeshColors();
if (meshColors != null) {
for (final Integer i : meshColors.keySet()) {
Util.getMesh(n, i).setDefaultColor(meshColors.get(i));
}
}
}
}
} catch (final Throwable t) {
BugReporter.report(t);
}
setRotatedNormalsForImportedMeshes();
}
}
use of com.ardor3d.scenegraph.Node in project energy3d by concord-consortium.
the class Foundation method removeEmptyNodes.
public void removeEmptyNodes() {
if (importedNodes != null) {
for (final Iterator<Node> it = importedNodes.iterator(); it.hasNext(); ) {
final Node n = it.next();
if (n.getNumberOfChildren() == 0) {
importedNodeStates.remove(importedNodes.indexOf(n));
root.detachChild(n);
it.remove();
}
}
}
}
use of com.ardor3d.scenegraph.Node in project energy3d by concord-consortium.
the class Foundation method setRotatedNormalsForImportedMeshes.
private void setRotatedNormalsForImportedMeshes() {
if (importedNodes != null) {
drawImportedNodes();
// DO NOT skip zero azimuth case -- final boolean nonZeroAz = !Util.isZero(getAzimuth());
for (final Node node : importedNodes) {
for (final Spatial s : node.getChildren()) {
final Mesh m = (Mesh) s;
final UserData ud = (UserData) m.getUserData();
ud.setRotatedNormal(node.getRotation().applyPost(ud.getNormal(), null));
}
}
}
}
use of com.ardor3d.scenegraph.Node 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();
}
}
}
}
}
use of com.ardor3d.scenegraph.Node in project energy3d by concord-consortium.
the class Roof method setOriginal.
@Override
public void setOriginal(final HousePart original) {
final Roof originalRoof = (Roof) original;
this.original = original;
root.detachChild(pointsRoot);
root.detachChild(roofPartsRoot);
roofPartsRoot = originalRoof.roofPartsRoot.makeCopy(true);
root.attachChild(roofPartsRoot);
for (int i = 0; i < roofPartsRoot.getNumberOfChildren(); i++) {
final UserData orgUserData = (UserData) ((Node) originalRoof.roofPartsRoot.getChild(i)).getChild(0).getUserData();
final Mesh mesh = (Mesh) ((Node) roofPartsRoot.getChild(i)).getChild(0);
mesh.setUserData(new UserData(this, orgUserData.getEditPointIndex(), false));
roofPartsRoot.getChild(i).setUserData(originalRoof.roofPartsRoot.getChild(i).getUserData());
final Line outlineMesh = (Line) ((Node) roofPartsRoot.getChild(i)).getChild(4);
outlineMesh.setLineWidth(printOutlineThickness);
}
drawAnnotations();
root.updateWorldBound(true);
}
Aggregations