Bugfix: added jme serialization for CameraNode, LighNode, CameraControl and LightControl (as suggested by @rectalogic).
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9721 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
711b8ab9ca
commit
c929d0ca41
@ -31,6 +31,10 @@
|
|||||||
*/
|
*/
|
||||||
package com.jme3.scene;
|
package com.jme3.scene;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import com.jme3.export.JmeExporter;
|
||||||
|
import com.jme3.export.JmeImporter;
|
||||||
import com.jme3.renderer.Camera;
|
import com.jme3.renderer.Camera;
|
||||||
import com.jme3.scene.control.CameraControl;
|
import com.jme3.scene.control.CameraControl;
|
||||||
import com.jme3.scene.control.CameraControl.ControlDirection;
|
import com.jme3.scene.control.CameraControl.ControlDirection;
|
||||||
@ -90,4 +94,16 @@ public class CameraNode extends Node {
|
|||||||
// this.lookAt(position, upVector);
|
// this.lookAt(position, upVector);
|
||||||
// camControl.getCamera().lookAt(position, upVector);
|
// camControl.getCamera().lookAt(position, upVector);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(JmeImporter im) throws IOException {
|
||||||
|
super.read(im);
|
||||||
|
camControl = (CameraControl)im.getCapsule(this).readSavable("camControl", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(JmeExporter ex) throws IOException {
|
||||||
|
super.write(ex);
|
||||||
|
ex.getCapsule(this).write(camControl, "camControl", null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,10 @@
|
|||||||
*/
|
*/
|
||||||
package com.jme3.scene;
|
package com.jme3.scene;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import com.jme3.export.JmeExporter;
|
||||||
|
import com.jme3.export.JmeImporter;
|
||||||
import com.jme3.light.Light;
|
import com.jme3.light.Light;
|
||||||
import com.jme3.scene.control.LightControl;
|
import com.jme3.scene.control.LightControl;
|
||||||
import com.jme3.scene.control.LightControl.ControlDirection;
|
import com.jme3.scene.control.LightControl.ControlDirection;
|
||||||
@ -90,4 +94,16 @@ public class LightNode extends Node {
|
|||||||
public Light getLight() {
|
public Light getLight() {
|
||||||
return lightControl.getLight();
|
return lightControl.getLight();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(JmeImporter im) throws IOException {
|
||||||
|
super.read(im);
|
||||||
|
lightControl = (LightControl)im.getCapsule(this).readSavable("lightControl", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(JmeExporter ex) throws IOException {
|
||||||
|
super.write(ex);
|
||||||
|
ex.getCapsule(this).write(lightControl, "lightControl", null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,8 +31,12 @@
|
|||||||
*/
|
*/
|
||||||
package com.jme3.scene.control;
|
package com.jme3.scene.control;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import com.jme3.export.InputCapsule;
|
||||||
import com.jme3.export.JmeExporter;
|
import com.jme3.export.JmeExporter;
|
||||||
import com.jme3.export.JmeImporter;
|
import com.jme3.export.JmeImporter;
|
||||||
|
import com.jme3.export.OutputCapsule;
|
||||||
import com.jme3.math.Quaternion;
|
import com.jme3.math.Quaternion;
|
||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
import com.jme3.renderer.Camera;
|
import com.jme3.renderer.Camera;
|
||||||
@ -40,7 +44,6 @@ import com.jme3.renderer.RenderManager;
|
|||||||
import com.jme3.renderer.ViewPort;
|
import com.jme3.renderer.ViewPort;
|
||||||
import com.jme3.scene.Spatial;
|
import com.jme3.scene.Spatial;
|
||||||
import com.jme3.util.TempVars;
|
import com.jme3.util.TempVars;
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This Control maintains a reference to a Camera,
|
* This Control maintains a reference to a Camera,
|
||||||
@ -142,18 +145,21 @@ public class CameraControl extends AbstractControl {
|
|||||||
return control;
|
return control;
|
||||||
}
|
}
|
||||||
private static final String CONTROL_DIR_NAME = "controlDir";
|
private static final String CONTROL_DIR_NAME = "controlDir";
|
||||||
|
private static final String CAMERA_NAME = "camera";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(JmeImporter im) throws IOException {
|
public void read(JmeImporter im) throws IOException {
|
||||||
super.read(im);
|
super.read(im);
|
||||||
im.getCapsule(this).readEnum(CONTROL_DIR_NAME,
|
InputCapsule ic = im.getCapsule(this);
|
||||||
ControlDirection.class, ControlDirection.SpatialToCamera);
|
controlDir = ic.readEnum(CONTROL_DIR_NAME, ControlDirection.class, ControlDirection.SpatialToCamera);
|
||||||
|
camera = (Camera)ic.readSavable(CAMERA_NAME, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(JmeExporter ex) throws IOException {
|
public void write(JmeExporter ex) throws IOException {
|
||||||
super.write(ex);
|
super.write(ex);
|
||||||
ex.getCapsule(this).write(controlDir, CONTROL_DIR_NAME,
|
OutputCapsule oc = ex.getCapsule(this);
|
||||||
ControlDirection.SpatialToCamera);
|
oc.write(controlDir, CONTROL_DIR_NAME, ControlDirection.SpatialToCamera);
|
||||||
|
oc.write(camera, CAMERA_NAME, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -31,8 +31,12 @@
|
|||||||
*/
|
*/
|
||||||
package com.jme3.scene.control;
|
package com.jme3.scene.control;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import com.jme3.export.InputCapsule;
|
||||||
import com.jme3.export.JmeExporter;
|
import com.jme3.export.JmeExporter;
|
||||||
import com.jme3.export.JmeImporter;
|
import com.jme3.export.JmeImporter;
|
||||||
|
import com.jme3.export.OutputCapsule;
|
||||||
import com.jme3.light.DirectionalLight;
|
import com.jme3.light.DirectionalLight;
|
||||||
import com.jme3.light.Light;
|
import com.jme3.light.Light;
|
||||||
import com.jme3.light.PointLight;
|
import com.jme3.light.PointLight;
|
||||||
@ -42,7 +46,6 @@ import com.jme3.renderer.RenderManager;
|
|||||||
import com.jme3.renderer.ViewPort;
|
import com.jme3.renderer.ViewPort;
|
||||||
import com.jme3.scene.Spatial;
|
import com.jme3.scene.Spatial;
|
||||||
import com.jme3.util.TempVars;
|
import com.jme3.util.TempVars;
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This Control maintains a reference to a Camera,
|
* This Control maintains a reference to a Camera,
|
||||||
@ -173,18 +176,21 @@ public class LightControl extends AbstractControl {
|
|||||||
return control;
|
return control;
|
||||||
}
|
}
|
||||||
private static final String CONTROL_DIR_NAME = "controlDir";
|
private static final String CONTROL_DIR_NAME = "controlDir";
|
||||||
|
private static final String LIGHT_NAME = "light";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(JmeImporter im) throws IOException {
|
public void read(JmeImporter im) throws IOException {
|
||||||
super.read(im);
|
super.read(im);
|
||||||
im.getCapsule(this).readEnum(CONTROL_DIR_NAME,
|
InputCapsule ic = im.getCapsule(this);
|
||||||
ControlDirection.class, ControlDirection.SpatialToLight);
|
controlDir = ic.readEnum(CONTROL_DIR_NAME, ControlDirection.class, ControlDirection.SpatialToLight);
|
||||||
|
light = (Light)ic.readSavable(LIGHT_NAME, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(JmeExporter ex) throws IOException {
|
public void write(JmeExporter ex) throws IOException {
|
||||||
super.write(ex);
|
super.write(ex);
|
||||||
ex.getCapsule(this).write(controlDir, CONTROL_DIR_NAME,
|
OutputCapsule oc = ex.getCapsule(this);
|
||||||
ControlDirection.SpatialToLight);
|
oc.write(controlDir, CONTROL_DIR_NAME, ControlDirection.SpatialToLight);
|
||||||
|
oc.write(light, LIGHT_NAME, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user