From 059210250cf0818f111671d0920a3e2e868cabac Mon Sep 17 00:00:00 2001 From: brentowens Date: Thu, 8 Sep 2011 23:45:33 +0000 Subject: [PATCH] * added audio node marker to Scene Explorer. * Light markers now are removed when light is deleted. git-svn-id: http://jmonkeyengine.googlecode.com/svn/trunk@8227 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../gde/core/sceneexplorer/nodes/JmeLight.java | 2 + .../core/sceneexplorer/nodes/JmePointLight.java | 8 -- .../scenecomposer/SceneComposerToolController.java | 126 +++++++++++++++++---- .../gde/scenecomposer/SceneEditorController.java | 12 -- .../src/com/jme3/gde/scenecomposer/audionode.gif | Bin 0 -> 340 bytes 5 files changed, 109 insertions(+), 39 deletions(-) create mode 100644 sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/audionode.gif diff --git a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/JmeLight.java b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/JmeLight.java index e5e4a45fe..6170fd62b 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/JmeLight.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/JmeLight.java @@ -43,6 +43,7 @@ import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import javax.swing.Action; import org.openide.actions.DeleteAction; +import org.openide.loaders.DataObject; import org.openide.nodes.Children; import org.openide.nodes.Sheet; import org.openide.util.Exceptions; @@ -121,6 +122,7 @@ public class JmeLight extends AbstractSceneExplorerNode { @Override public void destroy() throws IOException { try { + fireSave(true); SceneApplication.getApplication().enqueue(new Callable() { public Void call() throws Exception { diff --git a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/JmePointLight.java b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/JmePointLight.java index 1f1afd3f3..398f91ab0 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/JmePointLight.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/JmePointLight.java @@ -32,12 +32,9 @@ package com.jme3.gde.core.sceneexplorer.nodes; -import com.jme3.gde.core.sceneexplorer.nodes.SceneExplorerNode; import com.jme3.light.PointLight; import com.jme3.math.Vector3f; import com.jme3.scene.Spatial; -import org.openide.cookies.SaveCookie; -import org.openide.loaders.DataObject; import org.openide.nodes.Sheet; /** @@ -85,9 +82,4 @@ public class JmePointLight extends JmeLight{ public Class getExplorerNodeClass() { return JmePointLight.class; } - - public org.openide.nodes.Node[] createNodes(Object key, DataObject key2, SaveCookie cookie) { - return null; - } - } diff --git a/sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneComposerToolController.java b/sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneComposerToolController.java index f64d9d667..49836898e 100644 --- a/sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneComposerToolController.java +++ b/sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneComposerToolController.java @@ -5,15 +5,11 @@ package com.jme3.gde.scenecomposer; import com.jme3.asset.AssetManager; -import com.jme3.bounding.BoundingVolume; -import com.jme3.collision.Collidable; -import com.jme3.collision.CollisionResults; -import com.jme3.collision.UnsupportedCollisionException; +import com.jme3.audio.AudioNode; import com.jme3.gde.core.scene.SceneApplication; import com.jme3.gde.core.scene.controller.SceneToolController; import com.jme3.gde.core.sceneexplorer.nodes.JmeNode; import com.jme3.light.Light; -import com.jme3.light.LightList; import com.jme3.light.PointLight; import com.jme3.light.SpotLight; import com.jme3.material.Material; @@ -26,14 +22,11 @@ import com.jme3.renderer.ViewPort; import com.jme3.renderer.queue.RenderQueue.Bucket; import com.jme3.scene.Geometry; import com.jme3.scene.Node; -import com.jme3.scene.SceneGraphVisitor; import com.jme3.scene.Spatial; -import com.jme3.scene.control.AbstractControl; import com.jme3.scene.control.BillboardControl; import com.jme3.scene.control.Control; import com.jme3.scene.shape.Quad; import com.jme3.texture.Texture; -import java.util.Queue; import java.util.concurrent.Callable; /** @@ -48,14 +41,15 @@ public class SceneComposerToolController extends SceneToolController { private ComposerCameraController cameraController; private ViewPort overlayView; private Node onTopToolsNode; - private Node lightMarkersNode; + private Node nonSpatialMarkersNode; private Material lightMarkerMaterial; + private Material audioMarkerMaterial; public SceneComposerToolController(Node toolsNode, AssetManager manager, JmeNode rootNode) { super(toolsNode, manager); this.rootNode = rootNode; - lightMarkersNode = new Node("lightMarkersNode"); - toolsNode.attachChild(lightMarkersNode); + nonSpatialMarkersNode = new Node("lightMarkersNode"); + toolsNode.attachChild(nonSpatialMarkersNode); } public SceneComposerToolController(AssetManager manager) { @@ -203,10 +197,6 @@ public class SceneComposerToolController extends SceneToolController { editTool.draggedSecondary(mouseLoc, pressed, rootNode, editorController.getCurrentDataObject()); } } - - public Node getLightMarkersNode() { - return lightMarkersNode; - } /** * Adds a marker for the light to the scene if it does not exist yet @@ -215,21 +205,33 @@ public class SceneComposerToolController extends SceneToolController { if (!(light instanceof PointLight) && !(light instanceof SpotLight)) return; // only handle point and spot lights - Spatial s = lightMarkersNode.getChild(light.getName()); + Spatial s = nonSpatialMarkersNode.getChild(light.getName()); if (s != null) { // update location maybe? Remove old and replace with new? return; } LightMarker lm = new LightMarker(light); - lightMarkersNode.attachChild(lm); + nonSpatialMarkersNode.attachChild(lm); + } + + public void addAudioMarker(AudioNode audio) { + + Spatial s = nonSpatialMarkersNode.getChild(audio.getName()); + if (s != null) { + // update location maybe? Remove old and replace with new? + return; + } + + AudioMarker am = new AudioMarker(audio); + nonSpatialMarkersNode.attachChild(am); } /** * Removes a light marker from the scene's tool node */ public void removeLightMarker(Light light) { - Spatial s = lightMarkersNode.getChild(light.getName()); + Spatial s = nonSpatialMarkersNode.getChild(light.getName()); s.removeFromParent(); } @@ -243,9 +245,20 @@ public class SceneComposerToolController extends SceneToolController { } return lightMarkerMaterial; } + + private Material getAudioMarkerMaterial() { + if (audioMarkerMaterial == null) { + Material mat = new Material(manager, "Common/MatDefs/Misc/Unshaded.j3md"); + Texture tex = manager.loadTexture("com/jme3/gde/scenecomposer/audionode.gif"); + mat.setTexture("ColorMap", tex); + mat.getAdditionalRenderState().setBlendMode(BlendMode.Alpha); + audioMarkerMaterial = mat; + } + return audioMarkerMaterial; + } protected void refreshNonSpatialMarkers() { - lightMarkersNode.detachAllChildren(); + nonSpatialMarkersNode.detachAllChildren(); addMarkers(rootNode.getLookup().lookup(Node.class)); } @@ -254,6 +267,10 @@ public class SceneComposerToolController extends SceneToolController { for (Light light : parent.getLocalLightList()) addLightMarker(light); + if (parent instanceof AudioNode) { + addAudioMarker((AudioNode)parent); + } + for (Spatial s : parent.getChildren()) { if (s instanceof Node) addMarkers((Node)s); @@ -343,4 +360,75 @@ public class SceneComposerToolController extends SceneToolController { } } + + /** + * A marker on the screen that shows where an audio node is. + * This marker is not part of the scene, but is part of the tools node. + */ + protected class AudioMarker extends Geometry { + private AudioNode audio; + + protected AudioMarker() {} + + protected AudioMarker(AudioNode audio) { + this.audio = audio; + Quad q = new Quad(0.5f, 0.5f); + this.setMesh(q); + this.setMaterial(getAudioMarkerMaterial()); + this.addControl(new AudioMarkerControl()); + this.setQueueBucket(Bucket.Transparent); + } + + protected AudioNode getAudioNode() { + return audio; + } + + @Override + public void setLocalTranslation(Vector3f location) { + super.setLocalTranslation(location); + audio.setLocalTranslation(location); + } + + @Override + public void setLocalTranslation(float x, float y, float z) { + super.setLocalTranslation(x, y, z); + audio.setLocalTranslation(x, y, z); + } + } + + /** + * Updates the marker's position whenever the audio node has moved. + * It is also a BillboardControl, so this marker always faces + * the camera + */ + protected class AudioMarkerControl extends BillboardControl { + + AudioMarkerControl(){ + super(); + } + + @Override + protected void controlUpdate(float f) { + super.controlUpdate(f); + AudioMarker marker = (AudioMarker) getSpatial(); + if (marker != null) { + marker.setLocalTranslation(marker.getAudioNode().getWorldTranslation()); + } + } + + @Override + protected void controlRender(RenderManager rm, ViewPort vp) { + super.controlRender(rm, vp); + } + + @Override + public Control cloneForSpatial(Spatial sptl) { + AudioMarkerControl c = new AudioMarkerControl(); + c.setSpatial(sptl); + //TODO this isn't correct, none of BillboardControl is copied over + return c; + } + + } + } diff --git a/sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneEditorController.java b/sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneEditorController.java index 54a3c09b2..35a050ef3 100644 --- a/sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneEditorController.java +++ b/sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneEditorController.java @@ -7,28 +7,17 @@ package com.jme3.gde.scenecomposer; import com.jme3.asset.AssetManager; import com.jme3.asset.DesktopAssetManager; import com.jme3.asset.ModelKey; -import com.jme3.audio.AudioNode; import com.jme3.bullet.collision.shapes.CapsuleCollisionShape; import com.jme3.bullet.control.CharacterControl; import com.jme3.bullet.control.RigidBodyControl; -import com.jme3.effect.shapes.EmitterSphereShape; -import com.jme3.effect.ParticleEmitter; -import com.jme3.effect.ParticleMesh; import com.jme3.gde.core.assets.ProjectAssetManager; import com.jme3.gde.core.assets.SpatialAssetDataObject; import com.jme3.gde.core.scene.SceneApplication; -import com.jme3.gde.core.scene.controller.SceneToolController; import com.jme3.gde.core.sceneexplorer.nodes.AbstractSceneExplorerNode; import com.jme3.gde.core.sceneexplorer.nodes.JmeSpatial; import com.jme3.gde.core.undoredo.AbstractUndoableSceneEdit; import com.jme3.gde.core.undoredo.SceneUndoRedoManager; -import com.jme3.light.AmbientLight; -import com.jme3.light.DirectionalLight; import com.jme3.light.Light; -import com.jme3.light.PointLight; -import com.jme3.light.SpotLight; -import com.jme3.material.Material; -import com.jme3.math.ColorRGBA; import com.jme3.math.Quaternion; import com.jme3.math.Vector3f; import com.jme3.scene.AssetLinkNode; @@ -38,7 +27,6 @@ import com.jme3.scene.Node; import com.jme3.scene.Spatial; import com.jme3.scene.VertexBuffer.Type; import com.jme3.scene.control.Control; -import com.jme3.ui.Picture; import com.jme3.util.TangentBinormalGenerator; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; diff --git a/sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/audionode.gif b/sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/audionode.gif new file mode 100644 index 0000000000000000000000000000000000000000..6b7af790a1f0b53eb1c07039b67188ca0c75ece0 GIT binary patch literal 340 zcmZ?wbhEHb6krfwxN5;LGmW98f6o8^|6}bK{%=wH|DWOiv!egAjQ<~$|G!oK|L4j7 zzv%w`_iw_S760cO>sh)iUc3GObAkVF+5Ey1qLOlAQ}ZUyTXo^ut^dbm{%=pO^gKsS%!#8Ih3rf3r+vV)p+fn*Ud7CZreqU!(c?>(~EF zjQ*dOox6O~iF23#0^PAp{r?P;|Nj;Lzc16Xa{d3G$ul_i|EFG{3+Z^fx&`7 z2P6sd69ZeJ!<+&O7KRQFC5HkZrRlSl1@G8%cFB;i0rjv z>{}SHqP0-DP0L|=j#9aZxE`Yl2Zw}Cxu}3HqZ~WCree8<7%!tNr<$R5c7z$fi7*SN a0bjWXGmE79%2g~Z>o;s(#q8n8U=09^Op(R_ literal 0 HcmV?d00001 -- 2.11.0