Search in sources :

Example 6 with Camera

use of com.ardor3d.renderer.Camera in project energy3d by concord-consortium.

the class OrbitControl method computeNewFrontDistance.

public void computeNewFrontDistance() {
    final Camera currentCamera = SceneManager.getInstance().getCamera();
    if (currentCamera != null) {
        frontDistance = _center.subtractLocal(currentCamera.getLocation()).length();
        clearOrbitCenter();
    }
}
Also used : Camera(com.ardor3d.renderer.Camera)

Example 7 with Camera

use of com.ardor3d.renderer.Camera in project energy3d by concord-consortium.

the class Printout method getScreenShot.

private BufferedImage getScreenShot(final Renderer renderer, final ReadOnlyVector3 printCorner) {
    final Camera camera = Camera.getCurrentCamera();
    final int width = camera.getWidth(), height = camera.getHeight();
    final Vector3 cameraLocation = new Vector3(printCorner).addLocal(visibleSceneWidth / 2.0, Scene.getOriginalHouseRoot().getWorldBound().getCenter().getY() - 10, -visibleSceneHeight / 2.0);
    final double pageToX = printCorner.getX() + PrintController.getInstance().getPageWidth() + visibleSceneWidth / 2.0;
    final double pageToZ = printCorner.getZ() - PrintController.getInstance().getPageHeight() - visibleSceneHeight / 2.0;
    int currentX = 0;
    int currentY = 0;
    while (true) {
        camera.setLocation(cameraLocation);
        camera.lookAt(cameraLocation.add(0, 1, 0, null), Vector3.UNIT_Z);
        SceneManager.getInstance().getFrameHandler().updateFrame();
        SceneManager.getInstance().getFrameHandler().updateFrame();
        // Ask the renderer for the current scene to be stored in the buffer
        takeSnapShot(image, _scratch, renderer, width, height, currentX, currentY);
        currentX += width;
        if (currentX > targetSize.width) {
            currentX = 0;
            currentY += height;
        }
        if (cameraLocation.getX() + visibleSceneWidth < pageToX) {
            cameraLocation.addLocal(visibleSceneWidth, 0, 0);
        } else if (cameraLocation.getZ() - visibleSceneHeight > pageToZ) {
            cameraLocation.setX(printCorner.getX() + visibleSceneWidth / 2.0);
            cameraLocation.addLocal(0, 0, -visibleSceneHeight);
        } else {
            break;
        }
    }
    return image;
}
Also used : ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) Camera(com.ardor3d.renderer.Camera)

Example 8 with Camera

use of com.ardor3d.renderer.Camera in project energy3d by concord-consortium.

the class Printout method takeSnapShot.

public static BufferedImage takeSnapShot() {
    final Camera camera = Camera.getCurrentCamera();
    final int width = camera.getWidth() - camera.getWidth() % 4;
    final int height = camera.getHeight();
    final ByteBuffer _scratch = BufferUtils.createByteBuffer(width * height * ImageUtils.getPixelByteSize(getFormat(), PixelDataType.UnsignedByte));
    final BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
    takeSnapShot(image, _scratch, SceneManager.getInstance().getCanvas().getCanvasRenderer().getRenderer(), width, height, 0, 0);
    return image;
}
Also used : Camera(com.ardor3d.renderer.Camera) ByteBuffer(java.nio.ByteBuffer) BufferedImage(java.awt.image.BufferedImage)

Example 9 with Camera

use of com.ardor3d.renderer.Camera in project energy3d by concord-consortium.

the class Scene method loadCameraLocation.

public static void loadCameraLocation() {
    final Camera camera = SceneManager.getInstance().getCamera();
    if (instance.getCameraLocation() != null && instance.getCameraDirection() != null) {
        camera.setLocation(instance.getCameraLocation());
        camera.lookAt(instance.getCameraLocation().add(instance.getCameraDirection(), null), Vector3.UNIT_Z);
    }
    SceneManager.getInstance().getCameraNode().updateFromCamera();
    Scene.getInstance().updateEditShapes();
}
Also used : Camera(com.ardor3d.renderer.Camera)

Example 10 with Camera

use of com.ardor3d.renderer.Camera in project energy3d by concord-consortium.

the class SceneManager method update.

@Override
public void update(final ReadOnlyTimer timer) {
    final double tpf = timer.getTimePerFrame();
    passManager.updatePasses(tpf);
    taskManager.getQueue(GameTaskQueue.UPDATE).setExecuteMultiple(executeAllTask);
    taskManager.getQueue(GameTaskQueue.UPDATE).execute(canvas.getCanvasRenderer().getRenderer());
    if (operationFlag) {
        executeOperation();
    }
    if (mouseState != null) {
        mouseMoved();
    }
    if (Scene.isRedrawAll()) {
        Scene.getInstance().redrawAllNow();
    }
    if (rotAnim && viewMode == ViewMode.NORMAL && canvas.getCanvasRenderer() != null) {
        final Matrix3 rotate = new Matrix3();
        rotate.fromAngleNormalAxis(45 * tpf * MathUtils.DEG_TO_RAD, Vector3.UNIT_Z);
        final Camera camera = getCamera();
        camera.setLocation(rotate.applyPre(camera.getLocation(), null));
        camera.lookAt(0, 0, 1, Vector3.UNIT_Z);
        getCameraNode().updateFromCamera();
        Scene.getInstance().updateEditShapes();
    }
    final Heliodon heliodon = Heliodon.getInstance();
    if (heliodon != null) {
        if (sunAnim) {
            heliodon.setHourAngle(heliodon.getHourAngle() + tpf * 0.5, true, true, false);
            SceneManager.getInstance().changeSkyTexture();
            SceneManager.getInstance().setShading(heliodon.isNightTime());
            final boolean night = Heliodon.getInstance().isNightTime();
            for (final HousePart part : Scene.getInstance().getParts()) {
                if (part instanceof Mirror) {
                    final Mirror m = (Mirror) part;
                    if (night) {
                        // call this so that the light beams can be set invisible
                        m.drawSunBeam();
                    } else {
                        if (m.getReceiver() != null) {
                            m.draw();
                        }
                    }
                } else if (part instanceof ParabolicTrough) {
                    final ParabolicTrough t = (ParabolicTrough) part;
                    if (night) {
                        // call this so that the light beams can be set invisible
                        t.drawSunBeam();
                    } else {
                        t.draw();
                    }
                } else if (part instanceof ParabolicDish) {
                    final ParabolicDish d = (ParabolicDish) part;
                    if (night) {
                        // call this so that the light beams can be set invisible
                        d.drawSunBeam();
                    } else {
                        d.draw();
                    }
                } else if (part instanceof FresnelReflector) {
                    final FresnelReflector f = (FresnelReflector) part;
                    if (night) {
                        // call this so that the light beams can be set invisible
                        f.drawSunBeam();
                    } else {
                        f.draw();
                    }
                } else if (part instanceof SolarPanel) {
                    final SolarPanel sp = (SolarPanel) part;
                    if (!night && sp.getTracker() != Trackable.NO_TRACKER) {
                        sp.draw();
                    }
                    if (sp.isSunBeamVisible()) {
                        sp.drawSunBeam();
                    }
                } else if (part instanceof Rack) {
                    final Rack rack = (Rack) part;
                    if (!night && rack.getTracker() != Trackable.NO_TRACKER) {
                        rack.draw();
                    }
                    if (rack.isSunBeamVisible()) {
                        rack.drawSunBeam();
                    }
                }
            }
        }
        heliodon.update();
    }
    if (cameraControl != null && cameraControl.isAnimating()) {
        cameraControl.animate();
    }
    root.updateGeometricState(tpf);
}
Also used : ParabolicDish(org.concord.energy3d.model.ParabolicDish) Rack(org.concord.energy3d.model.Rack) ParabolicTrough(org.concord.energy3d.model.ParabolicTrough) FresnelReflector(org.concord.energy3d.model.FresnelReflector) SolarPanel(org.concord.energy3d.model.SolarPanel) Camera(com.ardor3d.renderer.Camera) Mirror(org.concord.energy3d.model.Mirror) PickedHousePart(org.concord.energy3d.model.PickedHousePart) HousePart(org.concord.energy3d.model.HousePart) Matrix3(com.ardor3d.math.Matrix3) Heliodon(org.concord.energy3d.shapes.Heliodon)

Aggregations

Camera (com.ardor3d.renderer.Camera)14 ReadOnlyVector3 (com.ardor3d.math.type.ReadOnlyVector3)6 Vector3 (com.ardor3d.math.Vector3)5 CullHint (com.ardor3d.scenegraph.hint.CullHint)2 Matrix3 (com.ardor3d.math.Matrix3)1 Spatial (com.ardor3d.scenegraph.Spatial)1 CameraNode (com.ardor3d.scenegraph.extension.CameraNode)1 Component (java.awt.Component)1 Dimension (java.awt.Dimension)1 BufferedImage (java.awt.image.BufferedImage)1 IOException (java.io.IOException)1 ByteBuffer (java.nio.ByteBuffer)1 FresnelReflector (org.concord.energy3d.model.FresnelReflector)1 HousePart (org.concord.energy3d.model.HousePart)1 Mirror (org.concord.energy3d.model.Mirror)1 ParabolicDish (org.concord.energy3d.model.ParabolicDish)1 ParabolicTrough (org.concord.energy3d.model.ParabolicTrough)1 PickedHousePart (org.concord.energy3d.model.PickedHousePart)1 Rack (org.concord.energy3d.model.Rack)1 SolarPanel (org.concord.energy3d.model.SolarPanel)1