* added audio node marker to Scene Explorer.

* Light markers now are removed when light is deleted.

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8227 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
bre..ns 13 years ago
parent cea09e02ed
commit 2c0f6d2d4d
  1. 2
      sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/JmeLight.java
  2. 8
      sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/JmePointLight.java
  3. 126
      sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneComposerToolController.java
  4. 12
      sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneEditorController.java
  5. BIN
      sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/audionode.gif

@ -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<Void>() {
public Void call() throws Exception {

@ -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;
}
}

@ -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) {
@ -204,10 +198,6 @@ public class SceneComposerToolController extends SceneToolController {
}
}
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();
}
@ -244,8 +246,19 @@ 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;
}
}
}

@ -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;

Binary file not shown.

After

Width:  |  Height:  |  Size: 340 B

Loading…
Cancel
Save