public void calculate() { double cx = control.getDouble("camera x"); double cy = control.getDouble("camera y"); double cz = control.getDouble("camera z"); double fx = control.getDouble("camera focus x"); double fy = control.getDouble("camera focus y"); double fz = control.getDouble("camera focus z"); double d = control.getDouble("screen distance"); double r = control.getDouble("rotation"); Camera camera = (Camera) panel.getCamera(); if (cx != camera.getX() || cy != camera.getY() || cz != camera.getZ()) { camera.setXYZ(cx, cy, cz); control.setValue("camera azimuth", camera.getAzimuth()); control.setValue("camera altitude", camera.getAltitude()); } else { double altitude = control.getDouble("camera altitude"); double azimuth = control.getDouble("camera azimuth"); camera.setAzimuthAndAltitude(azimuth, altitude); control.setValue("camera x", camera.getX()); control.setValue("camera y", camera.getY()); control.setValue("camera z", camera.getZ()); } camera.setFocusXYZ(fx, fy, fz); camera.setDistanceToScreen(d); camera.setRotation(r); panel.render(); }
public void updateValues() { Camera camera = (Camera) panel.getCamera(); control.setValue("camera x", camera.getX()); control.setValue("camera y", camera.getY()); control.setValue("camera z", camera.getZ()); control.setValue("camera focus x", camera.getFocusX()); control.setValue("camera focus y", camera.getFocusY()); control.setValue("camera focus z", camera.getFocusZ()); control.setValue("camera altitude", camera.getAltitude()); control.setValue("camera azimuth", camera.getAzimuth()); control.setValue("screen distance", camera.getDistanceToScreen()); control.setValue("rotation", camera.getRotation()); }
public CameraApp() { ball.setXYZ(0.0, 0.0, 0.0); ball.setSizeXYZ(0.5, 0.5, 0.5); ball.getStyle().setFillColor(Color.YELLOW); // right wall wallR.setXYZ(6.0, 0.0, 0.0); wallR.setSizeXYZ(0.2, 4.0, 4.0); wallR.getStyle().setFillColor(Color.GREEN); // left wall wallL.setXYZ(-6.0, 0.0, 0.0); wallL.setSizeXYZ(0.2, 4.0, 4.0); wallL.getStyle().setFillColor(Color.GREEN); // Add the objects panel.setPreferredMinMax(-6, 6, -6, 6, -6, 6); panel.getInteractionTarget(org.opensourcephysics.display3d.core.DrawingPanel3D.TARGET_PANEL); panel.addInteractionListener(this); panel.addElement(ball); panel.addElement(wallR); panel.addElement(wallL); DrawingFrame3D frame = new DrawingFrame3D(); frame.setDrawingPanel3D(panel); }
public void reset() { panel.getCamera().reset(); updateValues(); calculate(); }