Search in sources :

Example 6 with Floor

use of org.concord.energy3d.model.Floor in project energy3d by concord-consortium.

the class MainFrame method showColorDialogForParts.

void showColorDialogForParts() {
    final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
    ActionListener colorActionListener;
    if (selectedPart == null) {
        final ReadOnlyColorRGBA color = Scene.getInstance().getLandColor();
        if (color != null) {
            colorChooser.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue()));
        }
        colorActionListener = new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent e) {
                final float[] newColor = colorChooser.getColor().getComponents(null);
                final ColorRGBA rgba = new ColorRGBA(newColor[0], newColor[1], newColor[2], 0.5f);
                if (!Scene.getInstance().getLandColor().equals(rgba)) {
                    final ChangeLandColorCommand cmd = new ChangeLandColorCommand();
                    Scene.getInstance().setLandColor(rgba);
                    Scene.getInstance().setEdited(true);
                    SceneManager.getInstance().getUndoManager().addEdit(cmd);
                }
            }
        };
    } else {
        if (Scene.getInstance().getTextureMode() != TextureMode.None) {
            // when the user wants to set the color, automatically switch to no texture
            if (JOptionPane.showConfirmDialog(this, "To set color for an individual part, we have to remove the texture. Is that OK?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.NO_OPTION) {
                return;
            }
            Scene.getInstance().setTextureMode(TextureMode.None);
        }
        final ReadOnlyColorRGBA color = selectedPart.getColor();
        if (color != null) {
            colorChooser.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue()));
        }
        colorActionListener = new ActionListener() {

            private boolean changed;

            @Override
            public void actionPerformed(final ActionEvent e) {
                final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
                if (selectedPart == null) {
                    return;
                }
                final Color c = colorChooser.getColor();
                final float[] newColor = c.getComponents(null);
                final boolean restartPrintPreview = Scene.getInstance().getRoofColor().equals(ColorRGBA.WHITE) || c.equals(Color.WHITE);
                final ColorRGBA color = new ColorRGBA(newColor[0], newColor[1], newColor[2], newColor[3]);
                final JPanel panel = new JPanel();
                panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
                panel.setBorder(BorderFactory.createTitledBorder("Apply to:"));
                if (selectedPart instanceof Wall) {
                    final JRadioButton rb1 = new JRadioButton("Only this Wall", true);
                    final JRadioButton rb2 = new JRadioButton("All Walls Connected to This One (Direct and Indirect)");
                    final JRadioButton rb3 = new JRadioButton("All Walls of this Building");
                    final JRadioButton rb4 = new JRadioButton("All Walls");
                    panel.add(rb1);
                    panel.add(rb2);
                    panel.add(rb3);
                    panel.add(rb4);
                    final ButtonGroup bg = new ButtonGroup();
                    bg.add(rb1);
                    bg.add(rb2);
                    bg.add(rb3);
                    bg.add(rb4);
                    final Object[] options = new Object[] { "OK", "Cancel", "Apply" };
                    final JOptionPane optionPane = new JOptionPane(panel, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_CANCEL_OPTION, null, options, options[2]);
                    final JDialog dialog = optionPane.createDialog(MainFrame.getInstance(), "Wall Color");
                    while (true) {
                        changed = false;
                        dialog.setVisible(true);
                        final Object choice = optionPane.getValue();
                        if (choice == options[1]) {
                            break;
                        } else {
                            changed = !color.equals(selectedPart.getColor());
                            if (rb1.isSelected()) {
                                // apply to only this part
                                if (changed) {
                                    final ChangePartColorCommand cmd = new ChangePartColorCommand(selectedPart);
                                    selectedPart.setColor(color);
                                    selectedPart.draw();
                                    SceneManager.getInstance().refresh();
                                    SceneManager.getInstance().getUndoManager().addEdit(cmd);
                                }
                            } else if (rb2.isSelected()) {
                                final Wall w = (Wall) selectedPart;
                                if (!changed) {
                                    w.visitNeighbors(new WallVisitor() {

                                        @Override
                                        public void visit(final Wall currentWall, final Snap prev, final Snap next) {
                                            if (!color.equals(currentWall.getColor())) {
                                                changed = true;
                                            }
                                        }
                                    });
                                }
                                if (changed) {
                                    final ChangeColorOfConnectedWallsCommand cmd = new ChangeColorOfConnectedWallsCommand(w);
                                    Scene.getInstance().setColorOfConnectedWalls(w, color);
                                    SceneManager.getInstance().getUndoManager().addEdit(cmd);
                                }
                            } else if (rb3.isSelected()) {
                                if (!changed) {
                                    for (final HousePart x : Scene.getInstance().getPartsOfSameTypeInBuilding(selectedPart)) {
                                        if (!color.equals(x.getColor())) {
                                            changed = true;
                                            break;
                                        }
                                    }
                                }
                                if (changed) {
                                    final ChangeBuildingColorCommand cmd = new ChangeBuildingColorCommand(selectedPart);
                                    Scene.getInstance().setPartColorOfBuilding(selectedPart, color);
                                    SceneManager.getInstance().getUndoManager().addEdit(cmd);
                                }
                            } else if (rb4.isSelected()) {
                                if (!changed) {
                                    for (final HousePart x : Scene.getInstance().getAllPartsOfSameType(selectedPart)) {
                                        if (!color.equals(x.getColor())) {
                                            changed = true;
                                            break;
                                        }
                                    }
                                }
                                if (changed) {
                                    final ChangeColorOfAllPartsOfSameTypeCommand cmd = new ChangeColorOfAllPartsOfSameTypeCommand(selectedPart);
                                    Scene.getInstance().setColorOfAllPartsOfSameType(selectedPart, color);
                                    SceneManager.getInstance().getUndoManager().addEdit(cmd);
                                }
                            }
                            // remember the color decision for the next wall to be added
                            Scene.getInstance().setWallColor(color);
                            if (choice == options[0]) {
                                break;
                            }
                        }
                    }
                } else if (selectedPart instanceof Roof) {
                    final JRadioButton rb1 = new JRadioButton("Only this Roof", true);
                    final JRadioButton rb2 = new JRadioButton("All Roofs");
                    panel.add(rb1);
                    panel.add(rb2);
                    final ButtonGroup bg = new ButtonGroup();
                    bg.add(rb1);
                    bg.add(rb2);
                    final Object[] options = new Object[] { "OK", "Cancel", "Apply" };
                    final JOptionPane optionPane = new JOptionPane(panel, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_CANCEL_OPTION, null, options, options[2]);
                    final JDialog dialog = optionPane.createDialog(MainFrame.getInstance(), "Roof Color");
                    while (true) {
                        changed = false;
                        dialog.setVisible(true);
                        final Object choice = optionPane.getValue();
                        if (choice == options[1]) {
                            break;
                        } else {
                            changed = !color.equals(selectedPart.getColor());
                            if (rb1.isSelected()) {
                                // apply to only this part
                                if (changed) {
                                    final ChangePartColorCommand cmd = new ChangePartColorCommand(selectedPart);
                                    selectedPart.setColor(color);
                                    selectedPart.draw();
                                    SceneManager.getInstance().refresh();
                                    SceneManager.getInstance().getUndoManager().addEdit(cmd);
                                }
                            } else {
                                if (!changed) {
                                    for (final HousePart x : Scene.getInstance().getAllPartsOfSameType(selectedPart)) {
                                        if (!color.equals(x.getColor())) {
                                            changed = true;
                                            break;
                                        }
                                    }
                                }
                                if (changed) {
                                    final ChangeColorOfAllPartsOfSameTypeCommand cmd = new ChangeColorOfAllPartsOfSameTypeCommand(selectedPart);
                                    Scene.getInstance().setColorOfAllPartsOfSameType(selectedPart, color);
                                    SceneManager.getInstance().getUndoManager().addEdit(cmd);
                                }
                            }
                            // remember the color decision for the next roof to be added
                            Scene.getInstance().setRoofColor(color);
                            if (choice == options[0]) {
                                break;
                            }
                        }
                    }
                } else if (selectedPart instanceof Foundation) {
                    final JRadioButton rb1 = new JRadioButton("Only this Foundation", true);
                    final JRadioButton rb2 = new JRadioButton("All Foundations");
                    panel.add(rb1);
                    panel.add(rb2);
                    final ButtonGroup bg = new ButtonGroup();
                    bg.add(rb1);
                    bg.add(rb2);
                    final Object[] options = new Object[] { "OK", "Cancel", "Apply" };
                    final JOptionPane optionPane = new JOptionPane(panel, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_CANCEL_OPTION, null, options, options[2]);
                    final JDialog dialog = optionPane.createDialog(MainFrame.getInstance(), "Foundation Color");
                    while (true) {
                        changed = false;
                        dialog.setVisible(true);
                        final Object choice = optionPane.getValue();
                        if (choice == options[1]) {
                            break;
                        } else {
                            changed = !color.equals(selectedPart.getColor());
                            if (rb1.isSelected()) {
                                // apply to only this part
                                if (changed) {
                                    final ChangePartColorCommand cmd = new ChangePartColorCommand(selectedPart);
                                    selectedPart.setColor(color);
                                    selectedPart.draw();
                                    SceneManager.getInstance().refresh();
                                    SceneManager.getInstance().getUndoManager().addEdit(cmd);
                                }
                            } else {
                                if (!changed) {
                                    for (final HousePart x : Scene.getInstance().getAllPartsOfSameType(selectedPart)) {
                                        if (!color.equals(x.getColor())) {
                                            changed = true;
                                            break;
                                        }
                                    }
                                }
                                if (changed) {
                                    final ChangeColorOfAllPartsOfSameTypeCommand cmd = new ChangeColorOfAllPartsOfSameTypeCommand(selectedPart);
                                    Scene.getInstance().setColorOfAllPartsOfSameType(selectedPart, color);
                                    SceneManager.getInstance().getUndoManager().addEdit(cmd);
                                }
                            }
                            // remember the color decision for the next foundation to be added
                            Scene.getInstance().setFoundationColor(color);
                            if (choice == options[0]) {
                                break;
                            }
                        }
                    }
                } else {
                    changed = !color.equals(selectedPart.getColor());
                    if (changed) {
                        final ChangePartColorCommand cmd = new ChangePartColorCommand(selectedPart);
                        selectedPart.setColor(color);
                        selectedPart.draw();
                        SceneManager.getInstance().refresh();
                        SceneManager.getInstance().getUndoManager().addEdit(cmd);
                        if (selectedPart instanceof Door) {
                            // remember the color decision for the next part
                            Scene.getInstance().setDoorColor(color);
                        } else if (selectedPart instanceof Floor) {
                            Scene.getInstance().setFloorColor(color);
                        }
                    }
                }
                Scene.getInstance().setTextureMode(Scene.getInstance().getTextureMode());
                if (restartPrintPreview && PrintController.getInstance().isPrintPreview()) {
                    PrintController.getInstance().restartAnimation();
                }
                MainPanel.getInstance().getEnergyButton().setSelected(false);
                Scene.getInstance().setEdited(changed);
            }
        };
    }
    JColorChooser.createDialog(this, "Select Color", true, colorChooser, colorActionListener, null).setVisible(true);
}
Also used : ReadOnlyColorRGBA(com.ardor3d.math.type.ReadOnlyColorRGBA) JPanel(javax.swing.JPanel) Wall(org.concord.energy3d.model.Wall) JRadioButton(javax.swing.JRadioButton) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) Snap(org.concord.energy3d.model.Snap) ChangeColorOfConnectedWallsCommand(org.concord.energy3d.undo.ChangeColorOfConnectedWallsCommand) WallVisitor(org.concord.energy3d.util.WallVisitor) Roof(org.concord.energy3d.model.Roof) ChangePartColorCommand(org.concord.energy3d.undo.ChangePartColorCommand) Foundation(org.concord.energy3d.model.Foundation) HousePart(org.concord.energy3d.model.HousePart) ChangeLandColorCommand(org.concord.energy3d.undo.ChangeLandColorCommand) Floor(org.concord.energy3d.model.Floor) ChangeColorOfAllPartsOfSameTypeCommand(org.concord.energy3d.undo.ChangeColorOfAllPartsOfSameTypeCommand) Color(java.awt.Color) JOptionPane(javax.swing.JOptionPane) Door(org.concord.energy3d.model.Door) ActionListener(java.awt.event.ActionListener) ReadOnlyColorRGBA(com.ardor3d.math.type.ReadOnlyColorRGBA) ColorRGBA(com.ardor3d.math.ColorRGBA) ButtonGroup(javax.swing.ButtonGroup) ChangeBuildingColorCommand(org.concord.energy3d.undo.ChangeBuildingColorCommand) JDialog(javax.swing.JDialog)

Example 7 with Floor

use of org.concord.energy3d.model.Floor in project energy3d by concord-consortium.

the class Scene method pasteToPickedLocationOnFloor.

public void pasteToPickedLocationOnFloor() {
    EnergyPanel.getInstance().updateRadiationHeatMap();
    if (copyBuffer == null) {
        return;
    }
    if (copyBuffer instanceof Foundation) {
        return;
    }
    final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
    if (!(selectedPart instanceof Floor)) {
        return;
    }
    final HousePart c = copyBuffer.copy(false);
    if (c == null) {
        return;
    }
    Vector3 position = SceneManager.getInstance().getPickedLocationOnFloor();
    if (position == null) {
        return;
    }
    if (selectedPart != c.getContainer()) {
        // solar panels and racks can be pasted to a different parent
        if (c instanceof SolarPanel) {
            ((SolarPanel) c).moveTo(selectedPart);
        } else if (c instanceof Rack) {
            ((Rack) c).moveTo(selectedPart);
        }
    }
    position = c.toRelative(position.subtractLocal(c.getContainer().getAbsPoint(0)));
    final Vector3 center = c.toRelative(c.getAbsCenter().subtractLocal(c.getContainer().getAbsPoint(0)));
    position = position.subtractLocal(center);
    final int n = c.getPoints().size();
    for (int i = 0; i < n; i++) {
        final Vector3 v = c.getPoints().get(i);
        v.addLocal(position);
    }
    if (c instanceof Rack) {
        ((Rack) c).moveSolarPanels(position);
        setIdOfChildren(c);
    }
    add(c, true);
    copyBuffer = c;
    SceneManager.getInstance().setSelectedPart(c);
    SceneManager.getInstance().getUndoManager().addEdit(new PastePartCommand(c));
}
Also used : Floor(org.concord.energy3d.model.Floor) Rack(org.concord.energy3d.model.Rack) SolarPanel(org.concord.energy3d.model.SolarPanel) Foundation(org.concord.energy3d.model.Foundation) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) HousePart(org.concord.energy3d.model.HousePart) PastePartCommand(org.concord.energy3d.undo.PastePartCommand)

Example 8 with Floor

use of org.concord.energy3d.model.Floor in project energy3d by concord-consortium.

the class Scene method cleanup.

private void cleanup() {
    // fix if roof and wall are not linked from each other
    for (final HousePart p : parts) {
        if (p instanceof Roof) {
            final Roof r = (Roof) p;
            final HousePart c = r.getContainer();
            if (c != null && !c.getChildren().contains(r)) {
                c.getChildren().add(r);
            }
        }
    }
    final ArrayList<HousePart> toBeRemoved = new ArrayList<HousePart>();
    for (final HousePart p : parts) {
        if (!p.isValid()) {
            // remove invalid parts
            toBeRemoved.add(p);
        } else if (p.getContainer() == null) {
            // remove orphan parts without a container
            if (p instanceof Wall || p instanceof Roof || p instanceof Window || p instanceof Door || p instanceof SolarCollector || p instanceof Floor) {
                toBeRemoved.add(p);
            }
        } else if (!parts.contains(p.getContainer())) {
            // remove parts whose container doesn't exist in the scene
            toBeRemoved.add(p);
        }
    }
    for (final HousePart p : toBeRemoved) {
        remove(p, false);
    }
    // remove walls that are at the same position
    toBeRemoved.clear();
    for (final HousePart p : parts) {
        if (p instanceof Wall) {
            // remove walls that are at the same position
            if (((Wall) p).isAtSamePlaceAsAnotherPart()) {
                toBeRemoved.add(p);
            }
        }
    }
    for (final HousePart p : toBeRemoved) {
        remove(p, false);
    }
    // remove children with multiple parents
    toBeRemoved.clear();
    for (final HousePart p : parts) {
        for (final HousePart child : p.getChildren()) {
            if (child.getContainer() != p && !toBeRemoved.contains(child)) {
                toBeRemoved.add(child);
            }
        }
    }
    for (final HousePart p : toBeRemoved) {
        remove(p, false);
    }
    // remove from remaining parents
    for (final HousePart p : parts) {
        for (final HousePart r : toBeRemoved) {
            p.getChildren().remove(r);
        }
    }
    // remove all the children that are not in parts
    toBeRemoved.clear();
    for (final HousePart p : parts) {
        for (final HousePart child : p.getChildren()) {
            if (!parts.contains(child) && !toBeRemoved.contains(child)) {
                toBeRemoved.add(child);
            }
        }
    }
    for (final HousePart p : toBeRemoved) {
        remove(p, false);
    }
    // complete all non-completed parts
    for (final HousePart p : parts) {
        if (!p.isDrawCompleted()) {
            p.complete();
        }
    }
}
Also used : Window(org.concord.energy3d.model.Window) Floor(org.concord.energy3d.model.Floor) Roof(org.concord.energy3d.model.Roof) Wall(org.concord.energy3d.model.Wall) SolarCollector(org.concord.energy3d.model.SolarCollector) ArrayList(java.util.ArrayList) HousePart(org.concord.energy3d.model.HousePart) Door(org.concord.energy3d.model.Door)

Example 9 with Floor

use of org.concord.energy3d.model.Floor in project energy3d by concord-consortium.

the class SolarRadiation method computeToday.

private void computeToday() {
    // save current calendar for restoring at the end of this calculation
    final Calendar today = (Calendar) Heliodon.getInstance().getCalendar().clone();
    hourOfDay = today.get(Calendar.HOUR_OF_DAY);
    minuteOfHour = today.get(Calendar.MINUTE);
    today.set(Calendar.SECOND, 0);
    today.set(Calendar.MINUTE, 0);
    today.set(Calendar.HOUR_OF_DAY, 0);
    final String city = (String) EnergyPanel.getInstance().getCityComboBox().getSelectedItem();
    dailyAirTemperatures = Weather.computeOutsideTemperature(today, city);
    final int timeStep = Scene.getInstance().getTimeStep();
    final ReadOnlyVector3[] sunLocations = new ReadOnlyVector3[SolarRadiation.MINUTES_OF_DAY / timeStep];
    int totalSteps = 0;
    for (int minute = 0; minute < SolarRadiation.MINUTES_OF_DAY; minute += timeStep) {
        final ReadOnlyVector3 sunLocation = Heliodon.getInstance().computeSunLocation(today).normalizeLocal();
        sunLocations[minute / timeStep] = sunLocation;
        if (sunLocation.getZ() > 0) {
            totalSteps++;
        }
        today.add(Calendar.MINUTE, timeStep);
    }
    totalSteps -= 2;
    final double dayLength = totalSteps * timeStep / 60.0;
    int step = 1;
    setupImportedMeshes();
    // for (int minute = MINUTES_OF_DAY / 2; minute < MINUTES_OF_DAY / 2 + timeStep; minute += timeStep) { // test for 12 pm for comparison with shadow
    for (int minute = 0; minute < MINUTES_OF_DAY; minute += timeStep) {
        final ReadOnlyVector3 sunLocation = sunLocations[minute / timeStep];
        if (sunLocation.getZ() > 0) {
            final ReadOnlyVector3 directionTowardSun = sunLocation.normalize(null);
            calculatePeakRadiation(directionTowardSun, dayLength);
            for (final HousePart part : Scene.getInstance().getParts()) {
                if (part.isDrawCompleted()) {
                    if (part instanceof Window) {
                        computeOnMesh(minute, directionTowardSun, part, part.getRadiationMesh(), (Mesh) part.getRadiationCollisionSpatial(), part.getNormal());
                    } else if (part instanceof Wall) {
                        if (((Wall) part).getType() == Wall.SOLID_WALL) {
                            computeOnMesh(minute, directionTowardSun, part, part.getRadiationMesh(), (Mesh) part.getRadiationCollisionSpatial(), part.getNormal());
                        }
                    } else if (part instanceof Door || part instanceof Floor) {
                        computeOnMesh(minute, directionTowardSun, part, part.getRadiationMesh(), (Mesh) part.getRadiationCollisionSpatial(), part.getNormal());
                    } else if (part instanceof Foundation) {
                        final Foundation foundation = (Foundation) part;
                        for (int i = 0; i < 5; i++) {
                            final Mesh radiationMesh = foundation.getRadiationMesh(i);
                            final ReadOnlyVector3 normal = i == 0 ? part.getNormal() : ((UserData) radiationMesh.getUserData()).getNormal();
                            computeOnMesh(minute, directionTowardSun, part, radiationMesh, foundation.getRadiationCollisionSpatial(i), normal);
                        }
                        if (!Scene.getInstance().getOnlySolarComponentsInSolarMap()) {
                            final List<Node> importedNodes = foundation.getImportedNodes();
                            if (importedNodes != null) {
                                for (final Node node : importedNodes) {
                                    for (final Spatial s : node.getChildren()) {
                                        final Mesh m = (Mesh) s;
                                        computeOnImportedMesh(minute, directionTowardSun, foundation, m);
                                    }
                                }
                            }
                        }
                    } else if (part instanceof Roof) {
                        for (final Spatial roofPart : ((Roof) part).getRoofPartsRoot().getChildren()) {
                            if (roofPart.getSceneHints().getCullHint() != CullHint.Always) {
                                final ReadOnlyVector3 faceDirection = (ReadOnlyVector3) roofPart.getUserData();
                                final Mesh mesh = (Mesh) ((Node) roofPart).getChild(6);
                                computeOnMesh(minute, directionTowardSun, part, mesh, mesh, faceDirection);
                            }
                        }
                    } else if (part instanceof SolarPanel) {
                        computeOnSolarPanel(minute, directionTowardSun, (SolarPanel) part);
                    } else if (part instanceof Rack) {
                        computeOnRack(minute, directionTowardSun, (Rack) part);
                    } else if (part instanceof Mirror) {
                        computeOnMirror(minute, directionTowardSun, (Mirror) part);
                    } else if (part instanceof FresnelReflector) {
                        computeOnFresnelReflector(minute, directionTowardSun, (FresnelReflector) part);
                    } else if (part instanceof ParabolicTrough) {
                        computeOnParabolicTrough(minute, directionTowardSun, (ParabolicTrough) part);
                    } else if (part instanceof ParabolicDish) {
                        computeOnParabolicDish(minute, directionTowardSun, (ParabolicDish) part);
                    } else if (part instanceof Sensor) {
                        computeOnSensor(minute, directionTowardSun, (Sensor) part);
                    }
                }
            }
            computeOnLand(directionTowardSun);
            EnergyPanel.getInstance().progress((int) Math.round(100.0 * step / totalSteps));
            step++;
        }
    }
    maxValue = Math.round((MINUTES_OF_DAY / timeStep + 1.0) * (1 - 0.01 * Scene.getInstance().getSolarHeatMapColorContrast()));
    // If tracking the sun, the heliodon's calendar has been changed. Restore the time now.
    resetTrackables();
}
Also used : ParabolicTrough(org.concord.energy3d.model.ParabolicTrough) Wall(org.concord.energy3d.model.Wall) UserData(org.concord.energy3d.model.UserData) Node(com.ardor3d.scenegraph.Node) Rack(org.concord.energy3d.model.Rack) Roof(org.concord.energy3d.model.Roof) Foundation(org.concord.energy3d.model.Foundation) List(java.util.List) ArrayList(java.util.ArrayList) HousePart(org.concord.energy3d.model.HousePart) Window(org.concord.energy3d.model.Window) Floor(org.concord.energy3d.model.Floor) FresnelReflector(org.concord.energy3d.model.FresnelReflector) Calendar(java.util.Calendar) Mesh(com.ardor3d.scenegraph.Mesh) CullHint(com.ardor3d.scenegraph.hint.CullHint) TPoint(org.poly2tri.triangulation.point.TPoint) Point(org.poly2tri.geometry.primitives.Point) Door(org.concord.energy3d.model.Door) ParabolicDish(org.concord.energy3d.model.ParabolicDish) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Spatial(com.ardor3d.scenegraph.Spatial) SolarPanel(org.concord.energy3d.model.SolarPanel) Mirror(org.concord.energy3d.model.Mirror) Sensor(org.concord.energy3d.model.Sensor)

Example 10 with Floor

use of org.concord.energy3d.model.Floor in project energy3d by concord-consortium.

the class SolarRadiation method updateTextures.

public void updateTextures() {
    EnergyPanel.getInstance().setComputingStartMillis(System.currentTimeMillis());
    maxValue = Math.round((MINUTES_OF_DAY / Scene.getInstance().getTimeStep() + 1.0) * (1 - 0.01 * Scene.getInstance().getSolarHeatMapColorContrast()));
    applyTexture(SceneManager.getInstance().getSolarLand());
    final int totalMeshes = Scene.getInstance().getParts().size() + Scene.getInstance().countMeshes();
    int countMesh = 0;
    for (final HousePart part : Scene.getInstance().getParts()) {
        if (part instanceof SolarCollector) {
            applyTexture(part.getRadiationMesh());
        } else {
            if (!Scene.getInstance().getOnlySolarComponentsInSolarMap()) {
                if (part instanceof Wall || part instanceof Door || part instanceof Floor) {
                    applyTexture(part.getRadiationMesh());
                } else if (part instanceof Foundation) {
                    final Foundation foundation = (Foundation) part;
                    for (int i = 0; i < 5; i++) {
                        applyTexture(foundation.getRadiationMesh(i));
                    }
                    final List<Node> importedNodes = foundation.getImportedNodes();
                    if (importedNodes != null) {
                        for (final Node node : importedNodes) {
                            for (final Spatial s : node.getChildren()) {
                                applyTexture((Mesh) s);
                                EnergyPanel.getInstance().progress((int) Math.round(100.0 * (countMesh++) / totalMeshes));
                            }
                        }
                    }
                } else if (part instanceof Roof) {
                    for (final Spatial roofPart : ((Roof) part).getRoofPartsRoot().getChildren()) {
                        if (roofPart.getSceneHints().getCullHint() != CullHint.Always) {
                            final Mesh mesh = (Mesh) ((Node) roofPart).getChild(6);
                            applyTexture(mesh);
                        }
                    }
                }
            }
        }
        countMesh++;
    }
    EnergyPanel.getInstance().progress(0);
}
Also used : Floor(org.concord.energy3d.model.Floor) Roof(org.concord.energy3d.model.Roof) Wall(org.concord.energy3d.model.Wall) Spatial(com.ardor3d.scenegraph.Spatial) SolarCollector(org.concord.energy3d.model.SolarCollector) Node(com.ardor3d.scenegraph.Node) Mesh(com.ardor3d.scenegraph.Mesh) Foundation(org.concord.energy3d.model.Foundation) List(java.util.List) ArrayList(java.util.ArrayList) CullHint(com.ardor3d.scenegraph.hint.CullHint) TPoint(org.poly2tri.triangulation.point.TPoint) Point(org.poly2tri.geometry.primitives.Point) HousePart(org.concord.energy3d.model.HousePart) Door(org.concord.energy3d.model.Door)

Aggregations

Floor (org.concord.energy3d.model.Floor)16 HousePart (org.concord.energy3d.model.HousePart)15 Foundation (org.concord.energy3d.model.Foundation)12 Door (org.concord.energy3d.model.Door)11 Roof (org.concord.energy3d.model.Roof)11 Wall (org.concord.energy3d.model.Wall)11 Window (org.concord.energy3d.model.Window)10 Rack (org.concord.energy3d.model.Rack)9 SolarPanel (org.concord.energy3d.model.SolarPanel)8 Tree (org.concord.energy3d.model.Tree)7 ArrayList (java.util.ArrayList)6 List (java.util.List)5 Mesh (com.ardor3d.scenegraph.Mesh)4 Node (com.ardor3d.scenegraph.Node)4 Spatial (com.ardor3d.scenegraph.Spatial)4 Human (org.concord.energy3d.model.Human)4 Sensor (org.concord.energy3d.model.Sensor)4 SolarCollector (org.concord.energy3d.model.SolarCollector)4 ReadOnlyVector3 (com.ardor3d.math.type.ReadOnlyVector3)3 CullHint (com.ardor3d.scenegraph.hint.CullHint)3