diff --git a/sdk/jme3-core/src/com/jme3/gde/core/properties/TextureBrowser.java b/sdk/jme3-core/src/com/jme3/gde/core/properties/TextureBrowser.java index c1c404eab..7abf8c5fc 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/properties/TextureBrowser.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/properties/TextureBrowser.java @@ -44,7 +44,6 @@ import javax.swing.Icon; import javax.swing.ImageIcon; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; -import javax.swing.text.Position.Bias; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.TreeNode; import javax.swing.tree.TreePath; @@ -75,7 +74,7 @@ public class TextureBrowser extends javax.swing.JDialog implements TreeSelection initComponents(); loadAvailableTextures(); setSelectedTexture((Texture) editor.getValue()); - setLocationRelativeTo(null); + setLocationRelativeTo(null); } /** 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) { if (texture != null) { Logger.getLogger(TextureBrowser.class.getName()).finer("Looking for Texture: " + texture.getName()); - System.out.println("texture : " + texture.getName()); String[] path = ("/" + texture.getName()).split("/"); TreePath parent = new TreePath((TreeNode) jTree1.getModel().getRoot()); jTree1.expandPath(TreeUtil.buildTreePath(jTree1, parent, path, 0, true)); diff --git a/sdk/jme3-core/src/com/jme3/gde/core/scene/PreviewRequest.java b/sdk/jme3-core/src/com/jme3/gde/core/scene/PreviewRequest.java index 36fc2fb36..ef221f1cf 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/scene/PreviewRequest.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/scene/PreviewRequest.java @@ -29,9 +29,11 @@ * 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.scene; +import com.jme3.math.Quaternion; +import com.jme3.math.Vector3f; +import com.jme3.renderer.Camera; import com.jme3.scene.Spatial; import java.awt.image.BufferedImage; @@ -40,13 +42,16 @@ import java.awt.image.BufferedImage; * @author normenhansen */ public class PreviewRequest { + private Object requester; private Spatial spatial; private BufferedImage image; + private CameraRequest cameraRequest; public PreviewRequest(Object requester, Spatial spatial) { this.requester = requester; this.spatial = spatial; + cameraRequest = new CameraRequest(); } /** @@ -77,4 +82,28 @@ public class PreviewRequest { 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; + } + } } diff --git a/sdk/jme3-core/src/com/jme3/gde/core/scene/ScenePreviewProcessor.java b/sdk/jme3-core/src/com/jme3/gde/core/scene/ScenePreviewProcessor.java index 66147af12..5fdea66d1 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/scene/ScenePreviewProcessor.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/scene/ScenePreviewProcessor.java @@ -55,7 +55,7 @@ import java.util.concurrent.ConcurrentLinkedQueue; * @author normenhansen */ public class ScenePreviewProcessor implements SceneProcessor { - + private static final int width = 120, height = 120; private final ByteBuffer cpuBuf = BufferUtils.createByteBuffer(width * height * 4); private final byte[] cpuArray = new byte[width * height * 4]; @@ -67,16 +67,17 @@ public class ScenePreviewProcessor implements SceneProcessor { private ConcurrentLinkedQueue previewQueue = new ConcurrentLinkedQueue(); private PreviewRequest currentPreviewRequest; private RenderManager rm; - + private PointLight light; + public void addRequest(PreviewRequest request) { previewQueue.add(request); } - + private void update(float tpf) { previewNode.updateLogicalState(tpf); previewNode.updateGeometricState(); } - + public void setupPreviewView() { offCamera = new Camera(width, height); @@ -103,7 +104,7 @@ public class ScenePreviewProcessor implements SceneProcessor { offView.setOutputFrameBuffer(offBuffer); // setup framebuffer's scene - PointLight light = new PointLight(); + light = new PointLight(); light.setPosition(offCamera.getLocation()); light.setColor(ColorRGBA.White); previewNode.addLight(light); @@ -111,29 +112,39 @@ public class ScenePreviewProcessor implements SceneProcessor { // attach the scene to the viewport to be rendered offView.attachScene(previewNode); } - + public void initialize(RenderManager rm, ViewPort vp) { this.rm = rm; } - + public void reshape(ViewPort vp, int i, int i1) { } - + public boolean isInitialized() { return true; } - + public void preFrame(float f) { currentPreviewRequest = previewQueue.poll(); if (currentPreviewRequest != null) { 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); } - + public void postQueue(RenderQueue rq) { } - + public void postFrame(FrameBuffer fb) { if (currentPreviewRequest != null) { cpuBuf.clear(); @@ -150,26 +161,26 @@ public class ScenePreviewProcessor implements SceneProcessor { byte g = cpuArray[i + 1]; byte r = cpuArray[i + 2]; byte a = cpuArray[i + 3]; - + cpuArray[i + 0] = a; cpuArray[i + 1] = b; cpuArray[i + 2] = g; cpuArray[i + 3] = r; } - + BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR); WritableRaster wr = image.getRaster(); DataBufferByte db = (DataBufferByte) wr.getDataBuffer(); System.arraycopy(cpuArray, 0, db.getData(), 0, cpuArray.length); - + currentPreviewRequest.setImage(image); previewNode.detachAllChildren(); SceneApplication.getApplication().notifySceneListeners(currentPreviewRequest); currentPreviewRequest = null; } } - + public void cleanup() { } } diff --git a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/JmeParticleEmitter.java b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/JmeParticleEmitter.java index 647500aaf..84135d737 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/JmeParticleEmitter.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/JmeParticleEmitter.java @@ -149,7 +149,7 @@ public class JmeParticleEmitter extends JmeGeometry { } 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("emit", Object.class, "Emit all particles", "Click here to emit all particles of this emitter ") { JmeParticleEmitterButtonProperty pe; diff --git a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/NewSpatialPopup.java b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/NewSpatialPopup.java index c8761e1fa..2b9f8e6f7 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/NewSpatialPopup.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/NewSpatialPopup.java @@ -116,10 +116,10 @@ public class NewSpatialPopup extends AbstractAction implements Presenter.Popup { public Void call() throws Exception { ParticleEmitter emit = new ParticleEmitter("Emitter", ParticleMesh.Type.Triangle, 200); emit.setShape(new EmitterSphereShape(Vector3f.ZERO, 1f)); - emit.setGravity(0); + emit.setGravity(new Vector3f(0, 0, 0)); emit.setLowLife(5); emit.setHighLife(10); - emit.setInitialVelocity(new Vector3f(0, 0, 0)); + emit.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 0, 0)); emit.setImagesX(15); Material mat = new Material(SceneApplication.getApplication().getAssetManager(), "Common/MatDefs/Misc/Particle.j3md"); emit.setMaterial(mat);