All Downloads are FREE. Search and download functionalities are using the official Maven repository.

us.ihmc.simulationconstructionset.gui.ViewportPanel Maven / Gradle / Ivy

There is a newer version: 0.25.2
Show newest version
package us.ihmc.simulationconstructionset.gui;

import java.awt.Dimension;
import java.awt.GraphicsDevice;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.util.ArrayList;

import javax.swing.JFrame;
import javax.swing.JPanel;

import us.ihmc.euclid.tuple3D.interfaces.Tuple3DBasics;
import us.ihmc.jMonkeyEngineToolkit.Graphics3DAdapter;
import us.ihmc.jMonkeyEngineToolkit.camera.CameraConfiguration;
import us.ihmc.jMonkeyEngineToolkit.camera.CameraConfigurationList;
import us.ihmc.jMonkeyEngineToolkit.camera.CameraMountList;
import us.ihmc.jMonkeyEngineToolkit.camera.CaptureDevice;
import us.ihmc.jMonkeyEngineToolkit.camera.ClassicCameraController;
import us.ihmc.jMonkeyEngineToolkit.camera.TrackingDollyCameraController;
import us.ihmc.jMonkeyEngineToolkit.camera.ViewportAdapter;
import us.ihmc.simulationconstructionset.ViewportConfiguration;
import us.ihmc.simulationconstructionset.ViewportPanelConfiguration;
import us.ihmc.simulationconstructionset.commands.RunCommandsExecutor;
import us.ihmc.simulationconstructionset.gui.camera.CameraTrackAndDollyYoVariablesHolder;
import us.ihmc.simulationconstructionset.gui.config.CameraSelector;
import us.ihmc.simulationconstructionset.util.XMLReaderUtility;
import us.ihmc.yoVariables.registry.YoVariableHolder;
import us.ihmc.yoVariables.variable.YoDouble;

public class ViewportPanel extends JPanel implements CameraSelector, ActiveCameraHolder, ActiveCanvas3DHolder
{
   private static final long serialVersionUID = -2903057563160516887L;
   private static final boolean DEBUG_CLOSE_AND_DISPOSE = false;
   private ArrayList standard3DViews = new ArrayList<>();
   private ArrayList canvasPanels = new ArrayList<>();
   private ViewportAdapterAndCameraControllerHolder activeView;
   private CameraConfigurationList cameraConfigurationList;
   private CameraMountList cameraMountList;
   private YoVariableHolder yoVariableHolder;
   private RunCommandsExecutor runCommandsExecutor;
   private Graphics3DAdapter graphics3DAdapter;

   private StandardGUIActions standardGUIActions;

   public ViewportPanel(YoVariableHolder yoVariableHolder, RunCommandsExecutor runCommandsExecutor, StandardGUIActions standardGUIActions,
                        CameraConfigurationList cameraConfigurationList, CameraMountList cameraMountList, Graphics3DAdapter graphics3DAdapater)
   {
      this.yoVariableHolder = yoVariableHolder;
      this.runCommandsExecutor = runCommandsExecutor;
      this.standardGUIActions = standardGUIActions;
      this.cameraConfigurationList = cameraConfigurationList;
      this.cameraMountList = cameraMountList;
      graphics3DAdapter = graphics3DAdapater;

   }

   @Override
   public TrackingDollyCameraController getCameraPropertiesForActiveCamera()
   {
      return activeView.getCameraController();
   }

   public void setupViews(GraphicsDevice graphicsDevice, ViewportConfiguration viewportConfig)
   {
      setupViews(graphicsDevice, viewportConfig, null);
   }

   public void setupViews(GraphicsDevice graphicsDevice, ViewportConfiguration viewportConfig, JFrame jFrame)
   {
      removeAll();

      clearStandard3DViews();
      canvasPanels.clear();

      if (viewportConfig == null)
      {
         setLayout(new GridLayout(1, 1));

         CameraTrackAndDollyYoVariablesHolder cameraTrackAndDollyYoVariablesHolder = new CameraTrackAndDollyYoVariablesHolder(yoVariableHolder);

         ViewportAdapter standard3DView = graphics3DAdapter.createNewViewport(graphicsDevice, false, false);

         ClassicCameraController classicCameraController;
         if (jFrame != null)
            classicCameraController = ClassicCameraController.createClassicCameraControllerAndAddListeners(standard3DView,
                                                                                                           cameraTrackAndDollyYoVariablesHolder,
                                                                                                           graphics3DAdapter,
                                                                                                           jFrame);
         else
            classicCameraController = ClassicCameraController.createClassicCameraControllerAndAddListeners(standard3DView,
                                                                                                           cameraTrackAndDollyYoVariablesHolder,
                                                                                                           graphics3DAdapter);

         ViewportAdapterAndCameraControllerHolder viewportAdapterAndCameraControllerHolder = new ViewportAdapterAndCameraControllerHolder(standard3DView,
                                                                                                                                          classicCameraController);
         standard3DView.setCameraController(classicCameraController);

         standard3DViews.add(viewportAdapterAndCameraControllerHolder);
         activeView = viewportAdapterAndCameraControllerHolder;

         Canvas3DPanel panel_j = new Canvas3DPanel(runCommandsExecutor, viewportAdapterAndCameraControllerHolder, this);

         this.add(panel_j);

         return;
      }

      ArrayList panelConfigs = viewportConfig.getPanelConfigurations();

      GridBagLayout gridBag = new GridBagLayout();
      setLayout(gridBag);

      GridBagConstraints c;

      for (int i = 0; i < panelConfigs.size(); i++)
      {
         c = new GridBagConstraints();
         ViewportPanelConfiguration panelConfiguration = panelConfigs.get(i);

         CameraTrackAndDollyYoVariablesHolder cameraTrackAndDollyYoVariablesHolder = new CameraTrackAndDollyYoVariablesHolder(yoVariableHolder);

         ViewportAdapter standard3DView = graphics3DAdapter.createNewViewport(graphicsDevice, false, false);
         ClassicCameraController classicCameraController = ClassicCameraController.createClassicCameraControllerAndAddListeners(standard3DView,
                                                                                                                                cameraTrackAndDollyYoVariablesHolder,
                                                                                                                                graphics3DAdapter);
         ViewportAdapterAndCameraControllerHolder viewportAdapterAndCameraControllerHolder = new ViewportAdapterAndCameraControllerHolder(standard3DView,
                                                                                                                                          classicCameraController);
         standard3DView.setCameraController(classicCameraController);

         standard3DViews.add(viewportAdapterAndCameraControllerHolder);

         CameraConfiguration cameraConfig = cameraConfigurationList.getCameraConfiguration(panelConfiguration.cameraName);

         if (cameraConfig != null)
         {
            setCameraConfiguration(viewportAdapterAndCameraControllerHolder.getCameraController(), cameraConfig, yoVariableHolder, cameraMountList);
         }
         else
         {
            System.err.println("Warning. No camera named " + panelConfiguration.cameraName);

            continue;
         }

         Canvas3DPanel panel_j = new Canvas3DPanel(runCommandsExecutor, viewportAdapterAndCameraControllerHolder, this);
         canvasPanels.add(panel_j);

         c.gridx = panelConfiguration.gridx;
         c.gridy = panelConfiguration.gridy;
         c.gridwidth = panelConfiguration.gridwidth;
         c.gridheight = panelConfiguration.gridheight;
         c.weightx = panelConfiguration.gridwidth;
         c.weighty = panelConfiguration.gridheight;
         // c.weightx = 0.5;
         // c.weighty = 0.5;
         // c.anchor = GridBagConstraints.CENTER;
         c.fill = GridBagConstraints.BOTH;

         gridBag.setConstraints(panel_j, c);

         this.add(panel_j);

         if (i == 0)
         {
            activeView = viewportAdapterAndCameraControllerHolder;
            panel_j.setActive(true);
         }
         else
         {
            panel_j.setActive(false);
         }
      }
   }

   /*
    * public JPanel setupViewsCaching(GraphicsDevice graphicsDevice, ViewportConfiguration
    * viewportConfig, Locale locale, PreRenderer preRenderer, ViewportPanelUpdateBehavior
    * viewportPanelUpdateBehavior) { JPanel panel = null; if (viewportConfig != null) panel =
    * viewportConfig.getCachedViewportPanel(); if (panel != null)return panel; if (panel == null) panel
    * = new JPanel(); // Remove all from the locale: for (Standard3DView standard3DView :
    * standard3DViews) //++++++ { //standard3DView.detachAll(); //standard3DView.detach();
    * //++++++locale.removeBranchGraph(standard3DView); } panel.removeAll(); //standard3DViews.clear();
    * clearStandard3DViews(); canvasPanels.clear(); //standard3DViews = new ArrayList(); //canvasPanels
    * = new ArrayList(); // "Force" Garbage Collection: System.gc(); if (viewportConfig == null) {
    * panel.setLayout(new GridLayout(1, 1)); Standard3DView standard3DView = new
    * Standard3DView(graphicsDevice, navigatingCameraHolder, rob, locale, preRenderer);
    * standard3DViews.add(standard3DView); activeView = standard3DView;
    * navigatingCameraHolder.setNavigatingCamera(activeView.getCamera());
    * locale.addBranchGraph(standard3DView); YoCanvas3D canvas = standard3DView.getCanvas3D();
    * //panel.add(canvas); Canvas3DPanel panel_j = new Canvas3DPanel(canvas, standard3DView, this);
    * panel.add(panel_j); viewportPanelUpdateBehavior.attachViewportPanel(this); return panel; }
    * //ArrayList cachedViews = viewportConfig.getCached3DViews(); // if (cachedViews != null) // { //
    * for(int i=0; i getCameraAdapters()
   {
      return standard3DViews;
   }

   public void closeAndDispose()
   {
      if (DEBUG_CLOSE_AND_DISPOSE)
         System.out.println("Closing and Disposing things in " + getClass().getSimpleName());

      if (standard3DViews != null)
      {
         clearStandard3DViews();
         standard3DViews = null;
      }

      if (canvasPanels != null)
      {
         for (Canvas3DPanel canvas3dPanel : canvasPanels)
         {
            canvas3dPanel.closeAndDispose();
         }

         canvasPanels.clear();
         canvasPanels = null;
      }

      activeView = null;

      cameraConfigurationList = null;
      cameraMountList = null;
      yoVariableHolder = null;
      standardGUIActions = null;
      runCommandsExecutor = null;
      graphics3DAdapter = null;
   }

   // public YoCanvas3D getCanvas3D(){return activeView.getCanvas3D();}
   // public YoCanvas3D getOffscreenCanvas3D(){return this.offscreenCanvas3D;}
   @Override
   public TrackingDollyCameraController getCamera()
   {
      return activeView.getCameraController();
   }

   public TrackingDollyCameraController[] getCameras()
   {
      TrackingDollyCameraController[] cameras = new TrackingDollyCameraController[standard3DViews.size()];
      for (int i = 0; i < standard3DViews.size(); i++)
      {
         cameras[i] = standard3DViews.get(i).getCameraController();
      }

      return cameras;
   }

   public void setClipDistances(double near, double far)
   {
      activeView.getCameraController().setClipDistanceNear(near);
      activeView.getCameraController().setClipDistanceFar(far);
   }

   public void setFieldOfView(double fieldOfView)
   {
      activeView.getCameraController().setFieldOfView(fieldOfView);
   }

   public void setCameraTrackingVars(YoDouble xVar, YoDouble yVar, YoDouble zVar)
   {
      CameraTrackAndDollyYoVariablesHolder cameraTrackAndDollyVariablesHolder = (CameraTrackAndDollyYoVariablesHolder) activeView.getCameraController()
                                                                                                                                 .getCameraTrackAndDollyVariablesHolder();
      cameraTrackAndDollyVariablesHolder.setTrackingVars(xVar, yVar, zVar);

      //    activeView.getCamera().setTrackingVars(xVar, yVar, zVar);
   }

   public void setCameraDollyVars(YoDouble xVar, YoDouble yVar, YoDouble zVar)
   {
      CameraTrackAndDollyYoVariablesHolder cameraTrackAndDollyVariablesHolder = (CameraTrackAndDollyYoVariablesHolder) activeView.getCameraController()
                                                                                                                                 .getCameraTrackAndDollyVariablesHolder();
      cameraTrackAndDollyVariablesHolder.setDollyVars(xVar, yVar, zVar);

      //    activeView.getCamera().setDollyVars(xVar, yVar, zVar);
   }

   public void setCameraTrackingOffsets(double dx, double dy, double dz)
   {
      activeView.getCameraController().setTrackingOffsets(dx, dy, dz);
   }

   public void setCameraDollyOffsets(double dx, double dy, double dz)
   {
      activeView.getCameraController().setDollyOffsets(dx, dy, dz);
   }

   public void setCameraFix(double fixX, double fixY, double fixZ)
   {
      activeView.getCameraController().setFixPosition(fixX, fixY, fixZ);
   }

   public void setCameraFix(Tuple3DBasics cameraFix)
   {
      activeView.getCameraController().setFixPosition(cameraFix.getX(), cameraFix.getY(), cameraFix.getZ());
   }

   public void setCameraPosition(double posX, double posY, double posZ)
   {
      activeView.getCameraController().setCameraPosition(posX, posY, posZ);
   }

   public void setCameraPosition(Tuple3DBasics cameraPosition)
   {
      activeView.getCameraController().setCameraPosition(cameraPosition.getX(), cameraPosition.getY(), cameraPosition.getZ());
   }

   public void setCameraTracking(boolean track, boolean trackX, boolean trackY, boolean trackZ)
   {
      activeView.getCameraController().setTracking(track, trackX, trackY, trackZ);
   }

   public void setCameraDolly(boolean dolly, boolean dollyX, boolean dollyY, boolean dollyZ)
   {
      activeView.getCameraController().setDolly(dolly, dollyX, dollyY, dollyZ);
   }

   public void setCameraConfiguration(CameraConfiguration config, YoVariableHolder holder)
   {
      setCameraConfiguration(activeView.getCameraController(), config, holder, cameraMountList);
   }

   // public void updateGroundDisplay()
   // {
   //    standardGUIActions.updateGroundDisplay();
   // }

   public synchronized void clearStandard3DViews()
   {
      for (ViewportAdapterAndCameraControllerHolder viewportAdapterAndCameraControllerHolder : standard3DViews)
      {
         graphics3DAdapter.closeViewport(viewportAdapterAndCameraControllerHolder.getViewportAdapter());
         viewportAdapterAndCameraControllerHolder.closeAndDispose();
      }

      standard3DViews.clear();
   }

   @Override
   public CaptureDevice getActiveCaptureDevice()
   {
      return getActiveView().getCaptureDevice();
   }

   public void selectActiveCanvas3D(int canvasIndex)
   {
      if (canvasIndex >= canvasPanels.size())
      {
         return;
      }

      Canvas3DPanel canvasPanel = canvasPanels.get(canvasIndex);

      setActiveView(canvasPanel.getStandard3DView(), canvasPanel);
   }

   @Override
   public void selectCamera(String name)
   {
      CameraConfiguration config = cameraConfigurationList.getCameraConfiguration(name);

      if (config == null)
      {
         return;
      }

      setCameraConfiguration(config, yoVariableHolder); // , cameraMountList);

      //    makeCheckBoxesConsistentWithCamera();
   }

   public String getXMLStyleRepresentationofMultiViews(String currentView)
   {
      String textToWrite = "";
      textToWrite += "" + currentView + "";

      for (int i = 0; i < canvasPanels.size(); i++)
      {
         int label = i + 1;
         textToWrite += "\n";
         textToWrite += "\n" + canvasPanels.get(i).getStandard3DView().getCameraController().getCamX() + "";
         textToWrite += "\n" + canvasPanels.get(i).getStandard3DView().getCameraController().getCamY() + "";
         textToWrite += "\n" + canvasPanels.get(i).getStandard3DView().getCameraController().getCamZ() + "";
         textToWrite += "\n  \n " + canvasPanels.get(i).getStandard3DView().getCameraController().getDollyXOffset() + ""
               + "\n " + canvasPanels.get(i).getStandard3DView().getCameraController().getDollyYOffset() + "" + "\n "
               + canvasPanels.get(i).getStandard3DView().getCameraController().getDollyZOffset() + "";
         textToWrite += "\n" + "\n" + canvasPanels.get(i).getStandard3DView().getCameraController().isDolly() + ""
               + "\n" + canvasPanels.get(i).getStandard3DView().getCameraController().isDollyX() + "" + "\n"
               + canvasPanels.get(i).getStandard3DView().getCameraController().isDollyY() + "" + "\n"
               + canvasPanels.get(i).getStandard3DView().getCameraController().isDollyY() + "" + "\n";
         textToWrite += "\n";
         textToWrite += "\n  \n " + canvasPanels.get(i).getStandard3DView().getCameraController().getTrackingXOffset() + ""
               + "\n " + canvasPanels.get(i).getStandard3DView().getCameraController().getTrackingYOffset() + "" + "\n "
               + canvasPanels.get(i).getStandard3DView().getCameraController().getTrackingZOffset() + "";
         textToWrite += "\n " + "\n" + canvasPanels.get(i).getStandard3DView().getCameraController().isTracking() + ""
               + "\n" + canvasPanels.get(i).getStandard3DView().getCameraController().isTrackingX() + "" + "\n"
               + canvasPanels.get(i).getStandard3DView().getCameraController().isTrackingY() + "" + "\n"
               + canvasPanels.get(i).getStandard3DView().getCameraController().isTracking() + "" + "\n";
         textToWrite += "\n";
         textToWrite += "\n" + "\n" + canvasPanels.get(i).getStandard3DView().getCameraController().getFixX() + "" + "\n"
               + canvasPanels.get(i).getStandard3DView().getCameraController().getFixY() + "" + "\n"
               + canvasPanels.get(i).getStandard3DView().getCameraController().getFixZ() + "" + "\n";
         textToWrite += "\n";
      }

      if (canvasPanels.size() == 0)
      {
         textToWrite += "\n  " + "\n " + getCamera().getCamX() + "" + "\n " + getCamera().getCamY() + ""
               + "\n " + getCamera().getCamZ() + "";
         textToWrite += "\n  \n " + getCameraPropertiesForActiveCamera().getDollyXOffset() + "" + "\n "
               + getCameraPropertiesForActiveCamera().getDollyYOffset() + "" + "\n "
               + getCameraPropertiesForActiveCamera().getDollyZOffset() + "";
         textToWrite += "\n" + "\n" + getCameraPropertiesForActiveCamera().isDolly() + "" + "\n"
               + getCameraPropertiesForActiveCamera().isDollyX() + "" + "\n" + getCameraPropertiesForActiveCamera().isDollyY() + ""
               + "\n" + getCameraPropertiesForActiveCamera().isDollyY() + "" + "\n";
         textToWrite += "\n";
         textToWrite += "\n  \n " + getCameraPropertiesForActiveCamera().getTrackingXOffset() + "" + "\n "
               + getCameraPropertiesForActiveCamera().getTrackingYOffset() + "" + "\n "
               + getCameraPropertiesForActiveCamera().getTrackingZOffset() + "";
         textToWrite += "\n " + "\n" + getCameraPropertiesForActiveCamera().isTracking() + "" + "\n"
               + getCameraPropertiesForActiveCamera().isTrackingX() + "" + "\n" + getCameraPropertiesForActiveCamera().isTrackingY()
               + "" + "\n" + getCameraPropertiesForActiveCamera().isTracking() + "" + "\n";
         textToWrite += "\n";
         textToWrite += "\n" + "\n" + getCameraPropertiesForActiveCamera().getFixX() + "" + "\n"
               + getCameraPropertiesForActiveCamera().getFixY() + "" + "\n" + getCameraPropertiesForActiveCamera().getFixZ() + ""
               + "\n";
         textToWrite += "\n";
      }

      return textToWrite;
   }

   public String getXMLStyleRepresentationOfMainViewPort(boolean visible_ViewPort)
   {
      String textToWrite = "";

      textToWrite += "\n 
" + "\n " + visible_ViewPort + ""; textToWrite += "\n
"; return textToWrite; } public String getXMLStyleRepresentationOfClassViewPorts(ViewportAdapterAndCameraControllerHolder view3d, int canvasNumber) { String textToWrite = ""; textToWrite += "\n"; textToWrite += "\n" + view3d.getCameraController().getCamX() + ""; textToWrite += "\n" + view3d.getCameraController().getCamY() + ""; textToWrite += "\n" + view3d.getCameraController().getCamZ() + ""; textToWrite += "\n \n " + view3d.getCameraController().getDollyXOffset() + "" + "\n " + view3d.getCameraController().getDollyYOffset() + "" + "\n " + view3d.getCameraController().getDollyZOffset() + ""; textToWrite += "\n" + "\n" + view3d.getCameraController().isDolly() + "" + "\n" + view3d.getCameraController().isDollyX() + "" + "\n" + view3d.getCameraController().isDollyY() + "" + "\n" + view3d.getCameraController().isDollyY() + "" + "\n"; textToWrite += "\n"; textToWrite += "\n \n " + view3d.getCameraController().getTrackingXOffset() + "" + "\n " + view3d.getCameraController().getTrackingYOffset() + "" + "\n " + view3d.getCameraController().getTrackingZOffset() + ""; textToWrite += "\n " + "\n" + view3d.getCameraController().isTracking() + "" + "\n" + view3d.getCameraController().isTrackingX() + "" + "\n" + view3d.getCameraController().isTrackingY() + "" + "\n" + view3d.getCameraController().isTracking() + "" + "\n"; textToWrite += "\n"; textToWrite += "\n" + "\n" + view3d.getCameraController().getFixX() + "" + "\n" + view3d.getCameraController().getFixY() + "" + "\n" + view3d.getCameraController().getFixZ() + "" + "\n"; textToWrite += "\n"; return textToWrite; } public boolean setMainViewPortFromXMLDescription(String importXML) { String textToLoad = XMLReaderUtility.getMiddleString(0, importXML, "
", "
"); String visible = XMLReaderUtility.getMiddleString(0, textToLoad, "", ""); return visible.trim().equalsIgnoreCase("true"); } @Override public Dimension getMinimumSize() { return new Dimension(0, 0); } private int sizeForSetUpOfMultiViews(String currentView) { int size = 1; if (currentView.equals("Split Screen")) { size = 2; } if (currentView.equals("Three Views")) { size = 3; } if (currentView.equals("Four Views")) { size = 4; } return size; } public void setupMultiViews(String xmlRepresentation, String currentView) { for (int i = 0; i < sizeForSetUpOfMultiViews(currentView); i++) { int label = i + 1; String first = ""; String second = ""; String textToLoad = XMLReaderUtility.getMiddleString(0, xmlRepresentation, first, second); double posX = Double.parseDouble(XMLReaderUtility.getMiddleString(0, textToLoad, "", "")); double posY = Double.parseDouble(XMLReaderUtility.getMiddleString(0, textToLoad, "", "")); double posZ = Double.parseDouble(XMLReaderUtility.getMiddleString(0, textToLoad, "", "")); canvasPanels.get(i).getStandard3DView().getCameraController().setCameraPosition(posX, posY, posZ); String Dolly = XMLReaderUtility.getMiddleString(0, textToLoad, "", ""); double DollyX = Double.parseDouble(XMLReaderUtility.getMiddleString(0, Dolly, "", "")); double DollyY = Double.parseDouble(XMLReaderUtility.getMiddleString(0, Dolly, "", "")); double DollyZ = Double.parseDouble(XMLReaderUtility.getMiddleString(0, Dolly, "", "")); canvasPanels.get(i).getStandard3DView().getCameraController().setDollyOffsets(DollyX, DollyY, DollyZ); String Dolly_Boolean = XMLReaderUtility.getMiddleString(0, Dolly, "", ""); String Dolly_Boolean_X = XMLReaderUtility.getMiddleString(0, Dolly, "", ""); String Dolly_Boolean_Y = XMLReaderUtility.getMiddleString(0, Dolly, "", ""); String Dolly_Boolean_Z = XMLReaderUtility.getMiddleString(0, Dolly, "", ""); boolean dolly_set = true; boolean dolly_setX = true; boolean dolly_setY = true; boolean dolly_setZ = true; if (Dolly_Boolean.equals("false")) { dolly_set = false; } if (Dolly_Boolean_X.equals("false")) { dolly_setX = false; } if (Dolly_Boolean_Y.equals("false")) { dolly_setY = false; } if (Dolly_Boolean_Z.equals("false")) { dolly_setZ = false; } canvasPanels.get(i).getStandard3DView().getCameraController().setDolly(dolly_set, dolly_setX, dolly_setY, dolly_setZ); String Track = XMLReaderUtility.getMiddleString(0, textToLoad, "", ""); double TrackX = Double.parseDouble(XMLReaderUtility.getMiddleString(0, Track, "", "")); double TrackY = Double.parseDouble(XMLReaderUtility.getMiddleString(0, Track, "", "")); double TrackZ = Double.parseDouble(XMLReaderUtility.getMiddleString(0, Track, "", "")); canvasPanels.get(i).getStandard3DView().getCameraController().setTrackingOffsets(TrackX, TrackY, TrackZ); String Track_Boolean = XMLReaderUtility.getMiddleString(0, Track, "", ""); String Track_Boolean_X = XMLReaderUtility.getMiddleString(0, Track, "", ""); String Track_Boolean_Y = XMLReaderUtility.getMiddleString(0, Track, "", ""); String Track_Boolean_Z = XMLReaderUtility.getMiddleString(0, Track, "", ""); boolean track_set = true; boolean track_setX = true; boolean track_setY = true; boolean track_setZ = true; if (Track_Boolean.equals("false")) { track_set = false; } if (Track_Boolean_X.equals("false")) { track_setX = false; } if (Track_Boolean_Y.equals("false")) { track_setY = false; } if (Track_Boolean_Z.equals("false")) { track_setZ = false; } canvasPanels.get(i).getStandard3DView().getCameraController().setTracking(track_set, track_setX, track_setY, track_setZ); String Fix = XMLReaderUtility.getMiddleString(0, textToLoad, "", ""); double FixX = Double.parseDouble(XMLReaderUtility.getMiddleString(0, Fix, "", "")); double FixY = Double.parseDouble(XMLReaderUtility.getMiddleString(0, Fix, "", "")); double FixZ = Double.parseDouble(XMLReaderUtility.getMiddleString(0, Fix, "", "")); canvasPanels.get(i).getStandard3DView().getCameraController().setFixPosition(FixX, FixY, FixZ); } } public void setupMultiViews_ViewportWindows(String xmlRepresentation, String currentView) { for (int i = 0; i < sizeForSetUpOfMultiViews(currentView); i++) { int label = i + 1; String first = ""; String second = ""; String textToLoad = XMLReaderUtility.getMiddleString(0, xmlRepresentation, first, second); double posX = Double.parseDouble(XMLReaderUtility.getMiddleString(0, textToLoad, "", "")); double posY = Double.parseDouble(XMLReaderUtility.getMiddleString(0, textToLoad, "", "")); double posZ = Double.parseDouble(XMLReaderUtility.getMiddleString(0, textToLoad, "", "")); canvasPanels.get(i).getStandard3DView().getCameraController().setCameraPosition(posX, posY, posZ); String Dolly = XMLReaderUtility.getMiddleString(0, textToLoad, "", ""); double DollyX = Double.parseDouble(XMLReaderUtility.getMiddleString(0, Dolly, "", "")); double DollyY = Double.parseDouble(XMLReaderUtility.getMiddleString(0, Dolly, "", "")); double DollyZ = Double.parseDouble(XMLReaderUtility.getMiddleString(0, Dolly, "", "")); canvasPanels.get(i).getStandard3DView().getCameraController().setDollyOffsets(DollyX, DollyY, DollyZ); String Dolly_Boolean = XMLReaderUtility.getMiddleString(0, Dolly, "", ""); String Dolly_Boolean_X = XMLReaderUtility.getMiddleString(0, Dolly, "", ""); String Dolly_Boolean_Y = XMLReaderUtility.getMiddleString(0, Dolly, "", ""); String Dolly_Boolean_Z = XMLReaderUtility.getMiddleString(0, Dolly, "", ""); boolean dolly_set = true; boolean dolly_setX = true; boolean dolly_setY = true; boolean dolly_setZ = true; if (Dolly_Boolean.equals("false")) { dolly_set = false; } if (Dolly_Boolean_X.equals("false")) { dolly_setX = false; } if (Dolly_Boolean_Y.equals("false")) { dolly_setY = false; } if (Dolly_Boolean_Z.equals("false")) { dolly_setZ = false; } canvasPanels.get(i).getStandard3DView().getCameraController().setDolly(dolly_set, dolly_setX, dolly_setY, dolly_setZ); String Track = XMLReaderUtility.getMiddleString(0, textToLoad, "", ""); double TrackX = Double.parseDouble(XMLReaderUtility.getMiddleString(0, Track, "", "")); double TrackY = Double.parseDouble(XMLReaderUtility.getMiddleString(0, Track, "", "")); double TrackZ = Double.parseDouble(XMLReaderUtility.getMiddleString(0, Track, "", "")); canvasPanels.get(i).getStandard3DView().getCameraController().setTrackingOffsets(TrackX, TrackY, TrackZ); String Track_Boolean = XMLReaderUtility.getMiddleString(0, Track, "", ""); String Track_Boolean_X = XMLReaderUtility.getMiddleString(0, Track, "", ""); String Track_Boolean_Y = XMLReaderUtility.getMiddleString(0, Track, "", ""); String Track_Boolean_Z = XMLReaderUtility.getMiddleString(0, Track, "", ""); boolean track_set = true; boolean track_setX = true; boolean track_setY = true; boolean track_setZ = true; if (Track_Boolean.equals("false")) { track_set = false; } if (Track_Boolean_X.equals("false")) { track_setX = false; } if (Track_Boolean_Y.equals("false")) { track_setY = false; } if (Track_Boolean_Z.equals("false")) { track_setZ = false; } canvasPanels.get(i).getStandard3DView().getCameraController().setTracking(track_set, track_setX, track_setY, track_setZ); String Fix = XMLReaderUtility.getMiddleString(0, textToLoad, "", ""); double FixX = Double.parseDouble(XMLReaderUtility.getMiddleString(0, Fix, "", "")); double FixY = Double.parseDouble(XMLReaderUtility.getMiddleString(0, Fix, "", "")); double FixZ = Double.parseDouble(XMLReaderUtility.getMiddleString(0, Fix, "", "")); canvasPanels.get(i).getStandard3DView().getCameraController().setFixPosition(FixX, FixY, FixZ); } } public void setCameraTracking(boolean cameraTracking) { // TODO: make viewports based on interface } private void setCameraConfiguration(TrackingDollyCameraController camera, CameraConfiguration config, YoVariableHolder holder, CameraMountList mountList) { camera.setConfiguration(config, mountList); CameraTrackAndDollyYoVariablesHolder cameraTrackAndDollyYoVariablesHolder = (CameraTrackAndDollyYoVariablesHolder) camera.getCameraTrackAndDollyVariablesHolder(); YoDouble trackXVar = (YoDouble) holder.findVariable(config.getTrackXVar()); YoDouble trackYVar = (YoDouble) holder.findVariable(config.getTrackYVar()); YoDouble trackZVar = (YoDouble) holder.findVariable(config.getTrackZVar()); cameraTrackAndDollyYoVariablesHolder.setTrackingVars(trackXVar, trackYVar, trackZVar); YoDouble dollyXVar = (YoDouble) holder.findVariable(config.getDollyXVar()); YoDouble dollyYVar = (YoDouble) holder.findVariable(config.getDollyYVar()); YoDouble dollyZVar = (YoDouble) holder.findVariable(config.getDollyZVar()); cameraTrackAndDollyYoVariablesHolder.setDollyVars(dollyXVar, dollyYVar, dollyZVar); if (config.getFieldOfViewVar() != null) { YoDouble fieldOfViewVar = (YoDouble) yoVariableHolder.findVariable(config.getFieldOfViewVar()); cameraTrackAndDollyYoVariablesHolder.setFieldOfViewVar(fieldOfViewVar); } if (standardGUIActions != null) { standardGUIActions.makeCheckBoxesConsistentWithCamera(); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy