From 8348011344a1c5f219c5a366d9a0d0ef44c902ea Mon Sep 17 00:00:00 2001 From: "nor..67" Date: Fri, 25 Mar 2011 19:41:23 +0000 Subject: [PATCH] - add undoObject to AbstractToolAction - add Optimize Geometry tool - fix Tool list generation git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7113 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../build_jme3_sources_with_netbeans.html | 218 +----------------- .../docs/jme3/intermediate/file_types.html | 2 +- .../nodes/actions/AbstractToolAction.java | 9 +- .../nodes/actions/UseToolAction.java | 2 +- .../actions/impl/GenerateTangentsTool.java | 4 +- .../nodes/actions/impl/OptimizeGeometry.java | 69 ++++++ 6 files changed, 86 insertions(+), 218 deletions(-) create mode 100644 sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/OptimizeGeometry.java diff --git a/sdk/jme3-core/javahelp/com/jme3/gde/core/docs/jme3/build_jme3_sources_with_netbeans.html b/sdk/jme3-core/javahelp/com/jme3/gde/core/docs/jme3/build_jme3_sources_with_netbeans.html index b17b13eaf..70bdb40f1 100644 --- a/sdk/jme3-core/javahelp/com/jme3/gde/core/docs/jme3/build_jme3_sources_with_netbeans.html +++ b/sdk/jme3-core/javahelp/com/jme3/gde/core/docs/jme3/build_jme3_sources_with_netbeans.html @@ -1,15 +1,10 @@ -

Setting up JME3 in Netbeans 6.x

+

Setting up a svn checkout of the jME3 Engine

-You are welcome to try out the new jME3, and contribute patches and features! This document shows how to download, set up, build, and run the latest development version from the sources. (As of Early 2010, we are in pre-alpha.) -

- -

-
- +You are welcome to try out the new jME3, and contribute patches and features! This document shows how to download, set up, build, and run the latest development version from the sources.

@@ -23,11 +18,10 @@ Note: In the following, always replace ”~” with the path to your home direct

-Check out the sources form the repository. (The following NetBeans instructions are equivalent to executing cd ~/NetBeansProjects; svn checkout on the commandline.) - +Check out the sources from the repository.

    -
  1. In NetBeans go to Team > Subversion > Checkout
    +
  2. In jMonkeyPlatform go to Team > Subversion > Checkout
    1. Repository URL:
    2. @@ -37,9 +31,9 @@ Check out the sources form the repository. (The following NetBeans instructions
    3. Click Next
        -
      1. Repository Folders: “branches/jme3”
        +
      2. Repository Folders: “trunk/engine”
      3. -
      4. Local Folder: ~/NetBeansProjects
        +
      5. Local Folder: ~/jMonkeyProjects
    4. @@ -49,96 +43,8 @@ Check out the sources form the repository. (The following NetBeans instructions

      -The jme3 project opens in the Project window. -

      - -

      -Look into the Libraries node and confirm that the project depends on the following libraries in the classpath: -

      -
      -jME3-natives-joal.jar	lwjgl.jar       gluegen-rt.jar
      -jME3-jogl-natives.jar   jbullet.jar	stack-alloc.jar
      -jME3-lwjgl-natives.jar	jinput.jar	swing-layout-1.0.4.jar
      -j-ogg-oggd.jar	        joal.jar	vecmath.jar
      -j-ogg-vorbisd.jar       jogl.jar        asm-all-3.1.jar
      -
      - -

      -If you should see any red exclamation marks on packages, look at the Troubleshooting section below. -

      - -
- -

Optional: Setting up JOAL and JOGL

-
- -

- -This steps configures two optional libraries: JOAL for Audio, and JOGL as back-up option for older GPUs. (This step is recommended, but you can skip it if you know what are are doing.) - -

-
    -
  1. Open the jme3's project properties from the Projects window, and go to the Run category.
    -
  2. -
  3. Under VM Options, enter the following, depending on your operating system. (Replace 32 with 64 if applicable.)
    -
      -
    • Windows: -Djava.library.path=“lib/jogl/win32/:lib/joal/win32/”
      -
    • -
    • Linux: -Djava.library.path=“lib/jogl/linux32/:lib/joal/linux32/”
      -
    • -
    • Mac OS: -Djava.library.path=“lib/jogl/macosx_universal/:lib/joal/macosx/”
      -
    • -
    -
  4. -
- -

- -It is possible to configure one univerversal java library path - this is useful if you ever need to build a platform-independent JAR of your project: -

- - -

- -Important: When copying from the wiki, make certain to use normal quotation marks, not the curly ones. +The jme3 project opens in the Project window.

- -
- -

Optional: Setting up Android Support

-
- -

- -Work in progress … -

- -

-A jme3 application can either be deployed to the desktop (as Java Swing application) and web browser (as JNLP/WebStart or Applet), or to an Android phone. While the former is the default, switching to Android deployment can be done in a few steps. - -

-
    -
  1. Open Project Properties, go to Sources category.
    -
  2. -
  3. At Source Packages Folders, click “Add Folder”.
    -
      -
    • Add src/jme3_android
      -
    • -
    • Remove src/jme3_desktop
      -
    • -
    • Remove src/jme3_desktop_fx
      -
    • -
    -
  4. -
  5. build.xml…
    -
  6. -
-

Build and Run

@@ -146,7 +52,7 @@ A jme3 application can either be deployed to the desktop (as Java Swing applicat

-That's it! +That's it!

  1. Right-click the jme3 project node and “Clean and Build” the project.
    @@ -163,113 +69,5 @@ That's it!
-

- -Sample code for cool features is in the src/jme3_test folder. A sample game can be found in jme3_games/jme3game/cubefield/CubeField.java. -

- -

-Tips: -

- - - - -

Optional: Javadoc Popups and Source Navigation in NetBeans

-
- -

- -If you are working on the jme3 sources: -

-
    -
  1. In the Projects window, right-click the jme3 project and choose Generate Javadoc. Wait.
    -
  2. -
  3. Confirm in the Files window that the javadoc has been created in ~/NetBeansProjects/jme3/dist/javadoc
    -
  4. -
  5. In the editor, place the caret in a jme class and press ctrl-space to view javadoc.
    -
  6. -
- -

- -If you are working on a game project that depends on jme3: -

-
    -
  1. First follow the previous tip. (In the future, we may offer jme javadoc as download instead.)
    -
  2. -
  3. In your game project, right-click the Libraries node and choose “Properties”.
    -
  4. -
  5. In the Library properties, select jme3.jar and click the Edit button.
    -
      -
    1. For the Javadoc field, browse to ~/NetBeansProjects/jme3/dist/javadoc. Check “as relative path” and click select.
      -
    2. -
    3. For the Sources field, browse to ~/NetBeansProjects/jme3/src. Check “as relative path” and click select.
      -
    4. -
    5. Click OK.
      -
    6. -
    -
  6. -
  7. In the editor, place the caret in a jme class and press ctrl-space to view javadoc. Ctrl-click any jme3 method to jump to its definition in the sources.
    -
  8. -
- -

- -This tip works for any third-party JAR library that you use. (You may have to download the javadoc/sources from their home page separately). -

- -
- -

Troubleshooting

-
- -

- -Cannot Find Symbol SwingWorker compile errors, and red exclamation marks on some package icons? SwingWorker is part of JDK6 but not JDK5. If you get this error, you have two options to fix it: -

- - -

- -
- -

-
- -

- -
- -

- -

-Sources used: , -

-

view online version

\ No newline at end of file diff --git a/sdk/jme3-core/javahelp/com/jme3/gde/core/docs/jme3/intermediate/file_types.html b/sdk/jme3-core/javahelp/com/jme3/gde/core/docs/jme3/intermediate/file_types.html index 1f9721ce4..6a05dff11 100644 --- a/sdk/jme3-core/javahelp/com/jme3/gde/core/docs/jme3/intermediate/file_types.html +++ b/sdk/jme3-core/javahelp/com/jme3/gde/core/docs/jme3/intermediate/file_types.html @@ -42,7 +42,7 @@ .DDS, .HDR, .PFM, .TGATextures - .fontBitmap fonts + .fntBitmap fonts .WAV, .OGGWave and OGG Vorbis audio diff --git a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/AbstractToolAction.java b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/AbstractToolAction.java index 6ea95a34f..0c74af6b6 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/AbstractToolAction.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/AbstractToolAction.java @@ -59,12 +59,13 @@ public abstract class AbstractToolAction implements ToolAction { SceneApplication.getApplication().enqueue(new Callable() { public Void call() throws Exception { - if (doApplyTool(rootNode)) { + final Object object = doApplyTool(rootNode); + if (object!=null) { Lookup.getDefault().lookup(SceneUndoRedoManager.class).addEdit(this, new AbstractUndoableSceneEdit() { @Override public void sceneUndo() throws CannotUndoException { - doUndoTool(rootNode); + doUndoTool(rootNode,object); setModified(); } @@ -105,9 +106,9 @@ public abstract class AbstractToolAction implements ToolAction { }; } - protected abstract boolean doApplyTool(AbstractSceneExplorerNode rootNode); + protected abstract Object doApplyTool(AbstractSceneExplorerNode rootNode); - protected abstract void doUndoTool(AbstractSceneExplorerNode rootNode); + protected abstract void doUndoTool(AbstractSceneExplorerNode rootNode, Object undoObject); // protected abstract void doAwtUndo(); // protected abstract void doAwtRedo(); diff --git a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/UseToolAction.java b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/UseToolAction.java index 67faae673..49d6117e4 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/UseToolAction.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/UseToolAction.java @@ -61,7 +61,7 @@ public class UseToolAction extends AbstractAction implements Presenter.Popup { public JMenuItem getPopupPresenter() { JMenu result = new JMenu("Tools.."); for (ToolAction di : Lookup.getDefault().lookupAll(ToolAction.class)) { - if(exNode.getClass().isAssignableFrom(di.getNodeClass())){ + if(di.getNodeClass().isAssignableFrom(exNode.getClass())){ result.add(new JMenuItem(di.getAction(exNode, dataObject))); } } diff --git a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/GenerateTangentsTool.java b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/GenerateTangentsTool.java index fdbd362bc..15809afdd 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/GenerateTangentsTool.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/GenerateTangentsTool.java @@ -52,7 +52,7 @@ public class GenerateTangentsTool extends AbstractToolAction { } @Override - protected boolean doApplyTool(AbstractSceneExplorerNode rootNode) { + protected Object doApplyTool(AbstractSceneExplorerNode rootNode) { Geometry geom = rootNode.getLookup().lookup(Geometry.class); Mesh mesh = geom.getMesh(); if (mesh != null) { @@ -62,7 +62,7 @@ public class GenerateTangentsTool extends AbstractToolAction { } @Override - protected void doUndoTool(AbstractSceneExplorerNode rootNode) { + protected void doUndoTool(AbstractSceneExplorerNode rootNode, Object undoObject) { Geometry geom = rootNode.getLookup().lookup(Geometry.class); Mesh mesh = geom.getMesh(); if (mesh != null) { diff --git a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/OptimizeGeometry.java b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/OptimizeGeometry.java new file mode 100644 index 000000000..fbd6c01fb --- /dev/null +++ b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/OptimizeGeometry.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2009-2010 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.gde.core.sceneexplorer.nodes.actions.impl; + +import com.jme3.gde.core.sceneexplorer.nodes.AbstractSceneExplorerNode; +import com.jme3.gde.core.sceneexplorer.nodes.JmeSpatial; +import com.jme3.gde.core.sceneexplorer.nodes.actions.AbstractToolAction; +import com.jme3.gde.core.sceneexplorer.nodes.actions.ToolAction; +import com.jme3.scene.Spatial; +import jme3tools.optimize.GeometryBatchFactory; + +/** + * + * @author normenhansen + */ +@org.openide.util.lookup.ServiceProvider(service = ToolAction.class) +public class OptimizeGeometry extends AbstractToolAction { + + public OptimizeGeometry() { + name = "Optimize Geometry"; + } + + @Override + protected Object doApplyTool(AbstractSceneExplorerNode rootNode) { + Spatial geom = rootNode.getLookup().lookup(Spatial.class); + GeometryBatchFactory.optimize(geom); + return true; + } + + @Override + protected void doUndoTool(AbstractSceneExplorerNode rootNode, Object undoObject) { +// Spatial geom = rootNode.getLookup().lookup(Spatial.class); +// geom.removeFromParent(); + } + + public Class getNodeClass() { + return JmeSpatial.class; + } + +}