Search in sources :

Example 6 with OrientedBoundingBox

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();
}
Also used : Line(com.ardor3d.scenegraph.Line) OrientedBoundingBox(com.ardor3d.bounding.OrientedBoundingBox) Mesh(com.ardor3d.scenegraph.Mesh) OrientedBoundingBox(com.ardor3d.bounding.OrientedBoundingBox) Box(com.ardor3d.scenegraph.shape.Box) BMText(com.ardor3d.ui.text.BMText) OffsetState(com.ardor3d.renderer.state.OffsetState)

Example 7 with OrientedBoundingBox

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;
}
Also used : OrientedBoundingBox(com.ardor3d.bounding.OrientedBoundingBox)

Example 8 with OrientedBoundingBox

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);
    }
}
Also used : OrientedBoundingBox(com.ardor3d.bounding.OrientedBoundingBox) UserData(org.concord.energy3d.model.UserData) Spatial(com.ardor3d.scenegraph.Spatial) ArrayList(java.util.ArrayList) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) CullHint(com.ardor3d.scenegraph.hint.CullHint)

Example 9 with OrientedBoundingBox

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;
}
Also used : OrientedBoundingBox(com.ardor3d.bounding.OrientedBoundingBox)

Example 10 with OrientedBoundingBox

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();
}
Also used : Line(com.ardor3d.scenegraph.Line) Cylinder(com.ardor3d.scenegraph.shape.Cylinder) OrientedBoundingBox(com.ardor3d.bounding.OrientedBoundingBox) ColorRGBA(com.ardor3d.math.ColorRGBA) BoundingBox(com.ardor3d.bounding.BoundingBox) OrientedBoundingBox(com.ardor3d.bounding.OrientedBoundingBox) Mesh(com.ardor3d.scenegraph.Mesh) BoundingBox(com.ardor3d.bounding.BoundingBox) Box(com.ardor3d.scenegraph.shape.Box) OrientedBoundingBox(com.ardor3d.bounding.OrientedBoundingBox) BMText(com.ardor3d.ui.text.BMText) OffsetState(com.ardor3d.renderer.state.OffsetState)

Aggregations

OrientedBoundingBox (com.ardor3d.bounding.OrientedBoundingBox)24 Mesh (com.ardor3d.scenegraph.Mesh)9 Node (com.ardor3d.scenegraph.Node)8 BMText (com.ardor3d.ui.text.BMText)8 ColorRGBA (com.ardor3d.math.ColorRGBA)7 ReadOnlyVector3 (com.ardor3d.math.type.ReadOnlyVector3)7 Line (com.ardor3d.scenegraph.Line)7 Vector3 (com.ardor3d.math.Vector3)6 BoundingBox (com.ardor3d.bounding.BoundingBox)5 OffsetState (com.ardor3d.renderer.state.OffsetState)5 Box (com.ardor3d.scenegraph.shape.Box)5 ReadOnlyColorRGBA (com.ardor3d.math.type.ReadOnlyColorRGBA)4 Spatial (com.ardor3d.scenegraph.Spatial)4 CullHint (com.ardor3d.scenegraph.hint.CullHint)4 UserData (org.concord.energy3d.model.UserData)4 Cylinder (com.ardor3d.scenegraph.shape.Cylinder)3 FloatBuffer (java.nio.FloatBuffer)3 HousePart (org.concord.energy3d.model.HousePart)3 CullState (com.ardor3d.renderer.state.CullState)2 Foundation (org.concord.energy3d.model.Foundation)2