Search in sources :

Example 46 with Spatial

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

the class Foundation method updateTextureAndColor.

@Override
public void updateTextureAndColor() {
    for (final Mesh mesh : sideMesh) {
        mesh.setDefaultColor(Scene.getInstance().getTextureMode() == TextureMode.Full ? ColorRGBA.GRAY : (getColor() == null ? Scene.getInstance().getFoundationColor() : getColor()));
        updateTextureAndColor(mesh, getColor() == null ? Scene.getInstance().getFoundationColor() : getColor());
    }
    updateTextureAndColor(mesh, getColor() == null ? Scene.getInstance().getFoundationColor() : getColor());
    if (!SceneManager.getInstance().getSolarHeatMap() && importedNodes != null) {
        final int n = importedNodes.size();
        if (n > 0) {
            Node ni;
            for (int i = 0; i < n; i++) {
                ni = importedNodes.get(i);
                if (root.getChildren().contains(ni)) {
                    for (final Spatial s : ni.getChildren()) {
                        if (s instanceof Mesh) {
                            if (s instanceof Line) {
                                continue;
                            }
                            final Mesh m = (Mesh) s;
                            final UserData ud = (UserData) m.getUserData();
                            final TextureState ts = (TextureState) m.getLocalRenderState(StateType.Texture);
                            if (ts == null || ts.getTexture() == null) {
                                m.clearRenderState(StateType.Texture);
                            // m.setDefaultColor(nis.getDefaultColor());
                            } else {
                                if (ud.getTextureBuffer() == null || Util.isZero(ud.getTextureBuffer())) {
                                    m.clearRenderState(StateType.Texture);
                                // m.setDefaultColor(nis.getDefaultColor());
                                } else {
                                    m.getMeshData().setTextureBuffer(ud.getTextureBuffer(), 0);
                                    m.setRenderState(ud.getRenderState());
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : Line(com.ardor3d.scenegraph.Line) TextureState(com.ardor3d.renderer.state.TextureState) Spatial(com.ardor3d.scenegraph.Spatial) Node(com.ardor3d.scenegraph.Node) Mesh(com.ardor3d.scenegraph.Mesh) CullHint(com.ardor3d.scenegraph.hint.CullHint)

Example 47 with Spatial

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

the class Foundation method setMeshThickness.

public void setMeshThickness(final Node node, final double thickness) {
    final NodeState ns = getNodeState(node);
    if (!Util.isEqual(thickness, ns.getMeshThickness())) {
        final double delta = thickness - ns.getMeshThickness();
        for (final Spatial s : node.getChildren()) {
            final Mesh m = (Mesh) s;
            final UserData u = (UserData) m.getUserData();
            // do not use u.getRotateNormal() because in this case rotation would be applied to node, not mesh
            m.addTranslation(u.getNormal().multiply(delta, null));
        }
        ns.setMeshThickness(thickness);
    }
}
Also used : Spatial(com.ardor3d.scenegraph.Spatial) Mesh(com.ardor3d.scenegraph.Mesh)

Example 48 with Spatial

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

the class Foundation method setRotatedNormalsForImportedMeshes.

private void setRotatedNormalsForImportedMeshes() {
    if (importedNodes != null) {
        drawImportedNodes();
        // DO NOT skip zero azimuth case -- final boolean nonZeroAz = !Util.isZero(getAzimuth());
        for (final Node node : importedNodes) {
            for (final Spatial s : node.getChildren()) {
                final Mesh m = (Mesh) s;
                final UserData ud = (UserData) m.getUserData();
                ud.setRotatedNormal(node.getRotation().applyPost(ud.getNormal(), null));
            }
        }
    }
}
Also used : Spatial(com.ardor3d.scenegraph.Spatial) Node(com.ardor3d.scenegraph.Node) Mesh(com.ardor3d.scenegraph.Mesh)

Example 49 with Spatial

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

the class Foundation method createMeshThickness.

private void createMeshThickness(final Node node) {
    final NodeState ns = getNodeState(node);
    double thickness = ns.getMeshThickness();
    if (Util.isZero(thickness)) {
        thickness = 0.05;
        ns.setMeshThickness(thickness);
    }
    for (final Spatial s : node.getChildren()) {
        final Mesh m = (Mesh) s;
        final UserData u = (UserData) m.getUserData();
        // do not use u.getRotateNormal() because in this case rotation would be applied to node, not mesh
        m.addTranslation(u.getNormal().multiply(thickness, null));
    }
}
Also used : Spatial(com.ardor3d.scenegraph.Spatial) Mesh(com.ardor3d.scenegraph.Mesh)

Example 50 with Spatial

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

the class Roof method drawLabels.

@Override
public int drawLabels(int printSequence) {
    for (final Spatial roofPartNode : roofPartsRoot.getChildren()) {
        if (roofPartNode.getSceneHints().getCullHint() != CullHint.Always) {
            final String text = "(" + (printSequence++ + 1) + ")";
            final BMText label = (BMText) ((Node) roofPartNode).getChild(3);
            label.getSceneHints().setCullHint(CullHint.Inherit);
            label.setText(text);
        }
    }
    return printSequence;
}
Also used : Spatial(com.ardor3d.scenegraph.Spatial) BMText(com.ardor3d.ui.text.BMText)

Aggregations

Spatial (com.ardor3d.scenegraph.Spatial)57 Mesh (com.ardor3d.scenegraph.Mesh)36 ReadOnlyVector3 (com.ardor3d.math.type.ReadOnlyVector3)33 Node (com.ardor3d.scenegraph.Node)26 CullHint (com.ardor3d.scenegraph.hint.CullHint)26 Vector3 (com.ardor3d.math.Vector3)24 TPoint (org.poly2tri.triangulation.point.TPoint)18 PickResults (com.ardor3d.intersection.PickResults)15 PrimitivePickResults (com.ardor3d.intersection.PrimitivePickResults)15 Ray3 (com.ardor3d.math.Ray3)15 Point (org.poly2tri.geometry.primitives.Point)14 FloatBuffer (java.nio.FloatBuffer)13 ArrayList (java.util.ArrayList)12 HousePart (org.concord.energy3d.model.HousePart)12 CancellationException (java.util.concurrent.CancellationException)10 Foundation (org.concord.energy3d.model.Foundation)10 Roof (org.concord.energy3d.model.Roof)9 Calendar (java.util.Calendar)7 UserData (org.concord.energy3d.model.UserData)6 Window (org.concord.energy3d.model.Window)6