use of com.ardor3d.bounding.BoundingBox in project energy3d by concord-consortium.
the class SceneManager method createAxes.
private Spatial createAxes() {
final int axisLen = SKY_RADIUS;
final Node axisRoot = new Node();
FloatBuffer buf;
Line line;
// X-Axis
buf = BufferUtils.createVector3Buffer(2);
buf.put(-axisLen).put(0).put(0);
buf.put(axisLen).put(0).put(0);
line = new Line("X-Axis", buf, null, null, null);
line.setDefaultColor(ColorRGBA.RED);
Util.disablePickShadowLight(line);
line.setModelBound(new BoundingBox());
line.updateModelBound();
axisRoot.attachChild(line);
// Y-Axis
buf = BufferUtils.createVector3Buffer(2);
buf.put(0).put(-axisLen).put(0);
buf.put(0).put(axisLen).put(0);
line = new Line("Y-Axis", buf, null, null, null);
line.setDefaultColor(ColorRGBA.GREEN);
Util.disablePickShadowLight(line);
line.setModelBound(new BoundingBox());
line.updateModelBound();
axisRoot.attachChild(line);
// Z-Axis
buf = BufferUtils.createVector3Buffer(2);
buf.put(0).put(0).put(-axisLen);
buf.put(0).put(0).put(axisLen);
line = new Line("Z-Axis", buf, null, null, null);
Util.disablePickShadowLight(line);
line.setDefaultColor(ColorRGBA.BLUE);
line.setModelBound(new BoundingBox());
line.updateModelBound();
axisRoot.attachChild(line);
axisRoot.updateWorldBound(true);
return axisRoot;
}
use of com.ardor3d.bounding.BoundingBox in project energy3d by concord-consortium.
the class Rack method addPole.
private void addPole(final Vector3 position, final double poleHeight, final double baseZ) {
final Cylinder pole = new Cylinder("Pole Cylinder", 10, 10, 10, 0);
pole.setRadius(0.6);
pole.setRenderState(offsetState);
// slightly shorter so that the pole won't penetrate the surface of the rack
pole.setHeight(poleHeight - 0.5 * pole.getRadius());
pole.setModelBound(new BoundingBox());
pole.updateModelBound();
position.setZ(baseZ + pole.getHeight() / 2);
pole.setTranslation(position);
polesRoot.attachChild(pole);
}
use of com.ardor3d.bounding.BoundingBox in project energy3d by concord-consortium.
the class CameraControl method getCurrentExtent.
// the extent that depends on the camera orientation (not a perfect solution)
private static double getCurrentExtent() {
double extent = 10;
final BoundingVolume volume = Scene.getRoot().getWorldBound();
if (volume instanceof BoundingBox) {
final BoundingBox box = (BoundingBox) volume;
final ReadOnlyVector3 cameraDirection = SceneManager.getInstance().getCamera().getDirection();
final Vector3 e1 = box.getExtent(null);
final double extent1 = Math.abs(e1.cross(cameraDirection, null).length());
final Vector3 e2 = new Matrix3().applyRotationZ(Math.PI / 2).applyPost(e1, null);
final double extent2 = Math.abs(e2.cross(cameraDirection, null).length());
extent = 0.45 * (extent1 + extent2);
}
return extent;
}
use of com.ardor3d.bounding.BoundingBox in project energy3d by concord-consortium.
the class PrintController method arrangePrintPages.
private void arrangePrintPages(final ArrayList<ArrayList<Spatial>> pages) {
final double ratio = (double) Camera.getCurrentCamera().getWidth() / Camera.getCurrentCamera().getHeight();
cols = (int) Math.round(Math.sqrt(pages.size() + 4) * ratio);
if (cols % 2 == 0) {
cols++;
}
rows = (int) Math.ceil((pages.size() + 4) / cols);
int pageNum = 0;
printCenters.clear();
for (final ArrayList<Spatial> page : pages) {
final Vector3 upperLeftCorner = new Vector3();
double x, z;
final BoundingBox originalHouseBoundingBox = (BoundingBox) Scene.getOriginalHouseRoot().getWorldBound().asType(Type.AABB);
final ReadOnlyVector3 originalHouseCenter = Scene.getOriginalHouseRoot().getWorldBound().getCenter();
final double minXDistance = originalHouseBoundingBox.getXExtent() + pageWidth / 2.0;
final double minYDistance = originalHouseBoundingBox.getZExtent();
do {
x = (pageNum % cols - cols / 2) * (pageWidth + SPACE_BETWEEN_PAGES) + originalHouseCenter.getX();
z = (pageNum / cols) * (pageHeight + SPACE_BETWEEN_PAGES);
upperLeftCorner.setX(x - pageWidth / 2.0);
upperLeftCorner.setZ(z + pageHeight);
pageNum++;
} while (Math.abs(x - originalHouseCenter.getX()) < minXDistance && Math.abs(z - originalHouseCenter.getZ()) < minYDistance);
printCenters.add(upperLeftCorner);
for (final Spatial printSpatial : page) {
((UserData) printSpatial.getUserData()).getPrintCenter().addLocal(upperLeftCorner.multiply(1, 0, 1, null));
}
final Box box = new Box("Page Boundary");
final double y = Scene.getOriginalHouseRoot().getWorldBound().getCenter().getY();
box.setData(upperLeftCorner.add(0, y + 1, 0, null), upperLeftCorner.add(pageWidth, y + 1.2, -pageHeight, null));
box.setModelBound(new BoundingBox());
box.updateModelBound();
pagesRoot.attachChild(box);
final BMText footNote = Annotation.makeNewLabel(1);
final String url = Scene.getURL() != null ? Scene.getURL().getFile().substring(Scene.getURL().getFile().lastIndexOf('/') + 1, Scene.getURL().getFile().length()) + " -" : "";
footNote.setText(url.replaceAll("%20", " ") + " Page " + printCenters.size() + " / " + pages.size() + " - http://energy.concord.org/");
footNote.setFontScale(0.5);
footNote.setAlign(Align.North);
footNote.setTranslation(upperLeftCorner.add(pageWidth / 2.0, 0.0, -pageBottom - spaceBetweenParts / 2.0, null));
pagesRoot.attachChild(footNote);
}
pagesRoot.updateGeometricState(0);
}
use of com.ardor3d.bounding.BoundingBox in project energy3d by concord-consortium.
the class Mirror method init.
@Override
protected void init() {
super.init();
if (Util.isZero(mirrorWidth)) {
mirrorWidth = 5;
}
if (Util.isZero(mirrorHeight)) {
mirrorHeight = 3;
}
if (Util.isZero(reflectance)) {
reflectance = 0.9;
}
if (Util.isZero(opticalEfficiency)) {
opticalEfficiency = 1;
}
if (Util.isZero(baseHeight)) {
baseHeight = 10;
}
if (heliostatTarget != null) {
// FIXME: Somehow the target, when copied, doesn't point to the right object. This is not a prefect solution, but it fixes the problem.
final HousePart hp = Scene.getInstance().getPart(heliostatTarget.getId());
if (hp instanceof Foundation) {
heliostatTarget = (Foundation) hp;
} else {
heliostatTarget = null;
}
}
mesh = new Mesh("Reflecting Mirror");
mesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(6));
mesh.getMeshData().setTextureBuffer(BufferUtils.createVector2Buffer(6), 0);
mesh.setModelBound(new OrientedBoundingBox());
mesh.setUserData(new UserData(this));
root.attachChild(mesh);
surround = new Box("Mirror (Surround)");
surround.setModelBound(new OrientedBoundingBox());
final OffsetState offset = new OffsetState();
offset.setFactor(1);
offset.setUnits(1);
surround.setRenderState(offset);
root.attachChild(surround);
outlineMesh = new Line("Mirror (Outline)");
outlineMesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(8));
outlineMesh.setDefaultColor(ColorRGBA.BLACK);
outlineMesh.setModelBound(new OrientedBoundingBox());
root.attachChild(outlineMesh);
// if there are many mirrors, reduce the solution of post
post = new Cylinder("Post Cylinder", 2, Scene.getInstance().getAllHeliostats().size() < 200 ? 10 : 2, 10, 0);
post.setRadius(0.6);
post.setDefaultColor(ColorRGBA.WHITE);
post.setRenderState(offsetState);
post.setModelBound(new BoundingBox());
post.updateModelBound();
root.attachChild(post);
lightBeams = new Line("Light Beams");
lightBeams.setLineWidth(1f);
lightBeams.setStipplePattern((short) 0xffff);
lightBeams.setModelBound(null);
// final BlendState blendState = new BlendState();
// blendState.setBlendEnabled(true);
// lightBeams.setRenderState(blendState);
// lightBeams.getSceneHints().setRenderBucketType(RenderBucketType.Transparent);
Util.disablePickShadowLight(lightBeams);
lightBeams.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(4));
lightBeams.setDefaultColor(new ColorRGBA(1f, 1f, 1f, 1f));
root.attachChild(lightBeams);
label = new BMText("Label", "# " + id, FontManager.getInstance().getPartNumberFont(), Align.Center, Justify.Center);
Util.initHousePartLabel(label);
label.setFontScale(0.5);
label.setVisible(false);
root.attachChild(label);
updateTextureAndColor();
}
Aggregations