SDK : added possibility to switch to front, left, top, etc... views
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7919 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
@@ -16,8 +16,11 @@
|
|||||||
<file name="com-jme3-gde-core-sceneviewer-actions-SwitchFrontViewAction.instance">
|
<file name="com-jme3-gde-core-sceneviewer-actions-SwitchFrontViewAction.instance">
|
||||||
<attr name="iconBase" stringvalue="com/jme3/gde/core/sceneviewer/actions/32_bit.png"/>
|
<attr name="iconBase" stringvalue="com/jme3/gde/core/sceneviewer/actions/32_bit.png"/>
|
||||||
<attr name="instanceCreate" methodvalue="org.openide.awt.Actions.alwaysEnabled"/>
|
<attr name="instanceCreate" methodvalue="org.openide.awt.Actions.alwaysEnabled"/>
|
||||||
|
<attr name="instanceCreate" methodvalue="org.openide.awt.Actions.alwaysEnabled"/>
|
||||||
<attr name="noIconInMenu" boolvalue="false"/>
|
<attr name="noIconInMenu" boolvalue="false"/>
|
||||||
</file>
|
</file>
|
||||||
|
<file name="com-jme3-gde-core-sceneviewer-actions-SwitchFrontViewAction.instance"/>
|
||||||
|
<file name="com-jme3-gde-core-sceneviewer-actions-SwitchToFrontViewAction.instance_hidden"/>
|
||||||
</folder>
|
</folder>
|
||||||
<folder name="jMonkeyPlatform">
|
<folder name="jMonkeyPlatform">
|
||||||
<file name="com-jme3-gde-core-assets-actions-OpenModel.instance">
|
<file name="com-jme3-gde-core-assets-actions-OpenModel.instance">
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import com.jme3.app.Application;
|
|||||||
import com.jme3.app.StatsView;
|
import com.jme3.app.StatsView;
|
||||||
import com.jme3.font.BitmapFont;
|
import com.jme3.font.BitmapFont;
|
||||||
import com.jme3.font.BitmapText;
|
import com.jme3.font.BitmapText;
|
||||||
|
import com.jme3.gde.core.scene.controller.AbstractCameraController;
|
||||||
import com.jme3.gde.core.sceneexplorer.nodes.JmeSpatial;
|
import com.jme3.gde.core.sceneexplorer.nodes.JmeSpatial;
|
||||||
import com.jme3.gde.core.scene.processors.WireProcessor;
|
import com.jme3.gde.core.scene.processors.WireProcessor;
|
||||||
import com.jme3.gde.core.sceneviewer.SceneViewerTopComponent;
|
import com.jme3.gde.core.sceneviewer.SceneViewerTopComponent;
|
||||||
@@ -89,6 +90,7 @@ public class SceneApplication extends Application implements LookupProvider, Loo
|
|||||||
private Node statsGuiNode = new Node("Stats Gui Node");
|
private Node statsGuiNode = new Node("Stats Gui Node");
|
||||||
protected Node toolsNode = new Node("Tools Node");
|
protected Node toolsNode = new Node("Tools Node");
|
||||||
private SceneCameraController camController;
|
private SceneCameraController camController;
|
||||||
|
private AbstractCameraController activeCamController=null;
|
||||||
//preview variables
|
//preview variables
|
||||||
protected float secondCounter = 0.0f;
|
protected float secondCounter = 0.0f;
|
||||||
protected BitmapText fpsText;
|
protected BitmapText fpsText;
|
||||||
@@ -134,7 +136,8 @@ public class SceneApplication extends Application implements LookupProvider, Loo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SceneCameraController getCamController() {
|
public SceneCameraController getActiveCameraController() {
|
||||||
|
stateManager.getState(null);
|
||||||
return camController;
|
return camController;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -532,4 +535,14 @@ public class SceneApplication extends Application implements LookupProvider, Loo
|
|||||||
public ProgressHandle getProgressHandle() {
|
public ProgressHandle getProgressHandle() {
|
||||||
return progressHandle;
|
return progressHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AbstractCameraController getActiveCamController() {
|
||||||
|
return activeCamController;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActiveCamController(AbstractCameraController activeCamController) {
|
||||||
|
this.activeCamController = activeCamController;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+77
-56
@@ -30,6 +30,7 @@ import com.jme3.app.state.AppStateManager;
|
|||||||
import com.jme3.gde.core.scene.SceneApplication;
|
import com.jme3.gde.core.scene.SceneApplication;
|
||||||
import com.jme3.gde.core.scene.controller.toolbars.CameraToolbar;
|
import com.jme3.gde.core.scene.controller.toolbars.CameraToolbar;
|
||||||
import com.jme3.gde.core.sceneviewer.SceneViewerTopComponent;
|
import com.jme3.gde.core.sceneviewer.SceneViewerTopComponent;
|
||||||
|
import com.jme3.gde.core.util.CameraUtil.View;
|
||||||
import com.jme3.input.InputManager;
|
import com.jme3.input.InputManager;
|
||||||
import com.jme3.input.RawInputListener;
|
import com.jme3.input.RawInputListener;
|
||||||
import com.jme3.input.controls.ActionListener;
|
import com.jme3.input.controls.ActionListener;
|
||||||
@@ -80,24 +81,11 @@ public abstract class AbstractCameraController extends AbstractAppState implemen
|
|||||||
protected boolean checkDraggedR = false;
|
protected boolean checkDraggedR = false;
|
||||||
protected boolean checkReleaseLeft = false;
|
protected boolean checkReleaseLeft = false;
|
||||||
protected boolean checkReleaseRight = false;
|
protected boolean checkReleaseRight = false;
|
||||||
protected CameraToolbar camToolbar = new CameraToolbar();
|
|
||||||
|
|
||||||
public AbstractCameraController(Camera cam, InputManager inputManager) {
|
public AbstractCameraController(Camera cam, InputManager inputManager) {
|
||||||
this.cam = cam;
|
this.cam = cam;
|
||||||
this.inputManager = inputManager;
|
this.inputManager = inputManager;
|
||||||
|
|
||||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
|
||||||
|
|
||||||
public void run() {
|
|
||||||
|
|
||||||
SceneViewerTopComponent svtc = SceneViewerTopComponent.findInstance();
|
|
||||||
if (svtc != null) {
|
|
||||||
svtc.addAdditionnalToolbar(camToolbar);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMaster(Object component) {
|
public void setMaster(Object component) {
|
||||||
@@ -108,12 +96,35 @@ public abstract class AbstractCameraController extends AbstractAppState implemen
|
|||||||
inputManager.addRawInputListener(this);
|
inputManager.addRawInputListener(this);
|
||||||
inputManager.addListener(this, "MouseAxisX", "MouseAxisY", "MouseAxisX-", "MouseAxisY-", "MouseWheel", "MouseWheel-", "MouseButtonLeft", "MouseButtonMiddle", "MouseButtonRight");
|
inputManager.addListener(this, "MouseAxisX", "MouseAxisY", "MouseAxisX-", "MouseAxisY-", "MouseWheel", "MouseWheel-", "MouseButtonLeft", "MouseButtonMiddle", "MouseButtonRight");
|
||||||
SceneApplication.getApplication().getStateManager().attach(this);
|
SceneApplication.getApplication().getStateManager().attach(this);
|
||||||
|
SceneApplication.getApplication().setActiveCamController(this);
|
||||||
|
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
|
||||||
|
SceneViewerTopComponent svtc = SceneViewerTopComponent.findInstance();
|
||||||
|
if (svtc != null) {
|
||||||
|
svtc.addAdditionnalToolbar(CameraToolbar.getInstance());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disable() {
|
public void disable() {
|
||||||
inputManager.removeRawInputListener(this);
|
inputManager.removeRawInputListener(this);
|
||||||
inputManager.removeListener(this);
|
inputManager.removeListener(this);
|
||||||
SceneApplication.getApplication().getStateManager().detach(this);
|
SceneApplication.getApplication().getStateManager().detach(this);
|
||||||
|
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
|
||||||
|
SceneViewerTopComponent svtc = SceneViewerTopComponent.findInstance();
|
||||||
|
if (svtc != null) {
|
||||||
|
svtc.removeAdditionnalToolbar(CameraToolbar.getInstance());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCamFocus(final Vector3f focus) {
|
public void setCamFocus(final Vector3f focus) {
|
||||||
@@ -149,6 +160,17 @@ public abstract class AbstractCameraController extends AbstractAppState implemen
|
|||||||
|
|
||||||
Quaternion curRot = cam.getRotation().clone();
|
Quaternion curRot = cam.getRotation().clone();
|
||||||
cam.setRotation(rot.mult(curRot));
|
cam.setRotation(rot.mult(curRot));
|
||||||
|
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
|
||||||
|
SceneViewerTopComponent svtc = SceneViewerTopComponent.findInstance();
|
||||||
|
if (svtc != null) {
|
||||||
|
CameraToolbar.getInstance().switchToView(View.User);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void panCamera(float left, float up) {
|
protected void panCamera(float left, float up) {
|
||||||
@@ -183,7 +205,7 @@ public abstract class AbstractCameraController extends AbstractAppState implemen
|
|||||||
|
|
||||||
public void toggleOrthoPerspMode() {
|
public void toggleOrthoPerspMode() {
|
||||||
try {
|
try {
|
||||||
camToolbar.toggleOrthoMode(SceneApplication.getApplication().enqueue(new Callable<Boolean>() {
|
CameraToolbar.getInstance().toggleOrthoMode(SceneApplication.getApplication().enqueue(new Callable<Boolean>() {
|
||||||
|
|
||||||
public Boolean call() throws Exception {
|
public Boolean call() throws Exception {
|
||||||
return doToggleOrthoPerspMode();
|
return doToggleOrthoPerspMode();
|
||||||
@@ -196,6 +218,47 @@ public abstract class AbstractCameraController extends AbstractAppState implemen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void switchToView(final View view) {
|
||||||
|
SceneApplication.getApplication().enqueue(new Callable<Object>() {
|
||||||
|
|
||||||
|
public Object call() throws Exception {
|
||||||
|
float dist = cam.getLocation().distance(focus);
|
||||||
|
switch (view) {
|
||||||
|
case Front:
|
||||||
|
cam.setLocation(new Vector3f(focus.x, focus.y, focus.z+dist));
|
||||||
|
cam.lookAt(focus, Vector3f.UNIT_Y);
|
||||||
|
break;
|
||||||
|
case Left:
|
||||||
|
cam.setLocation(new Vector3f(focus.x+dist, focus.y, focus.z));
|
||||||
|
cam.lookAt(focus, Vector3f.UNIT_Y);
|
||||||
|
break;
|
||||||
|
case Right:
|
||||||
|
cam.setLocation(new Vector3f(focus.x-dist, focus.y, focus.z));
|
||||||
|
cam.lookAt(focus, Vector3f.UNIT_Y);
|
||||||
|
break;
|
||||||
|
case Back:
|
||||||
|
cam.setLocation(new Vector3f(focus.x, focus.y, focus.z-dist));
|
||||||
|
cam.lookAt(focus, Vector3f.UNIT_Y);
|
||||||
|
break;
|
||||||
|
case Top:
|
||||||
|
cam.setLocation(new Vector3f(focus.x, focus.y+dist, focus.z));
|
||||||
|
cam.lookAt(focus, Vector3f.UNIT_Z.mult(-1));
|
||||||
|
|
||||||
|
break;
|
||||||
|
case Bottom:
|
||||||
|
cam.setLocation(new Vector3f(focus.x, focus.y-dist, focus.z));
|
||||||
|
cam.lookAt(focus, Vector3f.UNIT_Z);
|
||||||
|
break;
|
||||||
|
case User:
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
CameraToolbar.getInstance().switchToView(view);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
protected boolean doToggleOrthoPerspMode() {
|
protected boolean doToggleOrthoPerspMode() {
|
||||||
|
|
||||||
float aspect = (float) cam.getWidth() / cam.getHeight();
|
float aspect = (float) cam.getWidth() / cam.getHeight();
|
||||||
@@ -214,50 +277,8 @@ public abstract class AbstractCameraController extends AbstractAppState implemen
|
|||||||
cam.setFrustumPerspective(45f, aspect, 1, 1000);
|
cam.setFrustumPerspective(45f, aspect, 1, 1000);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public void onAction(String string, boolean bln, float f) {
|
|
||||||
if ("MouseButtonLeft".equals(string)) {
|
|
||||||
if (bln) {
|
|
||||||
leftMouse = true;
|
|
||||||
moved = false;
|
|
||||||
} else {
|
|
||||||
if (leftMouse)
|
|
||||||
checkReleaseLeft = true;
|
|
||||||
leftMouse = false;
|
|
||||||
if (!moved) {
|
|
||||||
if (checkClick == false)
|
|
||||||
checkClick = true;
|
|
||||||
checkDragged = false;
|
|
||||||
} else {
|
|
||||||
checkDragged = true;
|
|
||||||
checkClick = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ("MouseButtonRight".equals(string)) {
|
|
||||||
if (bln) {
|
|
||||||
rightMouse = true;
|
|
||||||
movedR = false;
|
|
||||||
} else {
|
|
||||||
if (rightMouse)
|
|
||||||
checkReleaseRight = true;
|
|
||||||
rightMouse = false;
|
|
||||||
if (!movedR) {
|
|
||||||
if (checkClickR == false)
|
|
||||||
checkClickR = true;
|
|
||||||
checkDraggedR = false;
|
|
||||||
} else {
|
|
||||||
checkDraggedR = true;
|
|
||||||
checkClickR = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
public void onAnalog(String string, float f1, float f) {
|
public void onAnalog(String string, float f1, float f) {
|
||||||
if ("MouseAxisX".equals(string)) {
|
if ("MouseAxisX".equals(string)) {
|
||||||
moved = true;
|
moved = true;
|
||||||
|
|||||||
@@ -4,7 +4,15 @@
|
|||||||
*/
|
*/
|
||||||
package com.jme3.gde.core.scene.controller.toolbars;
|
package com.jme3.gde.core.scene.controller.toolbars;
|
||||||
|
|
||||||
|
import com.jme3.gde.core.sceneviewer.SceneViewerTopComponent;
|
||||||
|
import com.jme3.gde.core.sceneviewer.actions.SwitchBackViewAction;
|
||||||
|
import com.jme3.gde.core.sceneviewer.actions.SwitchBottomViewAction;
|
||||||
|
import com.jme3.gde.core.sceneviewer.actions.SwitchFrontViewAction;
|
||||||
|
import com.jme3.gde.core.sceneviewer.actions.SwitchLeftViewAction;
|
||||||
|
import com.jme3.gde.core.sceneviewer.actions.SwitchRightViewAction;
|
||||||
|
import com.jme3.gde.core.sceneviewer.actions.SwitchTopViewAction;
|
||||||
import com.jme3.gde.core.sceneviewer.actions.ToggleOrthoPerspAction;
|
import com.jme3.gde.core.sceneviewer.actions.ToggleOrthoPerspAction;
|
||||||
|
import com.jme3.gde.core.util.CameraUtil.View;
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
import org.openide.util.NbBundle;
|
import org.openide.util.NbBundle;
|
||||||
|
|
||||||
@@ -14,18 +22,39 @@ import org.openide.util.NbBundle;
|
|||||||
*/
|
*/
|
||||||
public class CameraToolbar extends javax.swing.JToolBar {
|
public class CameraToolbar extends javax.swing.JToolBar {
|
||||||
|
|
||||||
|
protected boolean isUserView = true;
|
||||||
|
private static CameraToolbar instance;
|
||||||
ImageIcon userIcon = new ImageIcon(getClass().getResource("/com/jme3/gde/core/scene/controller/toolbars/user.png"));
|
ImageIcon userIcon = new ImageIcon(getClass().getResource("/com/jme3/gde/core/scene/controller/toolbars/user.png"));
|
||||||
//toolbar actions
|
//toolbar actions
|
||||||
private ToggleOrthoPerspAction toggleOrthoPerspAction;
|
private ToggleOrthoPerspAction toggleOrthoPerspAction;
|
||||||
|
private SwitchFrontViewAction switchFrontViewAction;
|
||||||
|
private SwitchLeftViewAction switchLeftViewAction;
|
||||||
|
private SwitchRightViewAction switchRightViewAction;
|
||||||
|
private SwitchTopViewAction switchTopViewAction;
|
||||||
|
private SwitchBackViewAction switchBackViewAction;
|
||||||
|
private SwitchBottomViewAction switchBottomViewAction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates new form NewJPanel
|
* Creates new form NewJPanel
|
||||||
*/
|
*/
|
||||||
public CameraToolbar() {
|
protected CameraToolbar() {
|
||||||
toggleOrthoPerspAction = new ToggleOrthoPerspAction();
|
toggleOrthoPerspAction = new ToggleOrthoPerspAction();
|
||||||
|
switchFrontViewAction = new SwitchFrontViewAction();
|
||||||
|
switchLeftViewAction = new SwitchLeftViewAction();
|
||||||
|
switchBackViewAction = new SwitchBackViewAction();
|
||||||
|
switchBottomViewAction = new SwitchBottomViewAction();
|
||||||
|
switchTopViewAction = new SwitchTopViewAction();
|
||||||
|
switchRightViewAction = new SwitchRightViewAction();
|
||||||
initComponents();
|
initComponents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static CameraToolbar getInstance() {
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new CameraToolbar();
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
/** This method is called from within the constructor to
|
/** This method is called from within the constructor to
|
||||||
* initialize the form.
|
* initialize the form.
|
||||||
* WARNING: Do NOT modify this code. The content of this method is
|
* WARNING: Do NOT modify this code. The content of this method is
|
||||||
@@ -152,27 +181,70 @@ private void viewButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FI
|
|||||||
}//GEN-LAST:event_viewButtonActionPerformed
|
}//GEN-LAST:event_viewButtonActionPerformed
|
||||||
|
|
||||||
private void frontMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_frontMenuItemActionPerformed
|
private void frontMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_frontMenuItemActionPerformed
|
||||||
toggleFrontView();
|
SceneViewerTopComponent.findInstance().requestActive();
|
||||||
|
final java.awt.event.ActionEvent e = evt;
|
||||||
|
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
switchFrontViewAction.actionPerformed(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}//GEN-LAST:event_frontMenuItemActionPerformed
|
}//GEN-LAST:event_frontMenuItemActionPerformed
|
||||||
|
|
||||||
private void leftMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_leftMenuItemActionPerformed
|
private void leftMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_leftMenuItemActionPerformed
|
||||||
toggleLeftView();
|
SceneViewerTopComponent.findInstance().requestActive();
|
||||||
|
final java.awt.event.ActionEvent e = evt;
|
||||||
|
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
switchLeftViewAction.actionPerformed(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
}//GEN-LAST:event_leftMenuItemActionPerformed
|
}//GEN-LAST:event_leftMenuItemActionPerformed
|
||||||
|
|
||||||
private void rightMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rightMenuItemActionPerformed
|
private void rightMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rightMenuItemActionPerformed
|
||||||
toggleRightView();
|
SceneViewerTopComponent.findInstance().requestActive();
|
||||||
|
final java.awt.event.ActionEvent e = evt;
|
||||||
|
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
switchRightViewAction.actionPerformed(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
}//GEN-LAST:event_rightMenuItemActionPerformed
|
}//GEN-LAST:event_rightMenuItemActionPerformed
|
||||||
|
|
||||||
private void topMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_topMenuItemActionPerformed
|
private void topMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_topMenuItemActionPerformed
|
||||||
toggleTopView();
|
SceneViewerTopComponent.findInstance().requestActive();
|
||||||
|
final java.awt.event.ActionEvent e = evt;
|
||||||
|
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
switchTopViewAction.actionPerformed(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
}//GEN-LAST:event_topMenuItemActionPerformed
|
}//GEN-LAST:event_topMenuItemActionPerformed
|
||||||
|
|
||||||
private void backMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backMenuItemActionPerformed
|
private void backMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backMenuItemActionPerformed
|
||||||
toggleBackView();
|
SceneViewerTopComponent.findInstance().requestActive();
|
||||||
|
final java.awt.event.ActionEvent e = evt;
|
||||||
|
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
switchBackViewAction.actionPerformed(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
}//GEN-LAST:event_backMenuItemActionPerformed
|
}//GEN-LAST:event_backMenuItemActionPerformed
|
||||||
|
|
||||||
private void bottomMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bottomMenuItemActionPerformed
|
private void bottomMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bottomMenuItemActionPerformed
|
||||||
toggleBottomView();
|
SceneViewerTopComponent.findInstance().requestActive();
|
||||||
|
final java.awt.event.ActionEvent e = evt;
|
||||||
|
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
switchBottomViewAction.actionPerformed(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
}//GEN-LAST:event_bottomMenuItemActionPerformed
|
}//GEN-LAST:event_bottomMenuItemActionPerformed
|
||||||
|
|
||||||
private void enableOrthoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_enableOrthoActionPerformed
|
private void enableOrthoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_enableOrthoActionPerformed
|
||||||
@@ -190,39 +262,47 @@ private void enableOrthoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
|
|||||||
private javax.swing.JPopupMenu viewMenu;
|
private javax.swing.JPopupMenu viewMenu;
|
||||||
// End of variables declaration//GEN-END:variables
|
// End of variables declaration//GEN-END:variables
|
||||||
|
|
||||||
public void toggleFrontView() {
|
public void switchToView(View view) {
|
||||||
viewButton.setIcon(frontMenuItem.getIcon());
|
|
||||||
viewButton.setText(frontMenuItem.getText());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void toggleUserView() {
|
switch (view) {
|
||||||
viewButton.setIcon(userIcon);
|
case Front:
|
||||||
viewButton.setText(NbBundle.getMessage(CameraToolbar.class, "CameraToolbar.viewButton.label"));
|
viewButton.setIcon(frontMenuItem.getIcon());
|
||||||
}
|
viewButton.setText(frontMenuItem.getText());
|
||||||
|
isUserView = false;
|
||||||
public void toggleLeftView() {
|
break;
|
||||||
viewButton.setIcon(leftMenuItem.getIcon());
|
case Left:
|
||||||
viewButton.setText(leftMenuItem.getText());
|
viewButton.setIcon(leftMenuItem.getIcon());
|
||||||
}
|
viewButton.setText(leftMenuItem.getText());
|
||||||
|
isUserView = false;
|
||||||
public void toggleRightView() {
|
break;
|
||||||
viewButton.setIcon(rightMenuItem.getIcon());
|
case Right:
|
||||||
viewButton.setText(rightMenuItem.getText());
|
viewButton.setIcon(rightMenuItem.getIcon());
|
||||||
}
|
viewButton.setText(rightMenuItem.getText());
|
||||||
|
isUserView = false;
|
||||||
public void toggleBackView() {
|
break;
|
||||||
viewButton.setIcon(backMenuItem.getIcon());
|
case Back:
|
||||||
viewButton.setText(backMenuItem.getText());
|
viewButton.setIcon(backMenuItem.getIcon());
|
||||||
}
|
viewButton.setText(backMenuItem.getText());
|
||||||
|
isUserView = false;
|
||||||
public void toggleTopView() {
|
break;
|
||||||
viewButton.setIcon(topMenuItem.getIcon());
|
case Top:
|
||||||
viewButton.setText(topMenuItem.getText());
|
viewButton.setIcon(topMenuItem.getIcon());
|
||||||
}
|
viewButton.setText(topMenuItem.getText());
|
||||||
|
isUserView = false;
|
||||||
public void toggleBottomView() {
|
break;
|
||||||
viewButton.setIcon(bottomMenuItem.getIcon());
|
case Bottom:
|
||||||
viewButton.setText(bottomMenuItem.getText());
|
viewButton.setIcon(bottomMenuItem.getIcon());
|
||||||
|
viewButton.setText(bottomMenuItem.getText());
|
||||||
|
isUserView = false;
|
||||||
|
break;
|
||||||
|
case User:
|
||||||
|
default:
|
||||||
|
if (!isUserView) {
|
||||||
|
viewButton.setIcon(userIcon);
|
||||||
|
viewButton.setText(NbBundle.getMessage(CameraToolbar.class, "CameraToolbar.viewButton.label"));
|
||||||
|
isUserView = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toggleOrthoMode(boolean enabled) {
|
public void toggleOrthoMode(boolean enabled) {
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ public final class SceneViewerTopComponent extends TopComponent {
|
|||||||
if (e.getWheelRotation() < 0) {
|
if (e.getWheelRotation() < 0) {
|
||||||
action = "MouseWheel";
|
action = "MouseWheel";
|
||||||
}
|
}
|
||||||
app.getCamController().onAnalog(action, e.getWheelRotation(), 0);
|
app.getActiveCamController().onAnalog(action, e.getWheelRotation(), 0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -327,7 +327,10 @@ public final class SceneViewerTopComponent extends TopComponent {
|
|||||||
|
|
||||||
|
|
||||||
public void addAdditionnalToolbar(JToolBar tb){
|
public void addAdditionnalToolbar(JToolBar tb){
|
||||||
// jToolBar1.add(tb,4);
|
jToolBar1.add(tb,4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void removeAdditionnalToolbar(JToolBar tb){
|
||||||
|
jToolBar1.remove(tb);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package com.jme3.gde.core.sceneviewer.actions;
|
||||||
|
|
||||||
|
import com.jme3.gde.core.scene.SceneApplication;
|
||||||
|
import com.jme3.gde.core.sceneviewer.SceneViewerTopComponent;
|
||||||
|
import com.jme3.gde.core.util.CameraUtil.View;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import org.openide.awt.ActionRegistration;
|
||||||
|
import org.openide.awt.ActionReference;
|
||||||
|
import org.openide.awt.ActionReferences;
|
||||||
|
import org.openide.awt.ActionID;
|
||||||
|
import org.openide.util.NbBundle.Messages;
|
||||||
|
|
||||||
|
@ActionID(category = "SceneComposer",
|
||||||
|
id = "com.jme3.gde.core.sceneviewer.actions.SwitchBackViewAction")
|
||||||
|
@ActionRegistration(displayName = "#CTL_SwitchBackViewAction")
|
||||||
|
@ActionReferences({
|
||||||
|
@ActionReference(path = "Shortcuts", name = "END")
|
||||||
|
})
|
||||||
|
@Messages("CTL_SwitchBackViewAction=Switch to back view")
|
||||||
|
public final class SwitchBackViewAction implements ActionListener {
|
||||||
|
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
SceneViewerTopComponent svtc = SceneViewerTopComponent.findInstance();
|
||||||
|
|
||||||
|
if (svtc.hasFocus()) {
|
||||||
|
|
||||||
|
SceneApplication.getApplication().getActiveCamController().switchToView(View.Back);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package com.jme3.gde.core.sceneviewer.actions;
|
||||||
|
|
||||||
|
import com.jme3.gde.core.scene.SceneApplication;
|
||||||
|
import com.jme3.gde.core.sceneviewer.SceneViewerTopComponent;
|
||||||
|
import com.jme3.gde.core.util.CameraUtil.View;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import org.openide.awt.ActionRegistration;
|
||||||
|
import org.openide.awt.ActionReference;
|
||||||
|
import org.openide.awt.ActionReferences;
|
||||||
|
import org.openide.awt.ActionID;
|
||||||
|
import org.openide.util.NbBundle.Messages;
|
||||||
|
|
||||||
|
@ActionID(category = "SceneComposer",
|
||||||
|
id = "com.jme3.gde.core.sceneviewer.actions.SwitchBottomViewAction")
|
||||||
|
@ActionRegistration(displayName = "#CTL_SwitchBottomViewAction")
|
||||||
|
@ActionReferences({
|
||||||
|
@ActionReference(path = "Shortcuts", name = "HOME")
|
||||||
|
})
|
||||||
|
@Messages("CTL_SwitchBottomViewAction=Switch to bottom view")
|
||||||
|
public final class SwitchBottomViewAction implements ActionListener {
|
||||||
|
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
SceneViewerTopComponent svtc = SceneViewerTopComponent.findInstance();
|
||||||
|
|
||||||
|
if (svtc.hasFocus()) {
|
||||||
|
|
||||||
|
SceneApplication.getApplication().getActiveCamController().switchToView(View.Bottom);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,9 @@
|
|||||||
|
|
||||||
package com.jme3.gde.core.sceneviewer.actions;
|
package com.jme3.gde.core.sceneviewer.actions;
|
||||||
|
|
||||||
|
import com.jme3.gde.core.scene.SceneApplication;
|
||||||
import com.jme3.gde.core.sceneviewer.SceneViewerTopComponent;
|
import com.jme3.gde.core.sceneviewer.SceneViewerTopComponent;
|
||||||
|
import com.jme3.gde.core.util.CameraUtil.View;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import org.openide.awt.ActionRegistration;
|
import org.openide.awt.ActionRegistration;
|
||||||
@@ -10,23 +13,20 @@ import org.openide.awt.ActionID;
|
|||||||
import org.openide.util.NbBundle.Messages;
|
import org.openide.util.NbBundle.Messages;
|
||||||
|
|
||||||
@ActionID(category = "SceneComposer",
|
@ActionID(category = "SceneComposer",
|
||||||
id = "com.jme3.gde.core.sceneviewer.actions.SwitchFrontViewAcction")
|
id = "com.jme3.gde.core.sceneviewer.actions.SwitchFrontViewAction")
|
||||||
@ActionRegistration(displayName = "#CTL_SwitchFrontViewAcction")
|
@ActionRegistration(displayName = "#CTL_SwitchFrontViewAction")
|
||||||
@ActionReferences({
|
@ActionReferences({
|
||||||
@ActionReference(path = "Actions/jMonkeyPlatform"),
|
|
||||||
@ActionReference(path = "Shortcuts", name = "NUMPAD1")
|
@ActionReference(path = "Shortcuts", name = "NUMPAD1")
|
||||||
})
|
})
|
||||||
@Messages("CTL_SwitchFrontViewAcction=Switch to front view")
|
@Messages("CTL_SwitchFrontViewAction=Switch to front view")
|
||||||
public final class SwitchFrontViewAction implements ActionListener {
|
public final class SwitchFrontViewAction implements ActionListener {
|
||||||
|
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
SceneViewerTopComponent svtc = SceneViewerTopComponent.findInstance();
|
||||||
|
|
||||||
SceneViewerTopComponent svtc = SceneViewerTopComponent.findInstance();
|
|
||||||
if (svtc.hasFocus()) {
|
if (svtc.hasFocus()) {
|
||||||
System.out.println("front view");
|
|
||||||
|
SceneApplication.getApplication().getActiveCamController().switchToView(View.Front);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package com.jme3.gde.core.sceneviewer.actions;
|
||||||
|
|
||||||
|
import com.jme3.gde.core.scene.SceneApplication;
|
||||||
|
import com.jme3.gde.core.sceneviewer.SceneViewerTopComponent;
|
||||||
|
import com.jme3.gde.core.util.CameraUtil.View;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import org.openide.awt.ActionRegistration;
|
||||||
|
import org.openide.awt.ActionReference;
|
||||||
|
import org.openide.awt.ActionReferences;
|
||||||
|
import org.openide.awt.ActionID;
|
||||||
|
import org.openide.util.NbBundle.Messages;
|
||||||
|
|
||||||
|
@ActionID(category = "SceneComposer",
|
||||||
|
id = "com.jme3.gde.core.sceneviewer.actions.SwitchLeftViewAction")
|
||||||
|
@ActionRegistration(displayName = "#CTL_SwitchLeftViewAction")
|
||||||
|
@ActionReferences({
|
||||||
|
@ActionReference(path = "Shortcuts", name = "NUMPAD3")
|
||||||
|
})
|
||||||
|
@Messages("CTL_SwitchLeftViewAction=Switch to left view")
|
||||||
|
public final class SwitchLeftViewAction implements ActionListener {
|
||||||
|
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
SceneViewerTopComponent svtc = SceneViewerTopComponent.findInstance();
|
||||||
|
|
||||||
|
if (svtc.hasFocus()) {
|
||||||
|
|
||||||
|
SceneApplication.getApplication().getActiveCamController().switchToView(View.Left);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package com.jme3.gde.core.sceneviewer.actions;
|
||||||
|
|
||||||
|
import com.jme3.gde.core.scene.SceneApplication;
|
||||||
|
import com.jme3.gde.core.sceneviewer.SceneViewerTopComponent;
|
||||||
|
import com.jme3.gde.core.util.CameraUtil.View;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import org.openide.awt.ActionRegistration;
|
||||||
|
import org.openide.awt.ActionReference;
|
||||||
|
import org.openide.awt.ActionReferences;
|
||||||
|
import org.openide.awt.ActionID;
|
||||||
|
import org.openide.util.NbBundle.Messages;
|
||||||
|
|
||||||
|
@ActionID(category = "SceneComposer",
|
||||||
|
id = "com.jme3.gde.core.sceneviewer.actions.SwitchRightViewAction")
|
||||||
|
@ActionRegistration(displayName = "#CTL_SwitchRightViewAction")
|
||||||
|
@ActionReferences({
|
||||||
|
@ActionReference(path = "Shortcuts", name = "PAGE_DOWN")
|
||||||
|
})
|
||||||
|
@Messages("CTL_SwitchRightViewAction=Switch to right vue")
|
||||||
|
public final class SwitchRightViewAction implements ActionListener {
|
||||||
|
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
SceneViewerTopComponent svtc = SceneViewerTopComponent.findInstance();
|
||||||
|
|
||||||
|
if (svtc.hasFocus()) {
|
||||||
|
|
||||||
|
SceneApplication.getApplication().getActiveCamController().switchToView(View.Right);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package com.jme3.gde.core.sceneviewer.actions;
|
||||||
|
|
||||||
|
import com.jme3.gde.core.scene.SceneApplication;
|
||||||
|
import com.jme3.gde.core.sceneviewer.SceneViewerTopComponent;
|
||||||
|
import com.jme3.gde.core.util.CameraUtil.View;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import org.openide.awt.ActionRegistration;
|
||||||
|
import org.openide.awt.ActionReference;
|
||||||
|
import org.openide.awt.ActionReferences;
|
||||||
|
import org.openide.awt.ActionID;
|
||||||
|
import org.openide.util.NbBundle.Messages;
|
||||||
|
|
||||||
|
@ActionID(category = "SceneComposer",
|
||||||
|
id = "com.jme3.gde.core.sceneviewer.actions.SwitchTopViewAction")
|
||||||
|
@ActionRegistration(displayName = "#CTL_SwitchTopViewAction")
|
||||||
|
@ActionReferences({
|
||||||
|
@ActionReference(path = "Shortcuts", name = "NUMPAD7")
|
||||||
|
})
|
||||||
|
@Messages("CTL_SwitchTopViewAction=Switch to top view")
|
||||||
|
public final class SwitchTopViewAction implements ActionListener {
|
||||||
|
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
SceneViewerTopComponent svtc = SceneViewerTopComponent.findInstance();
|
||||||
|
|
||||||
|
if (svtc.hasFocus()) {
|
||||||
|
|
||||||
|
SceneApplication.getApplication().getActiveCamController().switchToView(View.Top);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.jme3.gde.core.sceneviewer.actions;
|
package com.jme3.gde.core.sceneviewer.actions;
|
||||||
|
|
||||||
import com.jme3.gde.core.scene.SceneApplication;
|
import com.jme3.gde.core.scene.SceneApplication;
|
||||||
|
import com.jme3.gde.core.scene.SceneRequest;
|
||||||
import com.jme3.gde.core.sceneviewer.SceneViewerTopComponent;
|
import com.jme3.gde.core.sceneviewer.SceneViewerTopComponent;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
@@ -27,7 +28,7 @@ public final class ToggleOrthoPerspAction implements ActionListener {
|
|||||||
|
|
||||||
SceneViewerTopComponent svtc = SceneViewerTopComponent.findInstance();
|
SceneViewerTopComponent svtc = SceneViewerTopComponent.findInstance();
|
||||||
if (svtc.hasFocus()) {
|
if (svtc.hasFocus()) {
|
||||||
SceneApplication.getApplication().getCamController().toggleOrthoPerspMode();
|
SceneApplication.getApplication().getActiveCamController().toggleOrthoPerspMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
package com.jme3.gde.core.util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Nehon
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
public class CameraUtil {
|
||||||
|
|
||||||
|
public enum View{
|
||||||
|
Front,Left,Right,Top,Bottom,Back,User
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user