use of com.ardor3d.bounding.OrientedBoundingBox in project energy3d by concord-consortium.
the class Sensor method init.
@Override
protected void init() {
super.init();
mesh = new Mesh("Sensor");
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("Sensor (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("Sensor (Outline)");
outlineMesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(8));
outlineMesh.setDefaultColor(ColorRGBA.BLACK);
outlineMesh.setModelBound(new OrientedBoundingBox());
root.attachChild(outlineMesh);
label = new BMText("" + getId(), "0", FontManager.getInstance().getPartNumberFont(), Align.Center, Justify.Center);
Util.initHousePartLabel(label);
label.setFontScale(0.6);
label.setVisible(true);
root.attachChild(label);
updateTextureAndColor();
}
use of com.ardor3d.bounding.OrientedBoundingBox in project energy3d by concord-consortium.
the class Sensor method isDrawable.
@Override
public boolean isDrawable() {
if (container == null) {
return true;
}
if (mesh.getWorldBound() == null) {
return true;
}
final OrientedBoundingBox bound = (OrientedBoundingBox) mesh.getWorldBound().clone(null);
bound.setExtent(bound.getExtent().divide(1.1, null));
for (final HousePart child : container.getChildren()) {
if (child != this && child instanceof Sensor && bound.intersects(child.mesh.getWorldBound())) {
return false;
}
}
return true;
}
use of com.ardor3d.bounding.OrientedBoundingBox in project energy3d by concord-consortium.
the class PrintController method computePrintCenterOf.
private void computePrintCenterOf(final Spatial printPart, final ArrayList<ArrayList<Spatial>> pages) {
boolean isFitted = false;
for (int pageNum = 0; pageNum < pages.size() && !isFitted; pageNum++) {
isFitted = fitInPage(printPart, pages.get(pageNum));
}
if (!isFitted) {
printPart.updateWorldBound(true);
final OrientedBoundingBox bounds = (OrientedBoundingBox) printPart.getWorldBound().asType(Type.OBB);
((UserData) printPart.getUserData()).setPrintCenter(new Vector3(bounds.getExtent().getX() + pageLeft, Scene.getOriginalHouseRoot().getWorldBound().getCenter().getY(), -bounds.getExtent().getZ() - pageTop));
final ArrayList<Spatial> page = new ArrayList<Spatial>();
page.add(printPart);
pages.add(page);
}
}
use of com.ardor3d.bounding.OrientedBoundingBox in project energy3d by concord-consortium.
the class PrintController method decideVertical.
private boolean decideVertical(final Mesh mesh) {
final OrientedBoundingBox bound = (OrientedBoundingBox) mesh.getWorldBound().asType(Type.OBB);
final boolean isMeshVertical = bound.getExtent().getX() < bound.getExtent().getZ();
final double imageableWidth = pageRight - pageLeft;
return isMeshVertical && bound.getExtent().getZ() * 2 < imageableWidth || !isMeshVertical && bound.getExtent().getX() * 2 > imageableWidth;
}
use of com.ardor3d.bounding.OrientedBoundingBox 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