- Added a CameraRequest to the PreviewRequest to be able to request location, rotation and lookAt of the scene camera
- fixed some compilation warning

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7959 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
rem..om 14 years ago
parent 2767600fe3
commit 8dba313b4a
  1. 4
      sdk/jme3-core/src/com/jme3/gde/core/properties/TextureBrowser.java
  2. 31
      sdk/jme3-core/src/com/jme3/gde/core/scene/PreviewRequest.java
  3. 41
      sdk/jme3-core/src/com/jme3/gde/core/scene/ScenePreviewProcessor.java
  4. 2
      sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/JmeParticleEmitter.java
  5. 4
      sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/NewSpatialPopup.java

@ -44,7 +44,6 @@ import javax.swing.Icon;
import javax.swing.ImageIcon; import javax.swing.ImageIcon;
import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener; import javax.swing.event.TreeSelectionListener;
import javax.swing.text.Position.Bias;
import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeNode; import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath; import javax.swing.tree.TreePath;
@ -75,7 +74,7 @@ public class TextureBrowser extends javax.swing.JDialog implements TreeSelection
initComponents(); initComponents();
loadAvailableTextures(); loadAvailableTextures();
setSelectedTexture((Texture) editor.getValue()); setSelectedTexture((Texture) editor.getValue());
setLocationRelativeTo(null); setLocationRelativeTo(null);
} }
/** This method is called from within the constructor to /** This method is called from within the constructor to
@ -266,7 +265,6 @@ public class TextureBrowser extends javax.swing.JDialog implements TreeSelection
private void setSelectedTexture(Texture texture) { private void setSelectedTexture(Texture texture) {
if (texture != null) { if (texture != null) {
Logger.getLogger(TextureBrowser.class.getName()).finer("Looking for Texture: " + texture.getName()); Logger.getLogger(TextureBrowser.class.getName()).finer("Looking for Texture: " + texture.getName());
System.out.println("texture : " + texture.getName());
String[] path = ("/" + texture.getName()).split("/"); String[] path = ("/" + texture.getName()).split("/");
TreePath parent = new TreePath((TreeNode) jTree1.getModel().getRoot()); TreePath parent = new TreePath((TreeNode) jTree1.getModel().getRoot());
jTree1.expandPath(TreeUtil.buildTreePath(jTree1, parent, path, 0, true)); jTree1.expandPath(TreeUtil.buildTreePath(jTree1, parent, path, 0, true));

@ -29,9 +29,11 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package com.jme3.gde.core.scene; package com.jme3.gde.core.scene;
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
import com.jme3.renderer.Camera;
import com.jme3.scene.Spatial; import com.jme3.scene.Spatial;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
@ -40,13 +42,16 @@ import java.awt.image.BufferedImage;
* @author normenhansen * @author normenhansen
*/ */
public class PreviewRequest { public class PreviewRequest {
private Object requester; private Object requester;
private Spatial spatial; private Spatial spatial;
private BufferedImage image; private BufferedImage image;
private CameraRequest cameraRequest;
public PreviewRequest(Object requester, Spatial spatial) { public PreviewRequest(Object requester, Spatial spatial) {
this.requester = requester; this.requester = requester;
this.spatial = spatial; this.spatial = spatial;
cameraRequest = new CameraRequest();
} }
/** /**
@ -77,4 +82,28 @@ public class PreviewRequest {
this.image = image; this.image = image;
} }
public CameraRequest getCameraRequest() {
return cameraRequest;
}
public class CameraRequest {
Vector3f location = null;
Quaternion rotation = null;
Vector3f lookAt = null;
Vector3f up = null;
public void setLocation(Vector3f location) {
this.location = location;
}
public void setLookAt(Vector3f lookAt, Vector3f up) {
this.lookAt = lookAt;
this.up = up;
}
public void setRotation(Quaternion rotation) {
this.rotation = rotation;
}
}
} }

@ -55,7 +55,7 @@ import java.util.concurrent.ConcurrentLinkedQueue;
* @author normenhansen * @author normenhansen
*/ */
public class ScenePreviewProcessor implements SceneProcessor { public class ScenePreviewProcessor implements SceneProcessor {
private static final int width = 120, height = 120; private static final int width = 120, height = 120;
private final ByteBuffer cpuBuf = BufferUtils.createByteBuffer(width * height * 4); private final ByteBuffer cpuBuf = BufferUtils.createByteBuffer(width * height * 4);
private final byte[] cpuArray = new byte[width * height * 4]; private final byte[] cpuArray = new byte[width * height * 4];
@ -67,16 +67,17 @@ public class ScenePreviewProcessor implements SceneProcessor {
private ConcurrentLinkedQueue<PreviewRequest> previewQueue = new ConcurrentLinkedQueue<PreviewRequest>(); private ConcurrentLinkedQueue<PreviewRequest> previewQueue = new ConcurrentLinkedQueue<PreviewRequest>();
private PreviewRequest currentPreviewRequest; private PreviewRequest currentPreviewRequest;
private RenderManager rm; private RenderManager rm;
private PointLight light;
public void addRequest(PreviewRequest request) { public void addRequest(PreviewRequest request) {
previewQueue.add(request); previewQueue.add(request);
} }
private void update(float tpf) { private void update(float tpf) {
previewNode.updateLogicalState(tpf); previewNode.updateLogicalState(tpf);
previewNode.updateGeometricState(); previewNode.updateGeometricState();
} }
public void setupPreviewView() { public void setupPreviewView() {
offCamera = new Camera(width, height); offCamera = new Camera(width, height);
@ -103,7 +104,7 @@ public class ScenePreviewProcessor implements SceneProcessor {
offView.setOutputFrameBuffer(offBuffer); offView.setOutputFrameBuffer(offBuffer);
// setup framebuffer's scene // setup framebuffer's scene
PointLight light = new PointLight(); light = new PointLight();
light.setPosition(offCamera.getLocation()); light.setPosition(offCamera.getLocation());
light.setColor(ColorRGBA.White); light.setColor(ColorRGBA.White);
previewNode.addLight(light); previewNode.addLight(light);
@ -111,29 +112,39 @@ public class ScenePreviewProcessor implements SceneProcessor {
// attach the scene to the viewport to be rendered // attach the scene to the viewport to be rendered
offView.attachScene(previewNode); offView.attachScene(previewNode);
} }
public void initialize(RenderManager rm, ViewPort vp) { public void initialize(RenderManager rm, ViewPort vp) {
this.rm = rm; this.rm = rm;
} }
public void reshape(ViewPort vp, int i, int i1) { public void reshape(ViewPort vp, int i, int i1) {
} }
public boolean isInitialized() { public boolean isInitialized() {
return true; return true;
} }
public void preFrame(float f) { public void preFrame(float f) {
currentPreviewRequest = previewQueue.poll(); currentPreviewRequest = previewQueue.poll();
if (currentPreviewRequest != null) { if (currentPreviewRequest != null) {
previewNode.attachChild(currentPreviewRequest.getSpatial()); previewNode.attachChild(currentPreviewRequest.getSpatial());
if (currentPreviewRequest.getCameraRequest().location != null) {
offCamera.setLocation(currentPreviewRequest.getCameraRequest().location);
light.setPosition(currentPreviewRequest.getCameraRequest().location);
}
if (currentPreviewRequest.getCameraRequest().rotation != null) {
offCamera.setRotation(currentPreviewRequest.getCameraRequest().rotation);
}
if (currentPreviewRequest.getCameraRequest().lookAt != null) {
offCamera.lookAt(currentPreviewRequest.getCameraRequest().lookAt, currentPreviewRequest.getCameraRequest().up);
}
} }
update(f); update(f);
} }
public void postQueue(RenderQueue rq) { public void postQueue(RenderQueue rq) {
} }
public void postFrame(FrameBuffer fb) { public void postFrame(FrameBuffer fb) {
if (currentPreviewRequest != null) { if (currentPreviewRequest != null) {
cpuBuf.clear(); cpuBuf.clear();
@ -150,26 +161,26 @@ public class ScenePreviewProcessor implements SceneProcessor {
byte g = cpuArray[i + 1]; byte g = cpuArray[i + 1];
byte r = cpuArray[i + 2]; byte r = cpuArray[i + 2];
byte a = cpuArray[i + 3]; byte a = cpuArray[i + 3];
cpuArray[i + 0] = a; cpuArray[i + 0] = a;
cpuArray[i + 1] = b; cpuArray[i + 1] = b;
cpuArray[i + 2] = g; cpuArray[i + 2] = g;
cpuArray[i + 3] = r; cpuArray[i + 3] = r;
} }
BufferedImage image = new BufferedImage(width, height, BufferedImage image = new BufferedImage(width, height,
BufferedImage.TYPE_4BYTE_ABGR); BufferedImage.TYPE_4BYTE_ABGR);
WritableRaster wr = image.getRaster(); WritableRaster wr = image.getRaster();
DataBufferByte db = (DataBufferByte) wr.getDataBuffer(); DataBufferByte db = (DataBufferByte) wr.getDataBuffer();
System.arraycopy(cpuArray, 0, db.getData(), 0, cpuArray.length); System.arraycopy(cpuArray, 0, db.getData(), 0, cpuArray.length);
currentPreviewRequest.setImage(image); currentPreviewRequest.setImage(image);
previewNode.detachAllChildren(); previewNode.detachAllChildren();
SceneApplication.getApplication().notifySceneListeners(currentPreviewRequest); SceneApplication.getApplication().notifySceneListeners(currentPreviewRequest);
currentPreviewRequest = null; currentPreviewRequest = null;
} }
} }
public void cleanup() { public void cleanup() {
} }
} }

@ -149,7 +149,7 @@ public class JmeParticleEmitter extends JmeGeometry {
} }
private Property createButtonProperty() { private Property createButtonProperty() {
return new PropertySupport.ReadWrite("emit", Object.class, "Emit all particles", "Click here to emit all particles of this emitter ") { return new PropertySupport.ReadWrite<Object>("emit", Object.class, "Emit all particles", "Click here to emit all particles of this emitter ") {
JmeParticleEmitterButtonProperty pe; JmeParticleEmitterButtonProperty pe;

@ -116,10 +116,10 @@ public class NewSpatialPopup extends AbstractAction implements Presenter.Popup {
public Void call() throws Exception { public Void call() throws Exception {
ParticleEmitter emit = new ParticleEmitter("Emitter", ParticleMesh.Type.Triangle, 200); ParticleEmitter emit = new ParticleEmitter("Emitter", ParticleMesh.Type.Triangle, 200);
emit.setShape(new EmitterSphereShape(Vector3f.ZERO, 1f)); emit.setShape(new EmitterSphereShape(Vector3f.ZERO, 1f));
emit.setGravity(0); emit.setGravity(new Vector3f(0, 0, 0));
emit.setLowLife(5); emit.setLowLife(5);
emit.setHighLife(10); emit.setHighLife(10);
emit.setInitialVelocity(new Vector3f(0, 0, 0)); emit.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 0, 0));
emit.setImagesX(15); emit.setImagesX(15);
Material mat = new Material(SceneApplication.getApplication().getAssetManager(), "Common/MatDefs/Misc/Particle.j3md"); Material mat = new Material(SceneApplication.getApplication().getAssetManager(), "Common/MatDefs/Misc/Particle.j3md");
emit.setMaterial(mat); emit.setMaterial(mat);

Loading…
Cancel
Save