Search in sources :

Example 61 with ReadOnlyVector3

use of com.ardor3d.math.type.ReadOnlyVector3 in project energy3d by concord-consortium.

the class SolarRadiation method computeOnSensor.

private void computeOnSensor(final int minute, final ReadOnlyVector3 directionTowardSun, final Sensor sensor) {
    final int nx = 2, ny = 2;
    // nx*ny*60: nx*ny is to get the unit cell area of the nx*ny grid; 60 is to convert the unit of timeStep from minute to kWh
    final double a = Sensor.WIDTH * Sensor.HEIGHT * Scene.getInstance().getTimeStep() / (nx * ny * 60.0);
    final ReadOnlyVector3 normal = sensor.getNormal();
    if (normal == null) {
        throw new RuntimeException("Normal is null");
    }
    final Mesh drawMesh = sensor.getRadiationMesh();
    final Mesh collisionMesh = (Mesh) sensor.getRadiationCollisionSpatial();
    MeshDataStore data = onMesh.get(drawMesh);
    if (data == null) {
        data = initMeshTextureDataOnRectangle(drawMesh, nx, ny);
    }
    final ReadOnlyVector3 offset = directionTowardSun.multiply(1, null);
    final double dot = normal.dot(directionTowardSun);
    double directRadiation = 0;
    if (dot > 0) {
        directRadiation += calculateDirectRadiation(directionTowardSun, normal);
    }
    final double indirectRadiation = calculateDiffuseAndReflectedRadiation(directionTowardSun, normal);
    final FloatBuffer vertexBuffer = drawMesh.getMeshData().getVertexBuffer();
    // (0, 0)
    final Vector3 p0 = new Vector3(vertexBuffer.get(3), vertexBuffer.get(4), vertexBuffer.get(5));
    // (1, 0)
    final Vector3 p1 = new Vector3(vertexBuffer.get(6), vertexBuffer.get(7), vertexBuffer.get(8));
    // (0, 1)
    final Vector3 p2 = new Vector3(vertexBuffer.get(0), vertexBuffer.get(1), vertexBuffer.get(2));
    // this is the longer side (supposed to be y)
    final Vector3 u = p1.subtract(p0, null).normalizeLocal();
    // this is the shorter side (supposed to be x)
    final Vector3 v = p2.subtract(p0, null).normalizeLocal();
    // x and y must be swapped to have correct heat map texture, because nx represents rows and ny columns as we call initMeshTextureDataOnRectangle(mesh, nx, ny)
    final double xSpacing = p1.distance(p0) / nx;
    final double ySpacing = p2.distance(p0) / ny;
    final int iMinute = minute / Scene.getInstance().getTimeStep();
    for (int x = 0; x < nx; x++) {
        for (int y = 0; y < ny; y++) {
            if (EnergyPanel.getInstance().isCancelled()) {
                throw new CancellationException();
            }
            final Vector3 u2 = u.multiply(xSpacing * (x + 0.5), null);
            final Vector3 v2 = v.multiply(ySpacing * (y + 0.5), null);
            final ReadOnlyVector3 p = drawMesh.getWorldTransform().applyForward(p0.add(v2, null).addLocal(u2)).addLocal(offset);
            final Ray3 pickRay = new Ray3(p, directionTowardSun);
            // assuming that indirect (ambient or diffuse) radiation can always reach a grid point
            double radiation = indirectRadiation;
            if (dot > 0) {
                final PickResults pickResults = new PrimitivePickResults();
                for (final Spatial spatial : collidables) {
                    if (spatial != collisionMesh) {
                        PickingUtil.findPick(spatial, pickRay, pickResults, false);
                        if (pickResults.getNumber() != 0) {
                            break;
                        }
                    }
                }
                if (pickResults.getNumber() == 0) {
                    radiation += directRadiation;
                }
            }
            data.dailySolarIntensity[x][y] += radiation;
            sensor.getSolarPotential()[iMinute] += radiation * a;
        }
    }
}
Also used : Mesh(com.ardor3d.scenegraph.Mesh) FloatBuffer(java.nio.FloatBuffer) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) CullHint(com.ardor3d.scenegraph.hint.CullHint) TPoint(org.poly2tri.triangulation.point.TPoint) Point(org.poly2tri.geometry.primitives.Point) Ray3(com.ardor3d.math.Ray3) PrimitivePickResults(com.ardor3d.intersection.PrimitivePickResults) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) CancellationException(java.util.concurrent.CancellationException) Spatial(com.ardor3d.scenegraph.Spatial) PrimitivePickResults(com.ardor3d.intersection.PrimitivePickResults) PickResults(com.ardor3d.intersection.PickResults)

Example 62 with ReadOnlyVector3

use of com.ardor3d.math.type.ReadOnlyVector3 in project energy3d by concord-consortium.

the class SolarRadiation method initMeshTextureData.

private MeshDataStore initMeshTextureData(final Mesh drawMesh, final Mesh collisionMesh, final ReadOnlyVector3 normal, final boolean updateTexture) {
    final MeshDataStore data = new MeshDataStore();
    if (normal != null) {
        final AnyToXYTransform toXY = new AnyToXYTransform(normal.getX(), normal.getY(), normal.getZ());
        final XYToAnyTransform fromXY = new XYToAnyTransform(normal.getX(), normal.getY(), normal.getZ());
        final FloatBuffer vertexBuffer = collisionMesh.getMeshData().getVertexBuffer();
        vertexBuffer.rewind();
        double minX, minY, maxX, maxY;
        minX = minY = Double.POSITIVE_INFINITY;
        maxX = maxY = Double.NEGATIVE_INFINITY;
        double z = Double.NaN;
        final List<ReadOnlyVector2> points = new ArrayList<ReadOnlyVector2>(vertexBuffer.limit() / 3);
        while (vertexBuffer.hasRemaining()) {
            final Vector3 pWorld = drawMesh.localToWorld(new Vector3(vertexBuffer.get(), vertexBuffer.get(), vertexBuffer.get()), null);
            final Point p = new TPoint(pWorld.getX(), pWorld.getY(), pWorld.getZ());
            toXY.transform(p);
            if (p.getX() < minX) {
                minX = p.getX();
            }
            if (p.getX() > maxX) {
                maxX = p.getX();
            }
            if (p.getY() < minY) {
                minY = p.getY();
            }
            if (p.getY() > maxY) {
                maxY = p.getY();
            }
            if (Double.isNaN(z)) {
                z = p.getZ();
            }
            points.add(new Vector2(p.getX(), p.getY()));
        }
        final Point tmp = new TPoint(minX, minY, z);
        fromXY.transform(tmp);
        data.p0 = new Vector3(tmp.getX(), tmp.getY(), tmp.getZ());
        tmp.set(minX, maxY, z);
        fromXY.transform(tmp);
        data.p1 = new Vector3(tmp.getX(), tmp.getY(), tmp.getZ());
        tmp.set(maxX, minY, z);
        fromXY.transform(tmp);
        data.p2 = new Vector3(tmp.getX(), tmp.getY(), tmp.getZ());
        final double solarStep = Scene.getInstance().getSolarStep();
        data.rows = Math.max(1, (int) Math.ceil(data.p1.subtract(data.p0, null).length() / solarStep));
        data.cols = Math.max(1, (int) Math.ceil(data.p2.subtract(data.p0, null).length() / solarStep));
        data.dailySolarIntensity = new double[Util.roundToPowerOfTwo(data.rows)][Util.roundToPowerOfTwo(data.cols)];
        final ReadOnlyVector2 originXY = new Vector2(minX, minY);
        final ReadOnlyVector2 uXY = new Vector2(maxX - minX, 0).normalizeLocal();
        final ReadOnlyVector2 vXY = new Vector2(0, maxY - minY).normalizeLocal();
        final int nrow = data.dailySolarIntensity.length;
        final int ncol = data.dailySolarIntensity[0].length;
        for (int row = 0; row < nrow; row++) {
            for (int col = 0; col < ncol; col++) {
                if (row >= data.rows || col >= data.cols) {
                    // overshot cells
                    data.dailySolarIntensity[row][col] = -1;
                } else {
                    final ReadOnlyVector2 p = originXY.add(uXY.multiply(col * solarStep, null), null).add(vXY.multiply(row * solarStep, null), null);
                    boolean isInside = false;
                    final int numberOfPoints = points.size();
                    if (numberOfPoints >= 3) {
                        // FIXME: sometimes we can end up with less than three points
                        for (int i = 0; i < numberOfPoints; i += 3) {
                            if (i + 2 < points.size()) {
                                if (Util.isPointInsideTriangle(p, points.get(i), points.get(i + 1), points.get(i + 2))) {
                                    isInside = true;
                                    break;
                                }
                            }
                        }
                    }
                    if (!isInside && col > 0 && row > 0) {
                        // must at least include one column or row
                        data.dailySolarIntensity[row][col] = -1;
                    }
                }
            }
        }
        data.u = data.p2.subtract(data.p0, null).normalizeLocal();
        data.v = data.p1.subtract(data.p0, null).normalizeLocal();
        onMesh.put(drawMesh, data);
        if (updateTexture) {
            updateTextureCoords(drawMesh);
        }
    }
    return data;
}
Also used : AnyToXYTransform(org.poly2tri.transform.coordinate.AnyToXYTransform) ArrayList(java.util.ArrayList) FloatBuffer(java.nio.FloatBuffer) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) TPoint(org.poly2tri.triangulation.point.TPoint) Point(org.poly2tri.geometry.primitives.Point) TPoint(org.poly2tri.triangulation.point.TPoint) CullHint(com.ardor3d.scenegraph.hint.CullHint) TPoint(org.poly2tri.triangulation.point.TPoint) Point(org.poly2tri.geometry.primitives.Point) ReadOnlyVector2(com.ardor3d.math.type.ReadOnlyVector2) XYToAnyTransform(org.poly2tri.transform.coordinate.XYToAnyTransform) ReadOnlyVector2(com.ardor3d.math.type.ReadOnlyVector2) Vector2(com.ardor3d.math.Vector2)

Example 63 with ReadOnlyVector3

use of com.ardor3d.math.type.ReadOnlyVector3 in project energy3d by concord-consortium.

the class SolarRadiation method computeOnParabolicDish.

// Unlike PV solar panels, no indirect (ambient or diffuse) radiation should be included in reflection calculation. The mesh is a parabolic surface.
private void computeOnParabolicDish(final int minute, final ReadOnlyVector3 directionTowardSun, final ParabolicDish dish) {
    final int n = Scene.getInstance().getParabolicDishN();
    final Calendar calendar = Heliodon.getInstance().getCalendar();
    calendar.set(Calendar.HOUR_OF_DAY, (int) ((double) minute / (double) SolarRadiation.MINUTES_OF_DAY * 24.0));
    calendar.set(Calendar.MINUTE, minute % 60);
    dish.draw();
    final ReadOnlyVector3 normal = dish.getNormal();
    if (normal == null) {
        throw new RuntimeException("Normal is null");
    }
    // n*n*60: n*n is to get the unit cell area of the nxn grid; 60 is to convert the unit of timeStep from minute to kWh
    final double a = 4 * dish.getRimRadius() * dish.getRimRadius() * Scene.getInstance().getTimeStep() / (n * n * 60.0);
    final Mesh mesh = dish.getRadiationMesh();
    MeshDataStore data = onMesh.get(mesh);
    if (data == null) {
        data = initMeshTextureDataOnRectangle(mesh, n, n);
    }
    final double dot = normal.dot(directionTowardSun);
    double directRadiation = 0;
    if (dot > 0) {
        directRadiation += calculateDirectRadiation(directionTowardSun, normal);
    }
    final double radius = dish.getRimRadius() / Scene.getInstance().getAnnotationScale();
    final double depth = dish.getRimRadius() * dish.getRimRadius() / (4 * dish.getFocalLength() * Scene.getInstance().getAnnotationScale());
    // center of the rim circle
    final Vector3 center = new Vector3(0, 0, depth);
    final Vector3 q = center.clone();
    final double spacing = 2 * radius / n;
    // as the parabolic dish always faces the sun, we only have to deal with its aperture plane (rim circle)
    final int iMinute = minute / Scene.getInstance().getTimeStep();
    for (int x = 0; x < n; x++) {
        for (int y = 0; y < n; y++) {
            if (EnergyPanel.getInstance().isCancelled()) {
                throw new CancellationException();
            }
            q.setX(spacing * (x + 0.5 * (1 - n)));
            q.setY(spacing * (y + 0.5 * (1 - n)));
            final ReadOnlyVector3 p = mesh.localToWorld(q, null);
            final Ray3 pickRay = new Ray3(p, directionTowardSun);
            if (dot > 0) {
                final PickResults pickResults = new PrimitivePickResults();
                for (final Spatial spatial : collidables) {
                    if (spatial != mesh) {
                        PickingUtil.findPick(spatial, pickRay, pickResults, false);
                        if (pickResults.getNumber() != 0) {
                            break;
                        }
                    }
                }
                if (pickResults.getNumber() == 0) {
                    // for heat map generation (for now, just use a square image for texture)
                    data.dailySolarIntensity[y][x] += directRadiation;
                    if (q.distanceSquared(center) < radius * radius) {
                        // sum all the solar energy up over all meshes and store in the foundation's solar potential array
                        dish.getSolarPotential()[iMinute] += directRadiation * a;
                    }
                }
            }
        }
    }
}
Also used : Calendar(java.util.Calendar) Mesh(com.ardor3d.scenegraph.Mesh) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) CullHint(com.ardor3d.scenegraph.hint.CullHint) TPoint(org.poly2tri.triangulation.point.TPoint) Point(org.poly2tri.geometry.primitives.Point) Ray3(com.ardor3d.math.Ray3) PrimitivePickResults(com.ardor3d.intersection.PrimitivePickResults) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) CancellationException(java.util.concurrent.CancellationException) Spatial(com.ardor3d.scenegraph.Spatial) PrimitivePickResults(com.ardor3d.intersection.PrimitivePickResults) PickResults(com.ardor3d.intersection.PickResults)

Example 64 with ReadOnlyVector3

use of com.ardor3d.math.type.ReadOnlyVector3 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 65 with ReadOnlyVector3

use of com.ardor3d.math.type.ReadOnlyVector3 in project energy3d by concord-consortium.

the class SolarRadiation method computeOnParabolicTrough.

// Unlike PV solar panels, no indirect (ambient or diffuse) radiation should be included in reflection calculation. The mesh is a parabolic surface.
private void computeOnParabolicTrough(final int minute, final ReadOnlyVector3 directionTowardSun, final ParabolicTrough trough) {
    final int nAxis = trough.getNSectionAxis();
    final int nPara = trough.getNSectionParabola();
    final Calendar calendar = Heliodon.getInstance().getCalendar();
    calendar.set(Calendar.HOUR_OF_DAY, (int) ((double) minute / (double) SolarRadiation.MINUTES_OF_DAY * 24.0));
    calendar.set(Calendar.MINUTE, minute % 60);
    trough.draw();
    final ReadOnlyVector3 normal = trough.getNormal();
    if (normal == null) {
        throw new RuntimeException("Normal is null");
    }
    // nx*ny*60: nx*ny is to get the unit cell area of the nx*ny grid; 60 is to convert the unit of timeStep from minute to kWh
    final double a = trough.getApertureWidth() * trough.getTroughLength() * Scene.getInstance().getTimeStep() / (nAxis * nPara * 60.0);
    final Mesh mesh = trough.getRadiationMesh();
    MeshDataStore data = onMesh.get(mesh);
    if (data == null) {
        // axis is row and parabola is column
        data = initMeshTextureDataOnRectangle(mesh, nAxis, nPara);
    }
    final double dot = normal.dot(directionTowardSun);
    double directRadiation = 0;
    if (dot > 0) {
        directRadiation += calculateDirectRadiation(directionTowardSun, normal);
    }
    final FloatBuffer vertexBuffer = mesh.getMeshData().getVertexBuffer();
    // number of vertex coordinates on each end
    final int j = vertexBuffer.limit() / 2;
    // (0, 0)
    final Vector3 p0 = new Vector3(vertexBuffer.get(0), vertexBuffer.get(1), vertexBuffer.get(2));
    // (1, 0)
    final Vector3 p1 = new Vector3(vertexBuffer.get(j - 3), vertexBuffer.get(j - 2), vertexBuffer.get(j - 1));
    // (0, 1)
    final Vector3 p2 = new Vector3(vertexBuffer.get(j), vertexBuffer.get(j + 1), vertexBuffer.get(j + 2));
    // final Vector3 q0 = mesh.localToWorld(p0, null);
    // final Vector3 q1 = mesh.localToWorld(p1, null);
    // final Vector3 q2 = mesh.localToWorld(p2, null);
    // System.out.println("***" + q0.distance(q1) * Scene.getInstance().getAnnotationScale() + "," + q0.distance(q2) * Scene.getInstance().getAnnotationScale());
    // this is perpendicular to the direction of the cylinder axis (nPara)
    final Vector3 u = p1.subtract(p0, null).normalizeLocal();
    // this is parallel to the direction of the cylinder axis (nAxis)
    final Vector3 v = p2.subtract(p0, null).normalizeLocal();
    final double xSpacing = p1.distance(p0) / nPara;
    final double ySpacing = p2.distance(p0) / nAxis;
    // as the parabolic trough always faces the sun, we only have to deal with its aperture plane
    final int iMinute = minute / Scene.getInstance().getTimeStep();
    for (int x = 0; x < nPara; x++) {
        for (int y = 0; y < nAxis; y++) {
            if (EnergyPanel.getInstance().isCancelled()) {
                throw new CancellationException();
            }
            final Vector3 u2 = u.multiply(xSpacing * (x + 0.5), null);
            final Vector3 v2 = v.multiply(ySpacing * (y + 0.5), null);
            // on the aperture plane of the parabolic trough
            final Vector3 q = p0.add(v2, null).addLocal(u2);
            final ReadOnlyVector3 p = mesh.localToWorld(q, null);
            final Ray3 pickRay = new Ray3(p, directionTowardSun);
            if (dot > 0) {
                final PickResults pickResults = new PrimitivePickResults();
                for (final Spatial spatial : collidables) {
                    if (spatial != mesh) {
                        PickingUtil.findPick(spatial, pickRay, pickResults, false);
                        if (pickResults.getNumber() != 0) {
                            break;
                        }
                    }
                }
                if (pickResults.getNumber() == 0) {
                    // for heat map generation
                    data.dailySolarIntensity[y][x] += directRadiation;
                    // sum all the solar energy up over all meshes and store in the foundation's solar potential array
                    trough.getSolarPotential()[iMinute] += directRadiation * a;
                }
            }
        }
    }
}
Also used : Calendar(java.util.Calendar) Mesh(com.ardor3d.scenegraph.Mesh) FloatBuffer(java.nio.FloatBuffer) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) CullHint(com.ardor3d.scenegraph.hint.CullHint) TPoint(org.poly2tri.triangulation.point.TPoint) Point(org.poly2tri.geometry.primitives.Point) Ray3(com.ardor3d.math.Ray3) PrimitivePickResults(com.ardor3d.intersection.PrimitivePickResults) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) CancellationException(java.util.concurrent.CancellationException) Spatial(com.ardor3d.scenegraph.Spatial) PrimitivePickResults(com.ardor3d.intersection.PrimitivePickResults) PickResults(com.ardor3d.intersection.PickResults)

Aggregations

ReadOnlyVector3 (com.ardor3d.math.type.ReadOnlyVector3)125 Vector3 (com.ardor3d.math.Vector3)88 CullHint (com.ardor3d.scenegraph.hint.CullHint)60 FloatBuffer (java.nio.FloatBuffer)45 TPoint (org.poly2tri.triangulation.point.TPoint)44 Point (org.poly2tri.geometry.primitives.Point)34 PolygonPoint (org.poly2tri.geometry.polygon.PolygonPoint)32 Mesh (com.ardor3d.scenegraph.Mesh)25 Spatial (com.ardor3d.scenegraph.Spatial)25 ArrayList (java.util.ArrayList)23 Node (com.ardor3d.scenegraph.Node)18 PickingHint (com.ardor3d.scenegraph.hint.PickingHint)18 Ray3 (com.ardor3d.math.Ray3)16 PickResults (com.ardor3d.intersection.PickResults)15 PrimitivePickResults (com.ardor3d.intersection.PrimitivePickResults)15 ArdorVector3Point (org.poly2tri.triangulation.point.ardor3d.ArdorVector3Point)15 TriangulationPoint (org.poly2tri.triangulation.TriangulationPoint)13 Matrix3 (com.ardor3d.math.Matrix3)10 CancellationException (java.util.concurrent.CancellationException)10 Vector2 (com.ardor3d.math.Vector2)9