summaryrefslogtreecommitdiffstats
path: root/src/classes/share
diff options
context:
space:
mode:
authorKen Mc Neill <[email protected]>2010-12-22 09:36:54 +0000
committerHarvey Harrison <[email protected]>2011-12-31 15:05:36 -0800
commit9f2d34dc4dfdc70820cb75dbf5b841624ea8b3bc (patch)
treef7b78097a702acd2595e29238cc89eb67b067633 /src/classes/share
parent77acd6a439dbea92ec829643ef3f9597a15072fc (diff)
j3dutils: cherry-pick fix from svn trunk issue 654
issue 654 fixed by mcneillk git-svn-id: https://svn.java.net/svn/j3d-core-utils~svn/trunk@204 9497e636-51bd-65ba-982d-a4982e1767a5 Signed-off-by: Harvey Harrison <[email protected]>
Diffstat (limited to 'src/classes/share')
-rw-r--r--src/classes/share/com/sun/j3d/utils/scenegraph/io/retained/Controller.java3
-rw-r--r--src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/SpotLightState.java66
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();
+ }
}