Warning cleanup.

Changed default composer camera angle
Displayed the grid by default
experimental
Nehon 10 years ago
parent 21179dc132
commit b3cdc1c3d2
  1. 6
      sdk/jme3-core/src/com/jme3/gde/core/scene/SceneApplication.java
  2. 5
      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. 7
      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. 18
      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

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

@ -116,6 +116,9 @@ public abstract class AbstractCameraController extends AbstractAppState implemen
if (cc != null) {
cam.setLocation(cc.cam.getLocation());
focus.set(cc.focus);
}else{
cam.setLocation(new Vector3f(-10, 5, 10));
cam.lookAt(Vector3f.ZERO, Vector3f.UNIT_Y);
}
inputManager.addRawInputListener(me);
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() {
SceneViewerTopComponent svtc = SceneViewerTopComponent.findInstance();
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()) {
cam.setParallelProjection(true);
float h = cam.getFrustumTop();
float w = cam.getFrustumRight();
float w;
float dist = cam.getLocation().distance(focus);
float fovY = FastMath.atan(h) / (FastMath.DEG_TO_RAD * .5f);
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
* @param button
* @param pressed true if pressed, false if released
*/
protected abstract void checkClick(int button, boolean pressed);
/**
* Mouse dragged while button is depressed
* @param button
* @param pressed
*/
protected void checkDragged(int button, boolean pressed) {
// override in sub classes

@ -27,7 +27,6 @@ import com.jme3.scene.Geometry;
import com.jme3.scene.Mesh;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.scene.control.CameraControl;
import com.jme3.scene.debug.Arrow;
import com.jme3.scene.debug.Grid;
import com.jme3.scene.debug.WireBox;
@ -51,12 +50,14 @@ public class SceneToolController implements AppState {
protected Material blueMat;
protected AbstractCameraController camController;
@SuppressWarnings("LeakingThisInConstructor")
public SceneToolController(AssetManager manager) {
this.toolsNode = new Node("ToolsNode");
initTools();
SceneApplication.getApplication().getStateManager().attach(this);
}
@SuppressWarnings("LeakingThisInConstructor")
public SceneToolController(Node toolsNode, AssetManager manager) {
this.toolsNode = toolsNode;
this.manager = manager;
@ -68,7 +69,7 @@ public class SceneToolController implements AppState {
this.camController = camController;
}
protected void initTools() {
protected final void initTools() {
blueMat = createBlueMat();
//Material redMat = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md");
@ -104,8 +105,6 @@ public class SceneToolController implements AppState {
grid = new Geometry("grid", new Grid(20, 20, 1.0f));
grid.setMaterial(grayMat);
grid.setLocalTranslation(-10, 0, -10);
final Spatial cursor = this.cursor;
final Node toolsNode = this.toolsNode;
SceneApplication.getApplication().enqueue(new Callable<Object>() {
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.event.KeyInputEvent;
import com.jme3.math.Vector2f;
import com.jme3.math.Vector3f;
import com.jme3.renderer.Camera;
import com.jme3.scene.Node;
/**
*
@ -40,15 +38,11 @@ import com.jme3.scene.Node;
*/
public class ComposerCameraController extends AbstractCameraController {
private Node rootNode;
private JmeNode jmeRootNode;
private SceneComposerToolController toolController;
private boolean forceCameraControls = false; // when user holds shift, this is true
public ComposerCameraController(Camera cam, JmeNode rootNode) {
super(cam, SceneApplication.getApplication().getInputManager());
this.jmeRootNode = rootNode;
this.rootNode = rootNode.getLookup().lookup(Node.class);
}
private boolean isEditButtonEnabled() {

@ -40,7 +40,6 @@ public class SceneComposerToolController extends SceneToolController {
private JmeNode rootNode;
private SceneEditTool editTool;
private SceneEditorController editorController;
private ComposerCameraController cameraController;
private ViewPort overlayView;
private Node onTopToolsNode;
private Node nonSpatialMarkersNode;
@ -63,6 +62,7 @@ public class SceneComposerToolController extends SceneToolController {
return null;
}
});
setShowGrid(showGrid);
}
public SceneComposerToolController(AssetManager manager) {
@ -73,9 +73,7 @@ public class SceneComposerToolController extends SceneToolController {
this.editorController = editorController;
}
public void setCameraController(ComposerCameraController cameraController) {
this.cameraController = cameraController;
public void createOnTopToolNode() {
// a node in a viewport that will always render on top
onTopToolsNode = new Node("OverlayNode");
overlayView = SceneApplication.getApplication().getOverlayView();
@ -91,7 +89,6 @@ public class SceneComposerToolController extends SceneToolController {
@Override
public void cleanup() {
super.cleanup();
cameraController = null;
editorController = null;
SceneApplication.getApplication().enqueue(new Callable<Void>() {
@ -126,6 +123,7 @@ public class SceneComposerToolController extends SceneToolController {
/**
* If the current tool overrides camera zoom/pan controls
* @return
*/
public boolean isOverrideCameraControl() {
if (editTool != null) {
@ -138,7 +136,7 @@ public class SceneComposerToolController extends SceneToolController {
/**
* 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) {
SceneApplication.getApplication().enqueue(new Callable<Object>() {
@ -175,6 +173,9 @@ public class SceneComposerToolController extends SceneToolController {
/**
* Primary button activated, send command to the tool
* for appropriate action.
* @param mouseLoc
* @param pressed
* @param camera
*/
public void doEditToolActivatedPrimary(Vector2f mouseLoc, boolean pressed, Camera camera) {
if (editTool != null) {
@ -186,6 +187,9 @@ public class SceneComposerToolController extends SceneToolController {
/**
* Secondary button activated, send command to the tool
* for appropriate action.
* @param mouseLoc
* @param pressed
* @param camera
*/
public void doEditToolActivatedSecondary(Vector2f mouseLoc, boolean pressed, Camera camera) {
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
* @param light
*/
public void addLightMarker(Light light) {
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
* @param light
*/
public void removeLightMarker(Light light) {
Spatial s = nonSpatialMarkersNode.getChild(light.getName());

@ -392,6 +392,7 @@
</Component>
<Component class="javax.swing.JToggleButton" name="showGridToggleButton">
<Properties>
<Property name="selected" type="boolean" value="true"/>
<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;)"/>
</Property>

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

Loading…
Cancel
Save