Search in sources :

Example 1 with OrientedBoundingBox

use of com.ardor3d.bounding.OrientedBoundingBox in project energy3d by concord-consortium.

the class Foundation method scanChildrenHeight.

public void scanChildrenHeight() {
    if (!isFirstPointInserted()) {
        return;
    }
    boundingHeight = scanChildrenHeight(this) - height;
    for (int i = 4; i < Math.min(8, points.size()); i++) {
        points.get(i).setZ(boundingHeight + height);
    }
    if (importedNodes != null) {
        boolean taller = false;
        for (final Node n : importedNodes) {
            final OrientedBoundingBox b = Util.getOrientedBoundingBox(n);
            final double bh = b.getCenter().getZ() + b.getExtent().getZ();
            if (bh > boundingHeight) {
                boundingHeight = bh;
                taller = true;
            }
        }
        if (taller) {
            // subtract as bounding box height includes the foundation height
            boundingHeight -= height;
        }
    }
    newBoundingHeight = boundingHeight;
    syncUpperPoints();
    updateEditShapes();
}
Also used : OrientedBoundingBox(com.ardor3d.bounding.OrientedBoundingBox) Node(com.ardor3d.scenegraph.Node) CullHint(com.ardor3d.scenegraph.hint.CullHint)

Example 2 with OrientedBoundingBox

use of com.ardor3d.bounding.OrientedBoundingBox in project energy3d by concord-consortium.

the class FresnelReflector method isDrawable.

@Override
public boolean isDrawable() {
    if (container == null) {
        return true;
    }
    if (mesh.getWorldBound() == null) {
        return true;
    }
    final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
    if (selectedPart == null || selectedPart.isDrawCompleted()) {
        // if nothing is really selected, skip overlap check
        return true;
    }
    final OrientedBoundingBox bound = (OrientedBoundingBox) mesh.getWorldBound().clone(null);
    bound.setExtent(bound.getExtent().divide(1.1, null).addLocal(0, 0, 1));
    for (final HousePart child : container.getChildren()) {
        if (child != this && child instanceof FresnelReflector && bound.intersects(child.mesh.getWorldBound())) {
            return false;
        }
    }
    return true;
}
Also used : OrientedBoundingBox(com.ardor3d.bounding.OrientedBoundingBox)

Example 3 with OrientedBoundingBox

use of com.ardor3d.bounding.OrientedBoundingBox in project energy3d by concord-consortium.

the class FresnelReflector method init.

@Override
protected void init() {
    super.init();
    if (Util.isZero(copyLayoutGap)) {
        // FIXME: Why is a transient member evaluated to zero?
        copyLayoutGap = 0.2;
    }
    if (Util.isZero(moduleLength)) {
        moduleLength = 3;
    }
    if (Util.isZero(length)) {
        length = 2 * moduleLength;
    }
    if (Util.isZero(moduleWidth)) {
        moduleWidth = 2;
    }
    if (Util.isZero(reflectance)) {
        reflectance = 0.9;
    }
    if (Util.isZero(opticalEfficiency)) {
        opticalEfficiency = 0.99;
    }
    if (Util.isZero(nSectionLength)) {
        nSectionLength = 16;
    }
    if (Util.isZero(nSectionWidth)) {
        nSectionWidth = 4;
    }
    detailed = Scene.getInstance().countParts(this.getClass()) < 50;
    if (absorber != null) {
        // FIXME: Somehow the absorber foundation, when copied, doesn't point to the right object. This is not a prefect solution, but it fixes the problem.
        absorber = (Foundation) Scene.getInstance().getPart(absorber.getId());
    }
    mesh = new Mesh("Fresnel Reflector Face");
    mesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(6));
    mesh.getMeshData().setTextureBuffer(BufferUtils.createVector2Buffer(6), 0);
    mesh.setDefaultColor(SKY_BLUE);
    mesh.setModelBound(new OrientedBoundingBox());
    mesh.setUserData(new UserData(this));
    root.attachChild(mesh);
    reflector = new Box("Fresnel Reflector Box");
    reflector.setModelBound(new OrientedBoundingBox());
    final OffsetState offset = new OffsetState();
    offset.setFactor(1);
    offset.setUnits(1);
    reflector.setRenderState(offset);
    root.attachChild(reflector);
    final int nModules = Math.max(1, getNumberOfModules());
    outlines = new Line("Fresnel Reflector (Outline)");
    outlines.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(8 + (nModules - 1) * 2));
    outlines.setDefaultColor(ColorRGBA.BLACK);
    outlines.setModelBound(new OrientedBoundingBox());
    outlines.setLineWidth(1f);
    outlines.setStipplePattern((short) 0xffff);
    Util.disablePickShadowLight(outlines);
    root.attachChild(outlines);
    lightBeams = new Line("Light Beams");
    lightBeams.setLineWidth(1f);
    lightBeams.setStipplePattern((short) 0xffff);
    lightBeams.setModelBound(null);
    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);
    modulesRoot = new Node("Modules Root");
    root.attachChild(modulesRoot);
    updateTextureAndColor();
    if (!points.isEmpty()) {
        oldReflectorCenter = points.get(0).clone();
    }
    oldLength = length;
    oldModuleWidth = moduleWidth;
}
Also used : Line(com.ardor3d.scenegraph.Line) OrientedBoundingBox(com.ardor3d.bounding.OrientedBoundingBox) ReadOnlyColorRGBA(com.ardor3d.math.type.ReadOnlyColorRGBA) ColorRGBA(com.ardor3d.math.ColorRGBA) Node(com.ardor3d.scenegraph.Node) 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) CullHint(com.ardor3d.scenegraph.hint.CullHint)

Example 4 with OrientedBoundingBox

use of com.ardor3d.bounding.OrientedBoundingBox in project energy3d by concord-consortium.

the class Rack method init.

@Override
protected void init() {
    super.init();
    if (Util.isZero(copyLayoutGap)) {
        // FIXME: Why is a transient member evaluated to zero?
        copyLayoutGap = 1;
    }
    if (Util.isZero(rackWidth)) {
        rackWidth = 4.95;
    }
    if (Util.isZero(rackHeight)) {
        rackHeight = 1.65;
    }
    if (monthlyTiltAngles == null) {
        monthlyTiltAngles = new double[12];
        Arrays.fill(monthlyTiltAngles, tiltAngle);
    }
    mesh = new Mesh("Rack");
    mesh.setDefaultColor(ColorRGBA.LIGHT_GRAY);
    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("Rack (Surround)");
    surround.setDefaultColor(ColorRGBA.LIGHT_GRAY);
    surround.setModelBound(new OrientedBoundingBox());
    final OffsetState offset = new OffsetState();
    // set a smaller value than solar panel so that the texture doesn't show up on the underside
    offset.setFactor(0.2f);
    offset.setUnits(1);
    surround.setRenderState(offset);
    root.attachChild(surround);
    outlineMesh = new Line("Rack (Outline)");
    outlineMesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(8));
    outlineMesh.setDefaultColor(ColorRGBA.BLACK);
    outlineMesh.setModelBound(new OrientedBoundingBox());
    root.attachChild(outlineMesh);
    sunBeam = new Line("Sun Beam");
    sunBeam.setLineWidth(1f);
    sunBeam.setStipplePattern((short) 0xffff);
    sunBeam.setModelBound(null);
    Util.disablePickShadowLight(sunBeam);
    sunBeam.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(4));
    sunBeam.setDefaultColor(new ColorRGBA(1f, 1f, 1f, 1f));
    root.attachChild(sunBeam);
    normalVector = new Line("Normal Vector");
    normalVector.setLineWidth(1f);
    normalVector.setStipplePattern((short) 0xffff);
    normalVector.setModelBound(null);
    Util.disablePickShadowLight(normalVector);
    normalVector.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(6));
    normalVector.setDefaultColor(new ColorRGBA(1f, 1f, 0f, 1f));
    root.attachChild(normalVector);
    angles = new Node("Angles");
    angles.getSceneHints().setAllPickingHints(false);
    Util.disablePickShadowLight(angles);
    root.attachChild(angles);
    // the angle between the sun beam and the normal vector
    sunAngle = new AngleAnnotation();
    sunAngle.setColor(ColorRGBA.WHITE);
    sunAngle.setLineWidth(1);
    sunAngle.setFontSize(1);
    sunAngle.setCustomRadius(normalVectorLength * 0.8);
    angles.attachChild(sunAngle);
    solarPanelOutlines = new Line("Solar Panel Outlines");
    solarPanelOutlines.setLineWidth(1f);
    solarPanelOutlines.setStipplePattern((short) 0xffff);
    solarPanelOutlines.setModelBound(null);
    Util.disablePickShadowLight(solarPanelOutlines);
    solarPanelOutlines.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(1));
    solarPanelOutlines.setDefaultColor(new ColorRGBA(0f, 0f, 0f, 1f));
    root.attachChild(solarPanelOutlines);
    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);
    polesRoot = new Node("Poles Root");
    root.attachChild(polesRoot);
    updateTextureAndColor();
    if (sampleSolarPanel == null) {
        sampleSolarPanel = new SolarPanel();
    }
    // ugly fixes for zero initial values when sampleSolarPanel is previously serialized without new variables
    if (sampleSolarPanel.getPvModuleSpecs() == null) {
        sampleSolarPanel.setPvModuleSpecs(new PvModuleSpecs());
    }
    if (Util.isZero(sampleSolarPanel.getNominalOperatingCellTemperature())) {
        sampleSolarPanel.setNominalOperatingCellTemperature(48);
    }
    if (!points.isEmpty()) {
        oldRackCenter = points.get(0).clone();
    }
    oldRackWidth = rackWidth;
    oldRackHeight = rackHeight;
}
Also used : Line(com.ardor3d.scenegraph.Line) OrientedBoundingBox(com.ardor3d.bounding.OrientedBoundingBox) ReadOnlyColorRGBA(com.ardor3d.math.type.ReadOnlyColorRGBA) ColorRGBA(com.ardor3d.math.ColorRGBA) Node(com.ardor3d.scenegraph.Node) Mesh(com.ardor3d.scenegraph.Mesh) BoundingBox(com.ardor3d.bounding.BoundingBox) Box(com.ardor3d.scenegraph.shape.Box) OrientedBoundingBox(com.ardor3d.bounding.OrientedBoundingBox) AngleAnnotation(org.concord.energy3d.shapes.AngleAnnotation) BMText(com.ardor3d.ui.text.BMText) PvModuleSpecs(org.concord.energy3d.simulation.PvModuleSpecs) OffsetState(com.ardor3d.renderer.state.OffsetState)

Example 5 with OrientedBoundingBox

use of com.ardor3d.bounding.OrientedBoundingBox in project energy3d by concord-consortium.

the class Rack method isDrawable.

@Override
public boolean isDrawable() {
    if (container == null) {
        return true;
    }
    if (mesh.getWorldBound() == null) {
        return true;
    }
    final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
    if (selectedPart == null || selectedPart.isDrawCompleted()) {
        // if nothing is really selected, skip overlap check
        return true;
    }
    final OrientedBoundingBox bound = (OrientedBoundingBox) mesh.getWorldBound().clone(null);
    bound.setExtent(bound.getExtent().divide(1.1, null).addLocal(0, 0, 1));
    for (final HousePart child : container.getChildren()) {
        if (child != this && child instanceof Rack && bound.intersects(child.mesh.getWorldBound())) {
            return false;
        }
    }
    return true;
}
Also used : OrientedBoundingBox(com.ardor3d.bounding.OrientedBoundingBox)

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