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();
}
}
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;
}
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;
}
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();
}
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);
}
Aggregations