فهرست منبع

SDK:
- cleanup OffScreenPanel lifecycle

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10182 75d07b2b-3a1a-0410-a2c5-0572b91ccdca

nor..67 12 سال پیش
والد
کامیت
e8c64ace59

+ 1 - 1
jme3-core/src/com/jme3/gde/core/scene/OffScenePanel.form

@@ -1,4 +1,4 @@
-<?xml version="1.1" encoding="UTF-8" ?>
+<?xml version="1.0" encoding="UTF-8" ?>
 
 <Form version="1.4" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
   <Events>

+ 12 - 8
jme3-core/src/com/jme3/gde/core/scene/OffScenePanel.java

@@ -73,7 +73,7 @@ public class OffScenePanel extends javax.swing.JPanel implements SceneProcessor
     private int width = 640, height = 480;
     private ByteBuffer cpuBuf;
 //    private byte[] cpuArray;
-    private Node rootNode = new Node("Root Node");
+    private final Node rootNode = new Node("Root Node");
     private FrameBuffer offBuffer;
     private ViewPort viewPort;
     private Camera camera;
@@ -98,6 +98,7 @@ public class OffScenePanel extends javax.swing.JPanel implements SceneProcessor
         this.width = width;
         this.height = height;
         initComponents();
+        setupScene();
     }
 
     public void resizeGLView(final int x, final int y) {
@@ -138,7 +139,7 @@ public class OffScenePanel extends javax.swing.JPanel implements SceneProcessor
             public Object call() throws Exception {
                 setupOffView();
                 setupOffBuffer();
-                setupScene();
+                attachScene();
                 return null;
             }
         });
@@ -157,17 +158,20 @@ public class OffScenePanel extends javax.swing.JPanel implements SceneProcessor
     }
 
     private void setupScene() {
-        //setup framebuffer's cam
-        camera.setFrustumPerspective(45f, 1f, 1f, 1000f);
-        camera.setLocation(new Vector3f(5f, 5f, 5f));
-        camera.lookAt(new Vector3f(0f, 0f, 0f), Vector3f.UNIT_Y);
-
         // setup framebuffer's scene
         light = new PointLight();
-        light.setPosition(camera.getLocation());
         light.setColor(ColorRGBA.White);
         rootNode.addLight(light);
+    }
+    
+    private void attachScene() {
         // attach the scene to the viewport to be rendered
+        //setup framebuffer's cam
+        light.setPosition(camera.getLocation());
+        camera.setFrustumPerspective(45f, 1f, 1f, 1000f);
+        camera.setLocation(new Vector3f(5f, 5f, 5f));
+        camera.lookAt(new Vector3f(0f, 0f, 0f), Vector3f.UNIT_Y);
+
         viewPort.attachScene(rootNode);
     }