|
@@ -43,6 +43,7 @@ import com.jme3.math.FastMath;
|
|
import com.jme3.math.Quaternion;
|
|
import com.jme3.math.Quaternion;
|
|
import com.jme3.math.Vector3f;
|
|
import com.jme3.math.Vector3f;
|
|
import com.jme3.post.SceneProcessor;
|
|
import com.jme3.post.SceneProcessor;
|
|
|
|
+import com.jme3.profile.AppProfiler;
|
|
import com.jme3.renderer.Camera;
|
|
import com.jme3.renderer.Camera;
|
|
import com.jme3.renderer.RenderManager;
|
|
import com.jme3.renderer.RenderManager;
|
|
import com.jme3.renderer.ViewPort;
|
|
import com.jme3.renderer.ViewPort;
|
|
@@ -106,6 +107,7 @@ public class OffScenePanel extends javax.swing.JPanel implements SceneProcessor
|
|
|
|
|
|
public void resizeGLView(final int x, final int y) {
|
|
public void resizeGLView(final int x, final int y) {
|
|
SceneApplication.getApplication().enqueue(new Callable<Object>() {
|
|
SceneApplication.getApplication().enqueue(new Callable<Object>() {
|
|
|
|
+ @Override
|
|
public Object call() throws Exception {
|
|
public Object call() throws Exception {
|
|
width = x;
|
|
width = x;
|
|
height = y;
|
|
height = y;
|
|
@@ -118,6 +120,7 @@ public class OffScenePanel extends javax.swing.JPanel implements SceneProcessor
|
|
}
|
|
}
|
|
});
|
|
});
|
|
java.awt.EventQueue.invokeLater(new Runnable() {
|
|
java.awt.EventQueue.invokeLater(new Runnable() {
|
|
|
|
+ @Override
|
|
public void run() {
|
|
public void run() {
|
|
Dimension dim = new Dimension(x, y);
|
|
Dimension dim = new Dimension(x, y);
|
|
setPreferredSize(dim);
|
|
setPreferredSize(dim);
|
|
@@ -136,6 +139,7 @@ public class OffScenePanel extends javax.swing.JPanel implements SceneProcessor
|
|
// }
|
|
// }
|
|
// });
|
|
// });
|
|
SceneApplication.getApplication().enqueue(new Callable<Object>() {
|
|
SceneApplication.getApplication().enqueue(new Callable<Object>() {
|
|
|
|
+ @Override
|
|
public Object call() throws Exception {
|
|
public Object call() throws Exception {
|
|
setupOffView();
|
|
setupOffView();
|
|
setupOffBuffer();
|
|
setupOffBuffer();
|
|
@@ -148,6 +152,7 @@ public class OffScenePanel extends javax.swing.JPanel implements SceneProcessor
|
|
public void stopPreview() {
|
|
public void stopPreview() {
|
|
//TODO add your handling code here:
|
|
//TODO add your handling code here:
|
|
SceneApplication.getApplication().enqueue(new Callable<Object>() {
|
|
SceneApplication.getApplication().enqueue(new Callable<Object>() {
|
|
|
|
+ @Override
|
|
public Object call() throws Exception {
|
|
public Object call() throws Exception {
|
|
SceneApplication.getApplication().getRenderManager().removePreView(viewPort);
|
|
SceneApplication.getApplication().getRenderManager().removePreView(viewPort);
|
|
return null;
|
|
return null;
|
|
@@ -197,26 +202,33 @@ public class OffScenePanel extends javax.swing.JPanel implements SceneProcessor
|
|
viewPort.addProcessor(this);
|
|
viewPort.addProcessor(this);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
public void initialize(RenderManager rm, ViewPort vp) {
|
|
public void initialize(RenderManager rm, ViewPort vp) {
|
|
this.rm = rm;
|
|
this.rm = rm;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
public void reshape(ViewPort vp, int i, int i1) {
|
|
public void reshape(ViewPort vp, int i, int i1) {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
public boolean isInitialized() {
|
|
public boolean isInitialized() {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
public void preFrame(float f) {
|
|
public void preFrame(float f) {
|
|
light.setPosition(camera.getLocation());
|
|
light.setPosition(camera.getLocation());
|
|
rootNode.updateLogicalState(f);
|
|
rootNode.updateLogicalState(f);
|
|
rootNode.updateGeometricState();
|
|
rootNode.updateGeometricState();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ @Override
|
|
public void postQueue(RenderQueue rq) {
|
|
public void postQueue(RenderQueue rq) {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
public void postFrame(FrameBuffer fb) {
|
|
public void postFrame(FrameBuffer fb) {
|
|
// cpuBuf.clear();
|
|
// cpuBuf.clear();
|
|
SceneApplication.getApplication().getRenderer().readFrameBufferWithFormat(offBuffer, cpuBuf,Format.BGRA8);
|
|
SceneApplication.getApplication().getRenderer().readFrameBufferWithFormat(offBuffer, cpuBuf,Format.BGRA8);
|
|
@@ -247,7 +259,13 @@ public class OffScenePanel extends javax.swing.JPanel implements SceneProcessor
|
|
}
|
|
}
|
|
repaint();
|
|
repaint();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void setProfiler(AppProfiler profiler) {
|
|
|
|
+ /* We don't support profiling yet */
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ @Override
|
|
public void cleanup() {
|
|
public void cleanup() {
|
|
}
|
|
}
|
|
|
|
|
|
@@ -299,6 +317,7 @@ public class OffScenePanel extends javax.swing.JPanel implements SceneProcessor
|
|
*/
|
|
*/
|
|
public void detach(final Spatial spat) {
|
|
public void detach(final Spatial spat) {
|
|
SceneApplication.getApplication().enqueue(new Callable<Object>() {
|
|
SceneApplication.getApplication().enqueue(new Callable<Object>() {
|
|
|
|
+ @Override
|
|
public Object call() throws Exception {
|
|
public Object call() throws Exception {
|
|
rootNode.detachChild(spat);
|
|
rootNode.detachChild(spat);
|
|
return null;
|
|
return null;
|
|
@@ -309,10 +328,10 @@ public class OffScenePanel extends javax.swing.JPanel implements SceneProcessor
|
|
/**
|
|
/**
|
|
* threadsafe detach from root node
|
|
* threadsafe detach from root node
|
|
*
|
|
*
|
|
- * @param spat
|
|
|
|
*/
|
|
*/
|
|
public void detachAll() {
|
|
public void detachAll() {
|
|
SceneApplication.getApplication().enqueue(new Callable<Object>() {
|
|
SceneApplication.getApplication().enqueue(new Callable<Object>() {
|
|
|
|
+ @Override
|
|
public Object call() throws Exception {
|
|
public Object call() throws Exception {
|
|
rootNode.detachAllChildren();
|
|
rootNode.detachAllChildren();
|
|
return null;
|
|
return null;
|
|
@@ -322,6 +341,7 @@ public class OffScenePanel extends javax.swing.JPanel implements SceneProcessor
|
|
|
|
|
|
public void setCamFocus(final Vector3f focus) {
|
|
public void setCamFocus(final Vector3f focus) {
|
|
SceneApplication.getApplication().enqueue(new Callable<Object>() {
|
|
SceneApplication.getApplication().enqueue(new Callable<Object>() {
|
|
|
|
+ @Override
|
|
public Object call() throws Exception {
|
|
public Object call() throws Exception {
|
|
doSetCamFocus(focus);
|
|
doSetCamFocus(focus);
|
|
return null;
|
|
return null;
|
|
@@ -332,6 +352,7 @@ public class OffScenePanel extends javax.swing.JPanel implements SceneProcessor
|
|
|
|
|
|
public void doSetCamFocus(final Vector3f focus_) {
|
|
public void doSetCamFocus(final Vector3f focus_) {
|
|
SceneApplication.getApplication().enqueue(new Callable<Object>() {
|
|
SceneApplication.getApplication().enqueue(new Callable<Object>() {
|
|
|
|
+ @Override
|
|
public Object call() throws Exception {
|
|
public Object call() throws Exception {
|
|
focus.set(focus_);
|
|
focus.set(focus_);
|
|
camera.setLocation(focus_.add(vector, camera.getLocation()));
|
|
camera.setLocation(focus_.add(vector, camera.getLocation()));
|
|
@@ -345,6 +366,7 @@ public class OffScenePanel extends javax.swing.JPanel implements SceneProcessor
|
|
*/
|
|
*/
|
|
public void rotateCamera(final Vector3f axis, final float amount_) {
|
|
public void rotateCamera(final Vector3f axis, final float amount_) {
|
|
SceneApplication.getApplication().enqueue(new Callable<Object>() {
|
|
SceneApplication.getApplication().enqueue(new Callable<Object>() {
|
|
|
|
+ @Override
|
|
public Object call() throws Exception {
|
|
public Object call() throws Exception {
|
|
float amount = amount_;
|
|
float amount = amount_;
|
|
if (axis.equals(camera.getLeft())) {
|
|
if (axis.equals(camera.getLeft())) {
|
|
@@ -367,6 +389,7 @@ public class OffScenePanel extends javax.swing.JPanel implements SceneProcessor
|
|
|
|
|
|
public void panCamera(final float left, final float up) {
|
|
public void panCamera(final float left, final float up) {
|
|
SceneApplication.getApplication().enqueue(new Callable<Object>() {
|
|
SceneApplication.getApplication().enqueue(new Callable<Object>() {
|
|
|
|
+ @Override
|
|
public Object call() throws Exception {
|
|
public Object call() throws Exception {
|
|
camera.getLeft().mult(left, vector);
|
|
camera.getLeft().mult(left, vector);
|
|
vector.scaleAdd(up, camera.getUp(), vector);
|
|
vector.scaleAdd(up, camera.getUp(), vector);
|
|
@@ -380,6 +403,7 @@ public class OffScenePanel extends javax.swing.JPanel implements SceneProcessor
|
|
|
|
|
|
public void moveCamera(final float forward) {
|
|
public void moveCamera(final float forward) {
|
|
SceneApplication.getApplication().enqueue(new Callable<Object>() {
|
|
SceneApplication.getApplication().enqueue(new Callable<Object>() {
|
|
|
|
+ @Override
|
|
public Object call() throws Exception {
|
|
public Object call() throws Exception {
|
|
camera.getDirection().mult(forward, vector);
|
|
camera.getDirection().mult(forward, vector);
|
|
camera.setLocation(camera.getLocation().add(vector));
|
|
camera.setLocation(camera.getLocation().add(vector));
|
|
@@ -390,6 +414,7 @@ public class OffScenePanel extends javax.swing.JPanel implements SceneProcessor
|
|
|
|
|
|
public void zoomCamera(final float amount_) {
|
|
public void zoomCamera(final float amount_) {
|
|
SceneApplication.getApplication().enqueue(new Callable<Object>() {
|
|
SceneApplication.getApplication().enqueue(new Callable<Object>() {
|
|
|
|
+ @Override
|
|
public Object call() throws Exception {
|
|
public Object call() throws Exception {
|
|
float amount = amount_;
|
|
float amount = amount_;
|
|
amount = camera.getLocation().distance(focus) * amount;
|
|
amount = camera.getLocation().distance(focus) * amount;
|