Example #1
0
 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();
 }
 void displayPosition(int projectionMode, double[] point) {
   if (showCoordinates < 0) {
     return;
   }
   if (point == null) {
     panel.setMessage(null, showCoordinates);
     return;
   }
   String text = ""; // $NON-NLS-1$
   switch (projectionMode) {
     case org.opensourcephysics.display3d.core.Camera.MODE_PLANAR_XY:
       if (formatX != null) {
         text = theFormatX.format(point[0]);
       }
       if (formatY != null) {
         text += ", " + theFormatY.format(point[1]); // $NON-NLS-1$
       }
       break;
     case org.opensourcephysics.display3d.core.Camera.MODE_PLANAR_XZ:
       if (formatX != null) {
         text = theFormatX.format(point[0]);
       }
       if (formatZ != null) {
         text += ", " + theFormatZ.format(point[2]); // $NON-NLS-1$
       }
       break;
     case org.opensourcephysics.display3d.core.Camera.MODE_PLANAR_YZ:
       if (formatY != null) {
         text = theFormatY.format(point[1]);
       }
       if (formatZ != null) {
         text += ", " + theFormatZ.format(point[2]); // $NON-NLS-1$
       }
       break;
     default:
       if (formatX != null) {
         text = theFormatX.format(point[0]);
       }
       if (formatY != null) {
         text += ", " + theFormatY.format(point[1]); // $NON-NLS-1$
       }
       if (formatZ != null) {
         text += ", " + theFormatZ.format(point[2]); // $NON-NLS-1$
       }
       break;
   }
   if (text.startsWith(", ")) { // $NON-NLS-1$
     text = text.substring(2);
   }
   panel.setMessage(text, showCoordinates);
 }
Example #3
0
 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());
 }
Example #4
0
 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 setRemoveHiddenLines(boolean _value) {
   this.removeHiddenLines = _value;
   if (panel != null) {
     panel.hintChanged(HINT_REMOVE_HIDDEN_LINES);
   }
 }
 public final void setAxesLabels(String[] labels) {
   axesLabels = labels;
   if (panel != null) {
     panel.hintChanged(HINT_AXES_LABELS);
   }
 }
 public void setDecorationType(int _value) {
   this.decorationType = _value;
   if (panel != null) {
     panel.hintChanged(HINT_DECORATION_TYPE);
   }
 }
 public void setCursorType(int _type) {
   this.cursorType = _type;
   if (panel != null) {
     panel.hintChanged(HINT_CURSOR_TYPE);
   }
 }
 public void setShowCoordinates(int location) {
   showCoordinates = location;
   if (panel != null) {
     panel.hintChanged(HINT_SHOW_COORDINATES);
   }
 }
 public void setUseColorDepth(boolean _value) {
   this.useColorDepth = _value;
   if (panel != null) {
     panel.hintChanged(HINT_USE_COLOR_DEPTH);
   }
 }
 public void setAllowQuickRedraw(boolean _value) {
   this.allowQuickRedraw = _value;
   if (panel != null) {
     panel.hintChanged(HINT_ALLOW_QUICK_REDRAW);
   }
 }
Example #12
0
 public void reset() {
   panel.getCamera().reset();
   updateValues();
   calculate();
 }