use of com.ardor3d.bounding.BoundingBox in project energy3d by concord-consortium.
the class Wall method init.
@Override
protected void init() {
super.init();
if (Util.isZero(wallThickness)) {
wallThickness = defaultWallThickness;
}
if (Util.isZero(uValue)) {
uValue = 0.28;
}
if (Util.isZero(volumetricHeatCapacity)) {
volumetricHeatCapacity = 0.5;
}
if (Util.isZero(columnRadius)) {
columnRadius = 1;
}
if (Util.isZero(railRadius)) {
railRadius = 0.1;
}
neighbors = new Snap[2];
if (thicknessNormal != null) {
thicknessNormal.normalizeLocal().multiplyLocal(wallThickness);
}
mesh = new Mesh("Wall");
mesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(1));
// mesh.getSceneHints().setPickingHint(PickingHint.Pickable, false);
mesh.setRenderState(offsetState);
mesh.setModelBound(new BoundingBox());
root.attachChild(mesh);
backMesh = new Mesh("Wall (Back)");
backMesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(1));
backMesh.setDefaultColor(ColorRGBA.LIGHT_GRAY);
backMesh.getSceneHints().setPickingHint(PickingHint.Pickable, false);
backMesh.setRenderState(offsetState);
backMesh.setModelBound(new BoundingBox());
root.attachChild(backMesh);
surroundMesh = new Mesh("Wall (Surround)");
surroundMesh.getMeshData().setIndexMode(IndexMode.Quads);
surroundMesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(12));
surroundMesh.getMeshData().setNormalBuffer(BufferUtils.createVector3Buffer(12));
surroundMesh.setDefaultColor(ColorRGBA.GRAY);
surroundMesh.setRenderState(offsetState);
surroundMesh.setModelBound(new BoundingBox());
root.attachChild(surroundMesh);
invisibleMesh = new Mesh("Wall (Invisible)");
invisibleMesh.getMeshData().setIndexMode(IndexMode.Quads);
invisibleMesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(4));
invisibleMesh.getSceneHints().setCullHint(CullHint.Always);
invisibleMesh.setRenderState(offsetState);
invisibleMesh.setModelBound(new BoundingBox());
root.attachChild(invisibleMesh);
windowsSurroundMesh = new Mesh("Wall (Windows Surround)");
windowsSurroundMesh.getMeshData().setIndexMode(IndexMode.Quads);
windowsSurroundMesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(1));
windowsSurroundMesh.getMeshData().setNormalBuffer(BufferUtils.createVector3Buffer(1));
windowsSurroundMesh.setDefaultColor(ColorRGBA.GRAY);
windowsSurroundMesh.getSceneHints().setPickingHint(PickingHint.Pickable, false);
windowsSurroundMesh.setRenderState(offsetState);
/* lets not use bounds for this mesh because when there are no windows its bounds is set to center 0,0,0 which shifts the overall bounds toward zero */
windowsSurroundMesh.setModelBound(null);
root.attachChild(windowsSurroundMesh);
outlineMesh = new Line("Wall (Outline)");
outlineMesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(8));
outlineMesh.setDefaultColor(ColorRGBA.BLACK);
outlineMesh.setModelBound(null);
Util.disablePickShadowLight(outlineMesh);
root.attachChild(outlineMesh);
updateTextureAndColor();
final UserData userData = new UserData(this);
mesh.setUserData(userData);
backMesh.setUserData(userData);
surroundMesh.setUserData(userData);
invisibleMesh.setUserData(userData);
columns = new Mesh("Columns");
columns.getMeshData().setIndexMode(IndexMode.Quads);
columns.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(500));
columns.getMeshData().setNormalBuffer(BufferUtils.createVector3Buffer(500));
columns.setRenderState(offsetState);
columns.setModelBound(new BoundingBox());
root.attachChild(columns);
rails = new Mesh("Railings");
rails.getMeshData().setIndexMode(IndexMode.Quads);
rails.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(1000));
rails.getMeshData().setNormalBuffer(BufferUtils.createVector3Buffer(1000));
rails.setRenderState(offsetState);
rails.setModelBound(new BoundingBox());
root.attachChild(rails);
steelFrame = new Mesh("Steel Frame");
steelFrame.getMeshData().setIndexMode(IndexMode.Quads);
steelFrame.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(1000));
steelFrame.getMeshData().setNormalBuffer(BufferUtils.createVector3Buffer(1000));
steelFrame.setRenderState(offsetState);
steelFrame.setModelBound(new BoundingBox());
root.attachChild(steelFrame);
}
use of com.ardor3d.bounding.BoundingBox in project energy3d by concord-consortium.
the class Roof method drawGrids.
@Override
public void drawGrids(final double gridSize) {
final BoundingBox bounds = (BoundingBox) root.getWorldBound().asType(Type.AABB);
final ReadOnlyVector3 width = Vector3.UNIT_X.multiply(bounds.getXExtent() * 2, null);
final ReadOnlyVector3 height = Vector3.UNIT_Y.multiply(bounds.getYExtent() * 2, null);
final ArrayList<ReadOnlyVector3> points = new ArrayList<ReadOnlyVector3>();
final ReadOnlyVector3 center = getCenter();
final ReadOnlyVector3 pMiddle = new Vector3(center.getX(), center.getY(), getAbsPoint(0).getZ());
final int cols = (int) (width.length() / gridSize);
for (int col = 0; col < cols / 2 + 1; col++) {
for (int neg = -1; neg <= 1; neg += 2) {
final ReadOnlyVector3 lineP1 = width.normalize(null).multiplyLocal(neg * col * gridSize).addLocal(pMiddle).subtractLocal(height.multiply(0.5, null));
points.add(lineP1);
final ReadOnlyVector3 lineP2 = lineP1.add(height, null);
points.add(lineP2);
if (col == 0) {
break;
}
}
}
final int rows = (int) (height.length() / gridSize);
for (int row = 0; row < rows / 2 + 1; row++) {
for (int neg = -1; neg <= 1; neg += 2) {
final ReadOnlyVector3 lineP1 = height.normalize(null).multiplyLocal(neg * row * gridSize).addLocal(pMiddle).subtractLocal(width.multiply(0.5, null));
points.add(lineP1);
final ReadOnlyVector3 lineP2 = lineP1.add(width, null);
points.add(lineP2);
if (row == 0) {
break;
}
}
}
if (points.size() < 2) {
return;
}
final FloatBuffer buf = BufferUtils.createVector3Buffer(points.size());
for (final ReadOnlyVector3 p : points) {
buf.put(p.getXf()).put(p.getYf()).put(pMiddle.getZf());
}
gridsMesh.getMeshData().setVertexBuffer(buf);
}
use of com.ardor3d.bounding.BoundingBox in project energy3d by concord-consortium.
the class ParabolicTrough method addPole.
private void addPole(final Vector3 position, final double poleHeight, final double baseZ) {
final Cylinder pole = new Cylinder("Pole Cylinder", 2, detailed ? 10 : 2, 10, 0);
pole.setRadius(0.6);
pole.setRenderState(offsetState);
// slightly shorter so that the pole won't penetrate the surface of the trough
pole.setHeight(poleHeight - 0.5 * pole.getRadius());
pole.setModelBound(new BoundingBox());
pole.updateModelBound();
position.setZ(baseZ + pole.getHeight() / 2);
pole.setTranslation(position);
modulesRoot.attachChild(pole);
}
Aggregations