Search in sources :

Example 6 with BloomRenderPass

use of com.ardor3d.extension.effect.bloom.BloomRenderPass in project energy3d by concord-consortium.

the class SolarPanel method drawSunBeam.

@Override
public void drawSunBeam() {
    if (Heliodon.getInstance().isNightTime() || !drawSunBeam) {
        sunBeam.setVisible(false);
        normalVector.setVisible(false);
        sunAngle.setVisible(false);
        return;
    }
    final Vector3 o = (!onFlatSurface() || container instanceof Rack) ? getAbsPoint(0) : getAbsPoint(0).addLocal(0, 0, baseHeight);
    final Vector3 sunLocation = Heliodon.getInstance().computeSunLocation(Heliodon.getInstance().getCalendar()).normalizeLocal();
    final FloatBuffer beamsVertices = sunBeam.getMeshData().getVertexBuffer();
    beamsVertices.rewind();
    // draw sun vector
    Vector3 r = o.clone();
    r.addLocal(sunLocation.multiply(5000, null));
    beamsVertices.put(o.getXf()).put(o.getYf()).put(o.getZf());
    beamsVertices.put(r.getXf()).put(r.getYf()).put(r.getZf());
    sunBeam.updateModelBound();
    sunBeam.setVisible(true);
    if (bloomRenderPass == null) {
        bloomRenderPass = new BloomRenderPass(SceneManager.getInstance().getCamera(), 10);
        bloomRenderPass.setBlurIntensityMultiplier(0.5f);
        bloomRenderPass.setNrBlurPasses(2);
        SceneManager.getInstance().getPassManager().add(bloomRenderPass);
    }
    if (!bloomRenderPass.contains(sunBeam)) {
        bloomRenderPass.add(sunBeam);
    }
    final FloatBuffer normalVertices = normalVector.getMeshData().getVertexBuffer();
    normalVertices.rewind();
    // draw normal vector
    r = o.clone();
    r.addLocal(normal.multiply(normalVectorLength, null));
    normalVertices.put(o.getXf()).put(o.getYf()).put(o.getZf());
    normalVertices.put(r.getXf()).put(r.getYf()).put(r.getZf());
    // draw arrows of the normal vector
    final double arrowLength = 0.75;
    final double arrowAngle = Math.toRadians(20);
    final Matrix3 matrix = new Matrix3();
    final FloatBuffer buf = mesh.getMeshData().getVertexBuffer();
    final ReadOnlyTransform trans = mesh.getWorldTransform();
    final Vector3 v1 = new Vector3();
    final Vector3 v2 = new Vector3();
    BufferUtils.populateFromBuffer(v1, buf, 1);
    BufferUtils.populateFromBuffer(v2, buf, 2);
    Vector3 a = trans.applyForward(v1).subtract(trans.applyForward(v2), null).normalizeLocal();
    a = a.crossLocal(normal);
    Vector3 s = normal.clone();
    s = matrix.fromAngleNormalAxis(arrowAngle, a).applyPost(s, null).multiplyLocal(arrowLength);
    s = r.subtract(s, null);
    normalVertices.put(r.getXf()).put(r.getYf()).put(r.getZf());
    normalVertices.put(s.getXf()).put(s.getYf()).put(s.getZf());
    s = normal.clone();
    s = matrix.fromAngleNormalAxis(-arrowAngle, a).applyPost(s, null).multiplyLocal(arrowLength);
    s = r.subtract(s, null);
    normalVertices.put(r.getXf()).put(r.getYf()).put(r.getZf());
    normalVertices.put(s.getXf()).put(s.getYf()).put(s.getZf());
    // draw the angle between the sun beam and the normal vector
    normal.cross(sunLocation, a);
    sunAngle.setRange(o, o.add(sunLocation, null), o.add(normal, null), a);
    sunAngle.setVisible(true);
    normalVector.updateModelBound();
    normalVector.setVisible(true);
}
Also used : ReadOnlyTransform(com.ardor3d.math.type.ReadOnlyTransform) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) FloatBuffer(java.nio.FloatBuffer) BloomRenderPass(com.ardor3d.extension.effect.bloom.BloomRenderPass) Matrix3(com.ardor3d.math.Matrix3)

Example 7 with BloomRenderPass

use of com.ardor3d.extension.effect.bloom.BloomRenderPass in project energy3d by concord-consortium.

the class Rack method drawSunBeam.

@Override
public void drawSunBeam() {
    if (Heliodon.getInstance().isNightTime() || !drawSunBeam) {
        sunBeam.setVisible(false);
        normalVector.setVisible(false);
        sunAngle.setVisible(false);
        return;
    }
    final Vector3 o = getAbsPoint(0);
    final Vector3 sunLocation = Heliodon.getInstance().computeSunLocation(Heliodon.getInstance().getCalendar()).normalizeLocal();
    final FloatBuffer beamsVertices = sunBeam.getMeshData().getVertexBuffer();
    beamsVertices.rewind();
    // draw sun vector
    Vector3 r = o.clone();
    r.addLocal(sunLocation.multiply(10000, null));
    beamsVertices.put(o.getXf()).put(o.getYf()).put(o.getZf());
    beamsVertices.put(r.getXf()).put(r.getYf()).put(r.getZf());
    sunBeam.updateModelBound();
    sunBeam.setVisible(true);
    if (bloomRenderPass == null) {
        bloomRenderPass = new BloomRenderPass(SceneManager.getInstance().getCamera(), 10);
        bloomRenderPass.setBlurIntensityMultiplier(0.5f);
        bloomRenderPass.setNrBlurPasses(2);
        SceneManager.getInstance().getPassManager().add(bloomRenderPass);
    }
    if (!bloomRenderPass.contains(sunBeam)) {
        bloomRenderPass.add(sunBeam);
    }
    final FloatBuffer normalVertices = normalVector.getMeshData().getVertexBuffer();
    normalVertices.rewind();
    // draw normal vector
    r = o.clone();
    r.addLocal(normal.multiply(normalVectorLength, null));
    normalVertices.put(o.getXf()).put(o.getYf()).put(o.getZf());
    normalVertices.put(r.getXf()).put(r.getYf()).put(r.getZf());
    // draw arrows of the normal vector
    final double arrowLength = 0.75;
    final double arrowAngle = Math.toRadians(20);
    final Matrix3 matrix = new Matrix3();
    final FloatBuffer buf = mesh.getMeshData().getVertexBuffer();
    final ReadOnlyTransform trans = mesh.getWorldTransform();
    final Vector3 v1 = new Vector3();
    final Vector3 v2 = new Vector3();
    BufferUtils.populateFromBuffer(v1, buf, 1);
    BufferUtils.populateFromBuffer(v2, buf, 2);
    Vector3 a = trans.applyForward(v1).subtract(trans.applyForward(v2), null).normalizeLocal();
    a = a.crossLocal(normal);
    Vector3 s = normal.clone();
    s = matrix.fromAngleNormalAxis(arrowAngle, a).applyPost(s, null).multiplyLocal(arrowLength);
    s = r.subtract(s, null);
    normalVertices.put(r.getXf()).put(r.getYf()).put(r.getZf());
    normalVertices.put(s.getXf()).put(s.getYf()).put(s.getZf());
    s = normal.clone();
    s = matrix.fromAngleNormalAxis(-arrowAngle, a).applyPost(s, null).multiplyLocal(arrowLength);
    s = r.subtract(s, null);
    normalVertices.put(r.getXf()).put(r.getYf()).put(r.getZf());
    normalVertices.put(s.getXf()).put(s.getYf()).put(s.getZf());
    // draw the angle between the sun beam and the normal vector
    normal.cross(sunLocation, a);
    sunAngle.setRange(o, o.add(sunLocation, null), o.add(normal, null), a);
    sunAngle.setVisible(true);
    normalVector.updateModelBound();
    normalVector.setVisible(true);
}
Also used : ReadOnlyTransform(com.ardor3d.math.type.ReadOnlyTransform) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) FloatBuffer(java.nio.FloatBuffer) BloomRenderPass(com.ardor3d.extension.effect.bloom.BloomRenderPass) Matrix3(com.ardor3d.math.Matrix3)

Example 8 with BloomRenderPass

use of com.ardor3d.extension.effect.bloom.BloomRenderPass in project energy3d by concord-consortium.

the class Mirror method drawSunBeam.

@Override
public void drawSunBeam() {
    if (Heliodon.getInstance().isNightTime() || heliostatTarget == null || !Scene.getInstance().areLightBeamsVisible()) {
        lightBeams.setVisible(false);
        return;
    }
    final Vector3 o = getAbsPoint(0);
    final double length = heliostatTarget.getSolarReceiverCenter().distance(o);
    final Vector3 sunLocation = Heliodon.getInstance().computeSunLocation(Heliodon.getInstance().getCalendar()).normalizeLocal();
    final FloatBuffer beamsVertices = lightBeams.getMeshData().getVertexBuffer();
    beamsVertices.rewind();
    if (drawSunBeam) {
        final Vector3 r = new Vector3(o);
        r.addLocal(sunLocation.multiply(5000, null));
        beamsVertices.put(o.getXf()).put(o.getYf()).put(o.getZf());
        beamsVertices.put(r.getXf()).put(r.getYf()).put(r.getZf());
    }
    final Vector3 s = sunLocation.multiplyLocal(length);
    final Vector3 p = new Matrix3().fromAngleNormalAxis(Math.PI, normal).applyPost(s, null);
    p.addLocal(o);
    beamsVertices.put(o.getXf()).put(o.getYf()).put(o.getZf());
    beamsVertices.put(p.getXf()).put(p.getYf()).put(p.getZf());
    lightBeams.updateModelBound();
    lightBeams.setVisible(true);
    if (bloomRenderPass == null) {
        bloomRenderPass = new BloomRenderPass(SceneManager.getInstance().getCamera(), 10);
        bloomRenderPass.setBlurIntensityMultiplier(0.5f);
        bloomRenderPass.setNrBlurPasses(2);
        SceneManager.getInstance().getPassManager().add(bloomRenderPass);
    }
    if (!bloomRenderPass.contains(lightBeams)) {
        bloomRenderPass.add(lightBeams);
    }
}
Also used : ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) FloatBuffer(java.nio.FloatBuffer) Matrix3(com.ardor3d.math.Matrix3) BloomRenderPass(com.ardor3d.extension.effect.bloom.BloomRenderPass)

Example 9 with BloomRenderPass

use of com.ardor3d.extension.effect.bloom.BloomRenderPass in project energy3d by concord-consortium.

the class ParabolicTrough method drawSunBeam.

@Override
public void drawSunBeam() {
    if (Heliodon.getInstance().isNightTime() || !beamsVisible) {
        lightBeams.setVisible(false);
        return;
    }
    final int nBeams = 10;
    FloatBuffer beamsBuffer = lightBeams.getMeshData().getVertexBuffer();
    final int beamsBufferSize = (nBeams + 1) * 12;
    if (beamsBuffer.capacity() < beamsBufferSize) {
        beamsBuffer = BufferUtils.createFloatBuffer(beamsBufferSize);
        lightBeams.getMeshData().setVertexBuffer(beamsBuffer);
    } else {
        beamsBuffer.rewind();
    }
    final Vector3 sunLocation = Heliodon.getInstance().computeSunLocation(Heliodon.getInstance().getCalendar()).normalizeLocal();
    double dx, dy, dz;
    final double ny = sunLocation.getY();
    sunLocation.multiplyLocal(10000);
    final double focus = 0.5 * reflector.getSemilatusRectum();
    final Vector3 focusPoint = mesh.getRotation().applyPost(new Vector3(0, 0, focus), null);
    for (int i = 0; i <= nBeams; i++) {
        dx = reflector.getWidth() * (0.5 - (double) i / nBeams);
        dz = 0.5 * dx * dx / reflector.getSemilatusRectum();
        final Vector3 d = mesh.getRotation().applyPost(new Vector3(dx, 0, dz), null);
        final Vector3 o = getAbsPoint(0).addLocal(d);
        // draw line to sun
        final Vector3 r = o.clone();
        r.addLocal(sunLocation);
        beamsBuffer.put(o.getXf()).put(o.getYf()).put(o.getZf());
        beamsBuffer.put(r.getXf()).put(r.getYf()).put(r.getZf());
        // draw line to focus
        dy = ny * (dz - focus);
        final Vector3 f = getAbsPoint(0).addLocal(focusPoint).addLocal(0, dy, 0);
        beamsBuffer.put(o.getXf()).put(o.getYf()).put(o.getZf());
        beamsBuffer.put(f.getXf()).put(f.getYf()).put(f.getZf());
    }
    lightBeams.updateModelBound();
    lightBeams.setVisible(true);
    if (bloomRenderPassLight == null) {
        bloomRenderPassLight = new BloomRenderPass(SceneManager.getInstance().getCamera(), 10);
        bloomRenderPassLight.setBlurIntensityMultiplier(0.5f);
        bloomRenderPassLight.setNrBlurPasses(2);
        SceneManager.getInstance().getPassManager().add(bloomRenderPassLight);
    }
    if (!bloomRenderPassLight.contains(lightBeams)) {
        bloomRenderPassLight.add(lightBeams);
    }
}
Also used : FloatBuffer(java.nio.FloatBuffer) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) CullHint(com.ardor3d.scenegraph.hint.CullHint) BloomRenderPass(com.ardor3d.extension.effect.bloom.BloomRenderPass)

Example 10 with BloomRenderPass

use of com.ardor3d.extension.effect.bloom.BloomRenderPass in project energy3d by concord-consortium.

the class FresnelReflector method drawSunBeam.

@Override
public void drawSunBeam() {
    if (Heliodon.getInstance().isNightTime() || absorber == null || !beamsVisible || !Scene.getInstance().areLightBeamsVisible()) {
        lightBeams.setVisible(false);
        return;
    }
    final double absoluteAzimuth = Math.toRadians(relativeAzimuth + getTopContainer().getAzimuth());
    final Vector3 o = getAbsPoint(0);
    final Vector3 c = absorber.getSolarReceiverCenter();
    final Vector3 sunDirection = Heliodon.getInstance().computeSunLocation(Heliodon.getInstance().getCalendar()).normalizeLocal();
    // by default, the rotation axis is in the north-south direction, so az = 0 maps to (0, 1, 0)
    final Vector3 rotationAxis = new Vector3(Math.sin(absoluteAzimuth), Math.cos(absoluteAzimuth), 0);
    final FloatBuffer beamsVertices = lightBeams.getMeshData().getVertexBuffer();
    beamsVertices.rewind();
    // from the sun to the reflector center
    final Vector3 r = o.clone();
    r.addLocal(sunDirection.multiply(5000, null));
    beamsVertices.put(o.getXf()).put(o.getYf()).put(o.getZf());
    beamsVertices.put(r.getXf()).put(r.getYf()).put(r.getZf());
    // from the reflector center to the receiver center
    final double shift = sunDirection.getZ() < MathUtils.ZERO_TOLERANCE ? 0 : (o.getZ() - c.getZ()) * (sunDirection.getY() * rotationAxis.getY() + sunDirection.getX() * rotationAxis.getX()) / sunDirection.getZ();
    c.setY(c.getY() + shift * rotationAxis.getY());
    c.setX(c.getX() + shift * rotationAxis.getX());
    beamsVertices.put(o.getXf()).put(o.getYf()).put(o.getZf());
    beamsVertices.put(c.getXf()).put(c.getYf()).put(c.getZf());
    lightBeams.updateModelBound();
    lightBeams.setVisible(true);
    if (bloomRenderPass == null) {
        bloomRenderPass = new BloomRenderPass(SceneManager.getInstance().getCamera(), 10);
        bloomRenderPass.setBlurIntensityMultiplier(0.5f);
        bloomRenderPass.setNrBlurPasses(2);
        SceneManager.getInstance().getPassManager().add(bloomRenderPass);
    }
    if (!bloomRenderPass.contains(lightBeams)) {
        bloomRenderPass.add(lightBeams);
    }
}
Also used : ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) FloatBuffer(java.nio.FloatBuffer) BloomRenderPass(com.ardor3d.extension.effect.bloom.BloomRenderPass)

Aggregations

BloomRenderPass (com.ardor3d.extension.effect.bloom.BloomRenderPass)10 Vector3 (com.ardor3d.math.Vector3)9 ReadOnlyVector3 (com.ardor3d.math.type.ReadOnlyVector3)9 FloatBuffer (java.nio.FloatBuffer)8 Matrix3 (com.ardor3d.math.Matrix3)6 CullHint (com.ardor3d.scenegraph.hint.CullHint)3 ReadOnlyTransform (com.ardor3d.math.type.ReadOnlyTransform)2