Search in sources :

Example 1 with Node

use of com.ardor3d.scenegraph.Node in project energy3d by concord-consortium.

the class Foundation method pickMesh.

public void pickMesh(final int x, final int y) {
    selectedMesh = null;
    if (importedNodes != null) {
        final PickResults pickResults = new PrimitivePickResults();
        pickResults.setCheckDistance(true);
        final Ray3 pickRay = SceneManager.getInstance().getCamera().getPickRay(new Vector2(x, y), false, null);
        for (final Node node : importedNodes) {
            for (final Spatial s : node.getChildren()) {
                if (s instanceof Mesh) {
                    PickingUtil.findPick(s, pickRay, pickResults, false);
                }
            }
        }
        if (pickResults.getNumber() > 0) {
            final Pickable pickable = pickResults.getPickData(0).getTarget();
            if (pickable instanceof Mesh) {
                selectedMesh = (Mesh) pickable;
                drawMeshSelection(selectedMesh);
            }
        } else {
            setMeshSelectionVisible(false);
        }
    }
}
Also used : PrimitivePickResults(com.ardor3d.intersection.PrimitivePickResults) ReadOnlyVector2(com.ardor3d.math.type.ReadOnlyVector2) Vector2(com.ardor3d.math.Vector2) Spatial(com.ardor3d.scenegraph.Spatial) Pickable(com.ardor3d.intersection.Pickable) Node(com.ardor3d.scenegraph.Node) Mesh(com.ardor3d.scenegraph.Mesh) PrimitivePickResults(com.ardor3d.intersection.PrimitivePickResults) PickResults(com.ardor3d.intersection.PickResults) Ray3(com.ardor3d.math.Ray3)

Example 2 with Node

use of com.ardor3d.scenegraph.Node in project energy3d by concord-consortium.

the class Foundation method processImportedMeshes.

// imported nodes often have a twin of meshes with identical vertex coordinates but opposite normal vectors, find these and offset them
public void processImportedMeshes() {
    // this could be a very compute-intensive task
    SceneManager.getInstance().cursorWait(true);
    for (final Node node : importedNodes) {
        NodeWorker.reach(node);
    }
    clearSelectedMesh();
    SceneManager.getInstance().cursorWait(false);
}
Also used : Node(com.ardor3d.scenegraph.Node)

Example 3 with Node

use of com.ardor3d.scenegraph.Node in project energy3d by concord-consortium.

the class Foundation method drawImportedNodes.

public void drawImportedNodes() {
    if (importedNodes != null) {
        final int n = importedNodes.size();
        if (n > 0) {
            Node ni;
            final Vector3 c = getAbsCenter();
            // the absolute center is lifted to the center of the bounding box that includes walls when there are
            c.setZ(height);
            // FIXME: Why negate?
            final Matrix3 matrix = new Matrix3().fromAngles(0, 0, -Math.toRadians(getAzimuth()));
            for (int i = 0; i < n; i++) {
                ni = importedNodes.get(i);
                if (root.getChildren().contains(ni)) {
                    final Vector3 relativePosition = importedNodeStates.get(i).getRelativePosition();
                    if (relativePosition != null) {
                        final Vector3 vi = matrix.applyPost(relativePosition, null);
                        ni.setTranslation(c.add(vi, null));
                        ni.setRotation(matrix);
                        for (final Spatial s : ni.getChildren()) {
                            if (s instanceof Mesh) {
                                final Mesh m = (Mesh) s;
                                m.updateModelBound();
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : Spatial(com.ardor3d.scenegraph.Spatial) Node(com.ardor3d.scenegraph.Node) Mesh(com.ardor3d.scenegraph.Mesh) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) CullHint(com.ardor3d.scenegraph.hint.CullHint) Matrix3(com.ardor3d.math.Matrix3)

Example 4 with Node

use of com.ardor3d.scenegraph.Node 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 5 with Node

use of com.ardor3d.scenegraph.Node 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)

Aggregations

Node (com.ardor3d.scenegraph.Node)50 Mesh (com.ardor3d.scenegraph.Mesh)31 ReadOnlyVector3 (com.ardor3d.math.type.ReadOnlyVector3)27 Spatial (com.ardor3d.scenegraph.Spatial)26 Vector3 (com.ardor3d.math.Vector3)20 CullHint (com.ardor3d.scenegraph.hint.CullHint)20 Foundation (org.concord.energy3d.model.Foundation)12 FloatBuffer (java.nio.FloatBuffer)11 ArrayList (java.util.ArrayList)11 Line (com.ardor3d.scenegraph.Line)10 HousePart (org.concord.energy3d.model.HousePart)10 TPoint (org.poly2tri.triangulation.point.TPoint)10 OrientedBoundingBox (com.ardor3d.bounding.OrientedBoundingBox)9 ColorRGBA (com.ardor3d.math.ColorRGBA)7 ReadOnlyColorRGBA (com.ardor3d.math.type.ReadOnlyColorRGBA)7 BoundingBox (com.ardor3d.bounding.BoundingBox)6 BMText (com.ardor3d.ui.text.BMText)6 List (java.util.List)6 Rack (org.concord.energy3d.model.Rack)6 Roof (org.concord.energy3d.model.Roof)6