diff options
Diffstat (limited to 'src/classes/share')
-rw-r--r-- | src/classes/share/com/sun/j3d/utils/scenegraph/io/retained/Controller.java | 3 | ||||
-rw-r--r-- | src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/SpotLightState.java | 66 |
2 files changed, 46 insertions, 23 deletions
diff --git a/src/classes/share/com/sun/j3d/utils/scenegraph/io/retained/Controller.java b/src/classes/share/com/sun/j3d/utils/scenegraph/io/retained/Controller.java index 8f6c294..e8e81b6 100644 --- a/src/classes/share/com/sun/j3d/utils/scenegraph/io/retained/Controller.java +++ b/src/classes/share/com/sun/j3d/utils/scenegraph/io/retained/Controller.java @@ -123,8 +123,9 @@ public abstract class Controller extends java.lang.Object { (bug 4690159) * 3 = Java3D 1.5.1 1) Add support for SceneGraphObject Name field * 4 = Java3D 1.5.2 issue 532, for saving Background Geometry + * 5 = Java3D 1.5.2+ issue 654, for saving required SpotLight attributes */ - protected int outputFileVersion = 4; + protected int outputFileVersion = 5; /** * When running the application within webstart this may not be the diff --git a/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/SpotLightState.java b/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/SpotLightState.java index 8215cbf..4e1dc88 100644 --- a/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/SpotLightState.java +++ b/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/SpotLightState.java @@ -45,37 +45,59 @@ package com.sun.j3d.utils.scenegraph.io.state.javax.media.j3d; import java.io.*; + +import javax.media.j3d.PointLight; import javax.media.j3d.SpotLight; +import javax.vecmath.Point3f; import javax.vecmath.Vector3f; import com.sun.j3d.utils.scenegraph.io.retained.Controller; import com.sun.j3d.utils.scenegraph.io.retained.SymbolTableData; +// issue 654: should inherit from PointLightState, but too hard to refactor public class SpotLightState extends LightState { - public SpotLightState( SymbolTableData symbol, Controller control ) { - super( symbol, control ); + public SpotLightState(SymbolTableData symbol, Controller control) { + super(symbol, control); + + } + + public void writeObject(DataOutput out) throws IOException { + super.writeObject(out); + + // issue 654: add missing attributes, since we should really inherit + // from PointLightState + Point3f point = new Point3f(); + ((PointLight) node).getAttenuation(point); + control.writePoint3f(out, point); + ((PointLight) node).getPosition(point); + control.writePoint3f(out, point); + + Vector3f dir = new Vector3f(); + ((SpotLight) node).getDirection(dir); + control.writeVector3f(out, dir); + + out.writeFloat(((SpotLight) node).getSpreadAngle()); + out.writeFloat(((SpotLight) node).getConcentration()); + } - } - - public void writeObject( DataOutput out ) throws IOException { - super.writeObject( out ); - Vector3f dir = new Vector3f(); - ((SpotLight)node).getDirection( dir ); - control.writeVector3f( out, dir ); + public void readObject(DataInput in) throws IOException { + + super.readObject(in); + + // issue 654: add missing attributes, since we should really inherit + // from PointLightState + if (control.getCurrentFileVersion() >= 5) { + ((PointLight) node).setAttenuation(control.readPoint3f(in)); + ((PointLight) node).setPosition(control.readPoint3f(in)); + } - out.writeFloat( ((SpotLight)node).getSpreadAngle()); - out.writeFloat( ((SpotLight)node).getConcentration()); - } + ((SpotLight) node).setDirection(control.readVector3f(in)); + ((SpotLight) node).setSpreadAngle(in.readFloat()); + ((SpotLight) node).setConcentration(in.readFloat()); + } - public void readObject( DataInput in ) throws IOException { - super.readObject( in ); - ((SpotLight)node).setDirection( control.readVector3f(in) ); - ((SpotLight)node).setSpreadAngle( in.readFloat() ); - ((SpotLight)node).setConcentration( in.readFloat() ); - } - - protected javax.media.j3d.SceneGraphObject createNode() { - return new SpotLight(); - } + protected javax.media.j3d.SceneGraphObject createNode() { + return new SpotLight(); + } } |