Warning cleanup.

Changed default composer camera angle
Displayed the grid by default
experimental
Nehon 10 years ago
parent 21179dc132
commit b3cdc1c3d2
  1. 10
      sdk/jme3-core/src/com/jme3/gde/core/scene/SceneApplication.java
  2. 7
      sdk/jme3-core/src/com/jme3/gde/core/scene/ScenePreviewProcessor.java
  3. 10
      sdk/jme3-core/src/com/jme3/gde/core/scene/controller/AbstractCameraController.java
  4. 9
      sdk/jme3-core/src/com/jme3/gde/core/scene/controller/SceneToolController.java
  5. 6
      sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/ComposerCameraController.java
  6. 20
      sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneComposerToolController.java
  7. 1
      sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneComposerTopComponent.form
  8. 14
      sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneComposerTopComponent.java

@ -275,7 +275,7 @@ public class SceneApplication extends Application implements LookupProvider {
super.destroy(); super.destroy();
} }
@Override @Override
public void update() { public void update() {
if (!started) { if (!started) {
try { try {
@ -299,7 +299,7 @@ public class SceneApplication extends Application implements LookupProvider {
fpsText.setText("Frames per second: " + fps); fpsText.setText("Frames per second: " + fps);
secondCounter = 0.0f; secondCounter = 0.0f;
} }
getStateManager().update(tpf); getStateManager().update(tpf);
toolsNode.updateLogicalState(tpf); toolsNode.updateLogicalState(tpf);
if (fakap != null) { if (fakap != null) {
fakap.updateFake(tpf); fakap.updateFake(tpf);
@ -519,10 +519,6 @@ public class SceneApplication extends Application implements LookupProvider {
} }
} }
private void resetCam() {
cam.setLocation(new Vector3f(0, 0, 10));
cam.lookAt(Vector3f.ZERO, Vector3f.UNIT_Y);
}
private void setWindowTitle(final String string) { private void setWindowTitle(final String string) {
SceneViewerTopComponent.findInstance().setDisplayName(string); SceneViewerTopComponent.findInstance().setDisplayName(string);
@ -637,7 +633,7 @@ public class SceneApplication extends Application implements LookupProvider {
NotifyUtil.show("Error starting OpenGL context!", "Click here to go to troubleshooting web page.", MessageType.EXCEPTION, lst, 0); NotifyUtil.show("Error starting OpenGL context!", "Click here to go to troubleshooting web page.", MessageType.EXCEPTION, lst, 0);
logger.log(Level.INFO, exception.getMessage(), exception); logger.log(Level.INFO, exception.getMessage(), exception);
} }
private static ActionListener lst = new ActionListener() { private static final ActionListener lst = new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
try { try {
HtmlBrowser.URLDisplayer.getDefault().showURL(new URL("http://jmonkeyengine.org/wiki/doku.php/sdk:troubleshooting")); HtmlBrowser.URLDisplayer.getDefault().showURL(new URL("http://jmonkeyengine.org/wiki/doku.php/sdk:troubleshooting"));

@ -64,9 +64,8 @@ public class ScenePreviewProcessor implements SceneProcessor {
private FrameBuffer offBuffer; private FrameBuffer offBuffer;
private ViewPort offView; private ViewPort offView;
private Camera offCamera; private Camera offCamera;
private ConcurrentLinkedQueue<PreviewRequest> previewQueue = new ConcurrentLinkedQueue<PreviewRequest>(); private final ConcurrentLinkedQueue<PreviewRequest> previewQueue = new ConcurrentLinkedQueue<PreviewRequest>();
private PreviewRequest currentPreviewRequest; private PreviewRequest currentPreviewRequest;
private RenderManager rm;
private PointLight light; private PointLight light;
public void addRequest(PreviewRequest request) { public void addRequest(PreviewRequest request) {
@ -126,7 +125,7 @@ public class ScenePreviewProcessor implements SceneProcessor {
} }
public void initialize(RenderManager rm, ViewPort vp) { public void initialize(RenderManager rm, ViewPort vp) {
this.rm = rm;
} }
public void reshape(ViewPort vp, int i, int i1) { public void reshape(ViewPort vp, int i, int i1) {

@ -116,6 +116,9 @@ public abstract class AbstractCameraController extends AbstractAppState implemen
if (cc != null) { if (cc != null) {
cam.setLocation(cc.cam.getLocation()); cam.setLocation(cc.cam.getLocation());
focus.set(cc.focus); focus.set(cc.focus);
}else{
cam.setLocation(new Vector3f(-10, 5, 10));
cam.lookAt(Vector3f.ZERO, Vector3f.UNIT_Y);
} }
inputManager.addRawInputListener(me); inputManager.addRawInputListener(me);
inputManager.addListener(me, "MouseAxisX", "MouseAxisY", "MouseAxisX-", "MouseAxisY-", "MouseWheel", "MouseWheel-", "MouseButtonLeft", "MouseButtonMiddle", "MouseButtonRight"); inputManager.addListener(me, "MouseAxisX", "MouseAxisY", "MouseAxisX-", "MouseAxisY-", "MouseWheel", "MouseWheel-", "MouseButtonLeft", "MouseButtonMiddle", "MouseButtonRight");
@ -127,7 +130,7 @@ public abstract class AbstractCameraController extends AbstractAppState implemen
private void addAdditionnalToolbar() { private void addAdditionnalToolbar() {
SceneViewerTopComponent svtc = SceneViewerTopComponent.findInstance(); SceneViewerTopComponent svtc = SceneViewerTopComponent.findInstance();
if (svtc != null) { if (svtc != null) {
svtc.add(CameraToolbar.getInstance(), java.awt.BorderLayout.SOUTH);; svtc.add(CameraToolbar.getInstance(), java.awt.BorderLayout.SOUTH);
} }
} }
@ -299,7 +302,7 @@ public abstract class AbstractCameraController extends AbstractAppState implemen
if (!cam.isParallelProjection()) { if (!cam.isParallelProjection()) {
cam.setParallelProjection(true); cam.setParallelProjection(true);
float h = cam.getFrustumTop(); float h = cam.getFrustumTop();
float w = cam.getFrustumRight(); float w;
float dist = cam.getLocation().distance(focus); float dist = cam.getLocation().distance(focus);
float fovY = FastMath.atan(h) / (FastMath.DEG_TO_RAD * .5f); float fovY = FastMath.atan(h) / (FastMath.DEG_TO_RAD * .5f);
h = FastMath.tan(fovY * FastMath.DEG_TO_RAD * .5f) * dist; h = FastMath.tan(fovY * FastMath.DEG_TO_RAD * .5f) * dist;
@ -557,12 +560,15 @@ public abstract class AbstractCameraController extends AbstractAppState implemen
/** /**
* mouse clicked, not dragged * mouse clicked, not dragged
* @param button
* @param pressed true if pressed, false if released * @param pressed true if pressed, false if released
*/ */
protected abstract void checkClick(int button, boolean pressed); protected abstract void checkClick(int button, boolean pressed);
/** /**
* Mouse dragged while button is depressed * Mouse dragged while button is depressed
* @param button
* @param pressed
*/ */
protected void checkDragged(int button, boolean pressed) { protected void checkDragged(int button, boolean pressed) {
// override in sub classes // override in sub classes

@ -27,7 +27,6 @@ import com.jme3.scene.Geometry;
import com.jme3.scene.Mesh; import com.jme3.scene.Mesh;
import com.jme3.scene.Node; import com.jme3.scene.Node;
import com.jme3.scene.Spatial; import com.jme3.scene.Spatial;
import com.jme3.scene.control.CameraControl;
import com.jme3.scene.debug.Arrow; import com.jme3.scene.debug.Arrow;
import com.jme3.scene.debug.Grid; import com.jme3.scene.debug.Grid;
import com.jme3.scene.debug.WireBox; import com.jme3.scene.debug.WireBox;
@ -51,12 +50,14 @@ public class SceneToolController implements AppState {
protected Material blueMat; protected Material blueMat;
protected AbstractCameraController camController; protected AbstractCameraController camController;
@SuppressWarnings("LeakingThisInConstructor")
public SceneToolController(AssetManager manager) { public SceneToolController(AssetManager manager) {
this.toolsNode = new Node("ToolsNode"); this.toolsNode = new Node("ToolsNode");
initTools(); initTools();
SceneApplication.getApplication().getStateManager().attach(this); SceneApplication.getApplication().getStateManager().attach(this);
} }
@SuppressWarnings("LeakingThisInConstructor")
public SceneToolController(Node toolsNode, AssetManager manager) { public SceneToolController(Node toolsNode, AssetManager manager) {
this.toolsNode = toolsNode; this.toolsNode = toolsNode;
this.manager = manager; this.manager = manager;
@ -68,7 +69,7 @@ public class SceneToolController implements AppState {
this.camController = camController; this.camController = camController;
} }
protected void initTools() { protected final void initTools() {
blueMat = createBlueMat(); blueMat = createBlueMat();
//Material redMat = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md"); //Material redMat = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md");
@ -103,9 +104,7 @@ public class SceneToolController implements AppState {
//grid //grid
grid = new Geometry("grid", new Grid(20, 20, 1.0f)); grid = new Geometry("grid", new Grid(20, 20, 1.0f));
grid.setMaterial(grayMat); grid.setMaterial(grayMat);
grid.setLocalTranslation(-10, 0, -10); grid.setLocalTranslation(-10, 0, -10);
final Spatial cursor = this.cursor;
final Node toolsNode = this.toolsNode;
SceneApplication.getApplication().enqueue(new Callable<Object>() { SceneApplication.getApplication().enqueue(new Callable<Object>() {
public Object call() throws Exception { public Object call() throws Exception {

@ -30,9 +30,7 @@ import com.jme3.gde.core.sceneexplorer.nodes.JmeNode;
import com.jme3.input.KeyInput; import com.jme3.input.KeyInput;
import com.jme3.input.event.KeyInputEvent; import com.jme3.input.event.KeyInputEvent;
import com.jme3.math.Vector2f; import com.jme3.math.Vector2f;
import com.jme3.math.Vector3f;
import com.jme3.renderer.Camera; import com.jme3.renderer.Camera;
import com.jme3.scene.Node;
/** /**
* *
@ -40,15 +38,11 @@ import com.jme3.scene.Node;
*/ */
public class ComposerCameraController extends AbstractCameraController { public class ComposerCameraController extends AbstractCameraController {
private Node rootNode;
private JmeNode jmeRootNode;
private SceneComposerToolController toolController; private SceneComposerToolController toolController;
private boolean forceCameraControls = false; // when user holds shift, this is true private boolean forceCameraControls = false; // when user holds shift, this is true
public ComposerCameraController(Camera cam, JmeNode rootNode) { public ComposerCameraController(Camera cam, JmeNode rootNode) {
super(cam, SceneApplication.getApplication().getInputManager()); super(cam, SceneApplication.getApplication().getInputManager());
this.jmeRootNode = rootNode;
this.rootNode = rootNode.getLookup().lookup(Node.class);
} }
private boolean isEditButtonEnabled() { private boolean isEditButtonEnabled() {

@ -39,8 +39,7 @@ public class SceneComposerToolController extends SceneToolController {
private JmeNode rootNode; private JmeNode rootNode;
private SceneEditTool editTool; private SceneEditTool editTool;
private SceneEditorController editorController; private SceneEditorController editorController;
private ComposerCameraController cameraController;
private ViewPort overlayView; private ViewPort overlayView;
private Node onTopToolsNode; private Node onTopToolsNode;
private Node nonSpatialMarkersNode; private Node nonSpatialMarkersNode;
@ -63,6 +62,7 @@ public class SceneComposerToolController extends SceneToolController {
return null; return null;
} }
}); });
setShowGrid(showGrid);
} }
public SceneComposerToolController(AssetManager manager) { public SceneComposerToolController(AssetManager manager) {
@ -73,9 +73,7 @@ public class SceneComposerToolController extends SceneToolController {
this.editorController = editorController; this.editorController = editorController;
} }
public void setCameraController(ComposerCameraController cameraController) { public void createOnTopToolNode() {
this.cameraController = cameraController;
// a node in a viewport that will always render on top // a node in a viewport that will always render on top
onTopToolsNode = new Node("OverlayNode"); onTopToolsNode = new Node("OverlayNode");
overlayView = SceneApplication.getApplication().getOverlayView(); overlayView = SceneApplication.getApplication().getOverlayView();
@ -91,7 +89,6 @@ public class SceneComposerToolController extends SceneToolController {
@Override @Override
public void cleanup() { public void cleanup() {
super.cleanup(); super.cleanup();
cameraController = null;
editorController = null; editorController = null;
SceneApplication.getApplication().enqueue(new Callable<Void>() { SceneApplication.getApplication().enqueue(new Callable<Void>() {
@ -126,6 +123,7 @@ public class SceneComposerToolController extends SceneToolController {
/** /**
* If the current tool overrides camera zoom/pan controls * If the current tool overrides camera zoom/pan controls
* @return
*/ */
public boolean isOverrideCameraControl() { public boolean isOverrideCameraControl() {
if (editTool != null) { if (editTool != null) {
@ -138,7 +136,7 @@ public class SceneComposerToolController extends SceneToolController {
/** /**
* Scene composer edit tool activated. Pass in null to remove tools. * Scene composer edit tool activated. Pass in null to remove tools.
* *
* @param sceneEditButton pass in null to hide any existing tool markers * @param sceneEditTool pass in null to hide any existing tool markers
*/ */
public void showEditTool(final SceneEditTool sceneEditTool) { public void showEditTool(final SceneEditTool sceneEditTool) {
SceneApplication.getApplication().enqueue(new Callable<Object>() { SceneApplication.getApplication().enqueue(new Callable<Object>() {
@ -175,6 +173,9 @@ public class SceneComposerToolController extends SceneToolController {
/** /**
* Primary button activated, send command to the tool * Primary button activated, send command to the tool
* for appropriate action. * for appropriate action.
* @param mouseLoc
* @param pressed
* @param camera
*/ */
public void doEditToolActivatedPrimary(Vector2f mouseLoc, boolean pressed, Camera camera) { public void doEditToolActivatedPrimary(Vector2f mouseLoc, boolean pressed, Camera camera) {
if (editTool != null) { if (editTool != null) {
@ -186,6 +187,9 @@ public class SceneComposerToolController extends SceneToolController {
/** /**
* Secondary button activated, send command to the tool * Secondary button activated, send command to the tool
* for appropriate action. * for appropriate action.
* @param mouseLoc
* @param pressed
* @param camera
*/ */
public void doEditToolActivatedSecondary(Vector2f mouseLoc, boolean pressed, Camera camera) { public void doEditToolActivatedSecondary(Vector2f mouseLoc, boolean pressed, Camera camera) {
if (editTool != null) { if (editTool != null) {
@ -223,6 +227,7 @@ public class SceneComposerToolController extends SceneToolController {
/** /**
* Adds a marker for the light to the scene if it does not exist yet * Adds a marker for the light to the scene if it does not exist yet
* @param light
*/ */
public void addLightMarker(Light light) { public void addLightMarker(Light light) {
if (!(light instanceof PointLight) && !(light instanceof SpotLight)) if (!(light instanceof PointLight) && !(light instanceof SpotLight))
@ -252,6 +257,7 @@ public class SceneComposerToolController extends SceneToolController {
/** /**
* Removes a light marker from the scene's tool node * Removes a light marker from the scene's tool node
* @param light
*/ */
public void removeLightMarker(Light light) { public void removeLightMarker(Light light) {
Spatial s = nonSpatialMarkersNode.getChild(light.getName()); Spatial s = nonSpatialMarkersNode.getChild(light.getName());

@ -392,6 +392,7 @@
</Component> </Component>
<Component class="javax.swing.JToggleButton" name="showGridToggleButton"> <Component class="javax.swing.JToggleButton" name="showGridToggleButton">
<Properties> <Properties>
<Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="com/jme3/gde/scenecomposer/Bundle.properties" key="SceneComposerTopComponent.showGridToggleButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/> <ResourceString bundle="com/jme3/gde/scenecomposer/Bundle.properties" key="SceneComposerTopComponent.showGridToggleButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property> </Property>

@ -72,7 +72,7 @@ public final class SceneComposerTopComponent extends TopComponent implements Sce
SceneEditorController editorController; SceneEditorController editorController;
private SceneRequest sentRequest; private SceneRequest sentRequest;
private SceneRequest currentRequest; private SceneRequest currentRequest;
private HelpCtx ctx = new HelpCtx("sdk.scene_composer"); private final HelpCtx ctx = new HelpCtx("sdk.scene_composer");
private ProjectAssetManager.ClassPathChangeListener listener; private ProjectAssetManager.ClassPathChangeListener listener;
public SceneComposerTopComponent() { public SceneComposerTopComponent() {
@ -88,6 +88,7 @@ public final class SceneComposerTopComponent extends TopComponent implements Sce
* WARNING: Do NOT modify this code. The content of this method is * WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor. * always regenerated by the Form Editor.
*/ */
@SuppressWarnings("UnnecessaryBoxing")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() { private void initComponents() {
@ -353,6 +354,7 @@ public final class SceneComposerTopComponent extends TopComponent implements Sce
}); });
jToolBar1.add(showSelectionToggleButton); jToolBar1.add(showSelectionToggleButton);
showGridToggleButton.setSelected(true);
org.openide.awt.Mnemonics.setLocalizedText(showGridToggleButton, org.openide.util.NbBundle.getMessage(SceneComposerTopComponent.class, "SceneComposerTopComponent.showGridToggleButton.text")); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(showGridToggleButton, org.openide.util.NbBundle.getMessage(SceneComposerTopComponent.class, "SceneComposerTopComponent.showGridToggleButton.text")); // NOI18N
showGridToggleButton.setToolTipText(org.openide.util.NbBundle.getMessage(SceneComposerTopComponent.class, "SceneComposerTopComponent.showGridToggleButton.toolTipText")); // NOI18N showGridToggleButton.setToolTipText(org.openide.util.NbBundle.getMessage(SceneComposerTopComponent.class, "SceneComposerTopComponent.showGridToggleButton.toolTipText")); // NOI18N
showGridToggleButton.setFocusable(false); showGridToggleButton.setFocusable(false);
@ -709,6 +711,7 @@ private void jToggleSelectGeomActionPerformed(java.awt.event.ActionEvent evt) {/
* Gets default instance. Do not use directly: reserved for *.settings files only, * Gets default instance. Do not use directly: reserved for *.settings files only,
* i.e. deserialization routines; otherwise you could get a non-deserialized instance. * i.e. deserialization routines; otherwise you could get a non-deserialized instance.
* To obtain the singleton instance, use {@link #findInstance}. * To obtain the singleton instance, use {@link #findInstance}.
* @return
*/ */
public static synchronized SceneComposerTopComponent getDefault() { public static synchronized SceneComposerTopComponent getDefault() {
if (instance == null) { if (instance == null) {
@ -719,6 +722,7 @@ private void jToggleSelectGeomActionPerformed(java.awt.event.ActionEvent evt) {/
/** /**
* Obtain the SceneComposerTopComponent instance. Never call {@link #getDefault} directly! * Obtain the SceneComposerTopComponent instance. Never call {@link #getDefault} directly!
* @return
*/ */
public static synchronized SceneComposerTopComponent findInstance() { public static synchronized SceneComposerTopComponent findInstance() {
TopComponent win = WindowManager.getDefault().findTopComponent(PREFERRED_ID); TopComponent win = WindowManager.getDefault().findTopComponent(PREFERRED_ID);
@ -841,7 +845,7 @@ private void jToggleSelectGeomActionPerformed(java.awt.event.ActionEvent evt) {/
if (!active) { if (!active) {
result.removeLookupListener(inst); result.removeLookupListener(inst);
showSelectionToggleButton.setSelected(true); showSelectionToggleButton.setSelected(true);
showGridToggleButton.setSelected(false); showGridToggleButton.setSelected(true);
sceneInfoLabel1.setText(""); sceneInfoLabel1.setText("");
sceneInfoLabel2.setText(""); sceneInfoLabel2.setText("");
sceneInfoLabel1.setToolTipText(""); sceneInfoLabel1.setToolTipText("");
@ -850,7 +854,7 @@ private void jToggleSelectGeomActionPerformed(java.awt.event.ActionEvent evt) {/
} else { } else {
result.addLookupListener(this); result.addLookupListener(this);
showSelectionToggleButton.setSelected(true); showSelectionToggleButton.setSelected(true);
showGridToggleButton.setSelected(false); showGridToggleButton.setSelected(true);
//TODO: threading //TODO: threading
if (file != null) { if (file != null) {
sceneInfoLabel1.setText("Name: " + file.getNameExt()); sceneInfoLabel1.setText("Name: " + file.getNameExt());
@ -917,6 +921,7 @@ private void jToggleSelectGeomActionPerformed(java.awt.event.ActionEvent evt) {/
/** /**
* listener for node selection changes * listener for node selection changes
* @param ev
*/ */
public void resultChanged(LookupEvent ev) { public void resultChanged(LookupEvent ev) {
if (currentRequest == null || !currentRequest.isDisplayed()) { if (currentRequest == null || !currentRequest.isDisplayed()) {
@ -994,10 +999,11 @@ private void jToggleSelectGeomActionPerformed(java.awt.event.ActionEvent evt) {/
camController.setMaster(this); camController.setMaster(this);
camController.enable(); camController.enable();
toolController.setCameraController(camController); toolController.createOnTopToolNode();
SelectTool tool = new SelectTool(); SelectTool tool = new SelectTool();
toolController.showEditTool(tool); toolController.showEditTool(tool);
toolController.setShowSelection(true); toolController.setShowSelection(true);
toolController.setShowGrid(true);
editorController.setToolController(toolController); editorController.setToolController(toolController);
toolController.refreshNonSpatialMarkers(); toolController.refreshNonSpatialMarkers();

Loading…
Cancel
Save