• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Main repository of MikuMikuStudio


コミットメタ情報

リビジョンcf33becd9e3950bd1b7b8d22ae6b4d94ec3ac0c0 (tree)
日時2013-07-07 07:14:41
作者kobayasi <kobayasi@pscn...>
コミッターkobayasi

ログメッセージ

merge from jme10694

変更サマリ

差分

--- a/engine/src/core/com/jme3/cinematic/Cinematic.java
+++ b/engine/src/core/com/jme3/cinematic/Cinematic.java
@@ -47,6 +47,7 @@ import com.jme3.renderer.Camera;
4747 import com.jme3.renderer.RenderManager;
4848 import com.jme3.scene.CameraNode;
4949 import com.jme3.scene.Node;
50+import com.jme3.scene.control.CameraControl;
5051 import com.jme3.scene.control.CameraControl.ControlDirection;
5152 import de.lessvoid.nifty.Nifty;
5253 import java.io.IOException;
@@ -277,7 +278,7 @@ public class Cinematic extends AbstractCinematicEvent implements AppState {
277278 public CameraNode bindCamera(String cameraName, Camera cam) {
278279 CameraNode node = new CameraNode(cameraName, cam);
279280 node.setControlDir(ControlDirection.SpatialToCamera);
280- node.getControl(0).setEnabled(false);
281+ node.getControl(CameraControl.class).setEnabled(false);
281282 cameras.put(cameraName, node);
282283 scene.attachChild(node);
283284 return node;
@@ -289,7 +290,7 @@ public class Cinematic extends AbstractCinematicEvent implements AppState {
289290
290291 private void enableCurrentCam(boolean enabled) {
291292 if (currentCam != null) {
292- currentCam.getControl(0).setEnabled(enabled);
293+ currentCam.getControl(CameraControl.class).setEnabled(enabled);
293294 }
294295 }
295296
--- a/engine/src/core/com/jme3/scene/control/AbstractControl.java
+++ b/engine/src/core/com/jme3/scene/control/AbstractControl.java
@@ -1,5 +1,5 @@
11 /*
2- * Copyright (c) 2009-2010 jMonkeyEngine
2+ * Copyright (c) 2009-2012 jMonkeyEngine
33 * All rights reserved.
44 *
55 * Redistribution and use in source and binary forms, with or without
@@ -29,12 +29,11 @@
2929 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
3030 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3131 */
32-
3332 package com.jme3.scene.control;
3433
34+import com.jme3.export.InputCapsule;
3535 import com.jme3.export.JmeExporter;
3636 import com.jme3.export.JmeImporter;
37-import com.jme3.export.InputCapsule;
3837 import com.jme3.export.OutputCapsule;
3938 import com.jme3.renderer.RenderManager;
4039 import com.jme3.renderer.ViewPort;
@@ -55,7 +54,7 @@ public abstract class AbstractControl implements Control {
5554 }
5655
5756 public void setSpatial(Spatial spatial) {
58- if (this.spatial != null && spatial != null) {
57+ if (this.spatial != null && spatial != null && spatial != this.spatial) {
5958 throw new IllegalStateException("This control has already been added to a Spatial");
6059 }
6160 this.spatial = spatial;
@@ -83,6 +82,29 @@ public abstract class AbstractControl implements Control {
8382 */
8483 protected abstract void controlRender(RenderManager rm, ViewPort vp);
8584
85+ /**
86+ * Default implementation of cloneForSpatial() that
87+ * simply clones the control and sets the spatial.
88+ * <pre>
89+ * AbstractControl c = clone();
90+ * c.spatial = null;
91+ * c.setSpatial(spatial);
92+ * </pre>
93+ *
94+ * Controls that wish to be persisted must be Cloneable.
95+ */
96+ @Override
97+ public Control cloneForSpatial(Spatial spatial) {
98+ try {
99+ AbstractControl c = (AbstractControl)clone();
100+ c.spatial = null; // to keep setSpatial() from throwing an exception
101+ c.setSpatial(spatial);
102+ return c;
103+ } catch(CloneNotSupportedException e) {
104+ throw new RuntimeException( "Can't clone control for spatial", e );
105+ }
106+ }
107+
86108 public void update(float tpf) {
87109 if (!enabled)
88110 return;
--- a/engine/src/core/com/jme3/scene/control/AreaUtils.java
+++ b/engine/src/core/com/jme3/scene/control/AreaUtils.java
@@ -1,5 +1,5 @@
11 /*
2- * Copyright (c) 2009-2010 jMonkeyEngine
2+ * Copyright (c) 2009-2012 jMonkeyEngine
33 * All rights reserved.
44 *
55 * Redistribution and use in source and binary forms, with or without
@@ -29,7 +29,6 @@
2929 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
3030 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3131 */
32-
3332 package com.jme3.scene.control;
3433
3534 import com.jme3.bounding.BoundingBox;
--- a/engine/src/core/com/jme3/scene/control/BillboardControl.java
+++ b/engine/src/core/com/jme3/scene/control/BillboardControl.java
@@ -1,5 +1,5 @@
11 /*
2- * Copyright (c) 2009-2010 jMonkeyEngine
2+ * Copyright (c) 2009-2012 jMonkeyEngine
33 * All rights reserved.
44 *
55 * Redistribution and use in source and binary forms, with or without
@@ -29,11 +29,8 @@
2929 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
3030 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3131 */
32-
3332 package com.jme3.scene.control;
3433
35-import java.io.IOException;
36-
3734 import com.jme3.export.InputCapsule;
3835 import com.jme3.export.JmeExporter;
3936 import com.jme3.export.JmeImporter;
@@ -47,6 +44,7 @@ import com.jme3.renderer.RenderManager;
4744 import com.jme3.renderer.ViewPort;
4845 import com.jme3.scene.Node;
4946 import com.jme3.scene.Spatial;
47+import java.io.IOException;
5048
5149 public class BillboardControl extends AbstractControl {
5250
--- a/engine/src/core/com/jme3/scene/control/CameraControl.java
+++ b/engine/src/core/com/jme3/scene/control/CameraControl.java
@@ -1,5 +1,5 @@
11 /*
2- * Copyright (c) 2009-2010 jMonkeyEngine
2+ * Copyright (c) 2009-2012 jMonkeyEngine
33 * All rights reserved.
44 *
55 * Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,10 @@
3131 */
3232 package com.jme3.scene.control;
3333
34+import com.jme3.export.InputCapsule;
3435 import com.jme3.export.JmeExporter;
3536 import com.jme3.export.JmeImporter;
37+import com.jme3.export.OutputCapsule;
3638 import com.jme3.math.Quaternion;
3739 import com.jme3.math.Vector3f;
3840 import com.jme3.renderer.Camera;
@@ -64,7 +66,7 @@ public class CameraControl extends AbstractControl {
6466 SpatialToCamera;
6567 }
6668 private Camera camera;
67- private ControlDirection controlDir = ControlDirection.CameraToSpatial;
69+ private ControlDirection controlDir = ControlDirection.SpatialToCamera;
6870
6971 /**
7072 * Constructor used for Serialization.
@@ -142,18 +144,21 @@ public class CameraControl extends AbstractControl {
142144 return control;
143145 }
144146 private static final String CONTROL_DIR_NAME = "controlDir";
145-
147+ private static final String CAMERA_NAME = "camera";
148+
146149 @Override
147150 public void read(JmeImporter im) throws IOException {
148151 super.read(im);
149- im.getCapsule(this).readEnum(CONTROL_DIR_NAME,
150- ControlDirection.class, ControlDirection.SpatialToCamera);
152+ InputCapsule ic = im.getCapsule(this);
153+ controlDir = ic.readEnum(CONTROL_DIR_NAME, ControlDirection.class, ControlDirection.SpatialToCamera);
154+ camera = (Camera)ic.readSavable(CAMERA_NAME, null);
151155 }
152156
153157 @Override
154158 public void write(JmeExporter ex) throws IOException {
155159 super.write(ex);
156- ex.getCapsule(this).write(controlDir, CONTROL_DIR_NAME,
157- ControlDirection.SpatialToCamera);
160+ OutputCapsule oc = ex.getCapsule(this);
161+ oc.write(controlDir, CONTROL_DIR_NAME, ControlDirection.SpatialToCamera);
162+ oc.write(camera, CAMERA_NAME, null);
158163 }
159164 }
\ No newline at end of file
--- a/engine/src/core/com/jme3/scene/control/Control.java
+++ b/engine/src/core/com/jme3/scene/control/Control.java
@@ -1,5 +1,5 @@
11 /*
2- * Copyright (c) 2009-2010 jMonkeyEngine
2+ * Copyright (c) 2009-2012 jMonkeyEngine
33 * All rights reserved.
44 *
55 * Redistribution and use in source and binary forms, with or without
@@ -29,7 +29,6 @@
2929 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
3030 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3131 */
32-
3332 package com.jme3.scene.control;
3433
3534 import com.jme3.export.Savable;
@@ -62,18 +61,6 @@ public interface Control extends Savable {
6261 public void setSpatial(Spatial spatial);
6362
6463 /**
65- * @param enabled Enable or disable the control. If disabled, update()
66- * should do nothing.
67- */
68- public void setEnabled(boolean enabled);
69-
70- /**
71- * @return True if enabled, false otherwise.
72- * @see Control#setEnabled(boolean)
73- */
74- public boolean isEnabled();
75-
76- /**
7764 * Updates the control. This should not be called from user code.
7865 * @param tpf Time per frame.
7966 */
--- a/engine/src/core/com/jme3/scene/control/LightControl.java
+++ b/engine/src/core/com/jme3/scene/control/LightControl.java
@@ -1,5 +1,5 @@
11 /*
2- * Copyright (c) 2009-2010 jMonkeyEngine
2+ * Copyright (c) 2009-2012 jMonkeyEngine
33 * All rights reserved.
44 *
55 * Redistribution and use in source and binary forms, with or without
@@ -31,14 +31,15 @@
3131 */
3232 package com.jme3.scene.control;
3333
34+import com.jme3.export.InputCapsule;
3435 import com.jme3.export.JmeExporter;
3536 import com.jme3.export.JmeImporter;
37+import com.jme3.export.OutputCapsule;
3638 import com.jme3.light.DirectionalLight;
3739 import com.jme3.light.Light;
3840 import com.jme3.light.PointLight;
39-import com.jme3.math.Quaternion;
41+import com.jme3.light.SpotLight;
4042 import com.jme3.math.Vector3f;
41-import com.jme3.renderer.Camera;
4243 import com.jme3.renderer.RenderManager;
4344 import com.jme3.renderer.ViewPort;
4445 import com.jme3.scene.Spatial;
@@ -130,12 +131,12 @@ public class LightControl extends AbstractControl {
130131 if (light instanceof DirectionalLight) {
131132 ((DirectionalLight) light).setDirection(vars.vect1.set(spatial.getWorldTranslation()).multLocal(-1.0f));
132133 }
134+
135+ if (light instanceof SpotLight) {
136+ ((SpotLight) light).setPosition(spatial.getWorldTranslation());
137+ ((SpotLight) light).setDirection(spatial.getWorldRotation().multLocal(vars.vect1.set(Vector3f.UNIT_Y).multLocal(-1)));
138+ }
133139 vars.release();
134- //TODO add code for Spot light here when it's done
135-// if( light instanceof SpotLight){
136-// ((SpotLight)light).setPosition(spatial.getWorldTranslation());
137-// ((SpotLight)light).setRotation(spatial.getWorldRotation());
138-// }
139140
140141 }
141142
@@ -174,18 +175,21 @@ public class LightControl extends AbstractControl {
174175 return control;
175176 }
176177 private static final String CONTROL_DIR_NAME = "controlDir";
177-
178+ private static final String LIGHT_NAME = "light";
179+
178180 @Override
179181 public void read(JmeImporter im) throws IOException {
180182 super.read(im);
181- im.getCapsule(this).readEnum(CONTROL_DIR_NAME,
182- ControlDirection.class, ControlDirection.SpatialToLight);
183+ InputCapsule ic = im.getCapsule(this);
184+ controlDir = ic.readEnum(CONTROL_DIR_NAME, ControlDirection.class, ControlDirection.SpatialToLight);
185+ light = (Light)ic.readSavable(LIGHT_NAME, null);
183186 }
184187
185188 @Override
186189 public void write(JmeExporter ex) throws IOException {
187190 super.write(ex);
188- ex.getCapsule(this).write(controlDir, CONTROL_DIR_NAME,
189- ControlDirection.SpatialToLight);
191+ OutputCapsule oc = ex.getCapsule(this);
192+ oc.write(controlDir, CONTROL_DIR_NAME, ControlDirection.SpatialToLight);
193+ oc.write(light, LIGHT_NAME, null);
190194 }
191195 }
\ No newline at end of file
--- a/engine/src/core/com/jme3/scene/control/LodControl.java
+++ b/engine/src/core/com/jme3/scene/control/LodControl.java
@@ -1,5 +1,5 @@
11 /*
2- * Copyright (c) 2009-2010 jMonkeyEngine
2+ * Copyright (c) 2009-2012 jMonkeyEngine
33 * All rights reserved.
44 *
55 * Redistribution and use in source and binary forms, with or without
@@ -29,13 +29,12 @@
2929 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
3030 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3131 */
32-
3332 package com.jme3.scene.control;
3433
3534 import com.jme3.bounding.BoundingVolume;
35+import com.jme3.export.InputCapsule;
3636 import com.jme3.export.JmeExporter;
3737 import com.jme3.export.JmeImporter;
38-import com.jme3.export.InputCapsule;
3938 import com.jme3.export.OutputCapsule;
4039 import com.jme3.math.FastMath;
4140 import com.jme3.renderer.Camera;
--- a/engine/src/core/com/jme3/scene/control/UpdateControl.java
+++ b/engine/src/core/com/jme3/scene/control/UpdateControl.java
@@ -1,5 +1,5 @@
11 /*
2- * Copyright (c) 2009-2010 jMonkeyEngine
2+ * Copyright (c) 2009-2012 jMonkeyEngine
33 * All rights reserved.
44 *
55 * Redistribution and use in source and binary forms, with or without
--- a/engine/src/test/jme3test/animation/TestCameraMotionPath.java
+++ b/engine/src/test/jme3test/animation/TestCameraMotionPath.java
@@ -49,6 +49,7 @@ import com.jme3.math.Vector3f;
4949 import com.jme3.scene.CameraNode;
5050 import com.jme3.scene.Geometry;
5151 import com.jme3.scene.Spatial;
52+import com.jme3.scene.control.CameraControl;
5253 import com.jme3.scene.control.CameraControl.ControlDirection;
5354 import com.jme3.scene.shape.Box;
5455
@@ -73,7 +74,7 @@ public class TestCameraMotionPath extends SimpleApplication {
7374 cam.setLocation(new Vector3f(8.4399185f, 11.189463f, 14.267577f));
7475 camNode = new CameraNode("Motion cam", cam);
7576 camNode.setControlDir(ControlDirection.SpatialToCamera);
76- camNode.getControl(0).setEnabled(false);
77+ camNode.getControl(CameraControl.class).setEnabled(false);
7778 path = new MotionPath();
7879 path.setCycle(true);
7980 path.addWayPoint(new Vector3f(20, 3, 0));
@@ -170,11 +171,11 @@ public class TestCameraMotionPath extends SimpleApplication {
170171 playing = false;
171172 cameraMotionControl.stop();
172173 chaser.setEnabled(true);
173- camNode.getControl(0).setEnabled(false);
174+ camNode.getControl(CameraControl.class).setEnabled(false);
174175 } else {
175176 playing = true;
176177 chaser.setEnabled(false);
177- camNode.getControl(0).setEnabled(true);
178+ camNode.getControl(CameraControl.class).setEnabled(true);
178179 cameraMotionControl.play();
179180 }
180181 }