Arrg! I've been having trouble with this for a couple of days now, and would like to
get some help, if you please.
I've created a method which creates a RotPosPathInterpolator behavior node and adds it
to the scene graph. When calling the method with the first TransformGroup, lets call
it TransformGroup A, it works as expected. When calling the method with another
TransformGroup, lets call it TransformGroupB, there are problems. As soon as the
RotPosPathInterpolator for TransformGroupB, gets added to the scene graph, a
NullPointerException is thrown within a Java3D thread, as follows:
// Stack trace
java.lang.NullPointerException
at
javax.media.j3d.TransformGroupRetained.updateChildLocalToVworld(TransformGroupRetained.java:969)
at
javax.media.j3d.TransformGroupRetained.updateChildLocalToVworld(TransformGroupRetained.java:961)
at
javax.media.j3d.TransformGroupRetained.processChildLocalToVworld(TransformGroupRetained.java:825)
at
javax.media.j3d.TransformStructure.processCurrentLocalToVworld(TransformStructure.java:306)
at javax.media.j3d.TransformStructure.processMessages(TransformStructure.java:186)
at javax.media.j3d.StructureUpdateThread.doWork(StructureUpdateThread.java:83)
at javax.media.j3d.J3dThread.run(J3dThread.java:250)
// end of stack trace
Here's the thread name where the NullPointerException occurred:
System Thread [J3D-TransformStructureUpdateThread-1]
The RotPosPathInterpolator's purpose is to move a TransformGroup a certain direction
and to rotate it around to a certain angle.
Strangely, maybe 5% of the time, the NullPointerException does not occur, and
TransformGroupB gets moved/rotated as expected.
Thank you very much,
David B
Here is most of the code:
// x, y, z, and angle
double[] delta = new double [] { 8d, 0d, 0d, -1*Math.PI };
Alpha alpha = new Alpha(-1, 4000);
double deltaAngle = delta[3];
// Lets move back for the first 1/4 second,
// and then fully rotate around for the next
// 3/4 of a second, and then finish
// the move the next 2 seconds
float[] knots = new float[] { 0f, .25f / 3f, .25f, 1.0f };
AxisAngle4f axisAngle;
Quat4f[] quats = new Quat4f[4];
quats[0] = new Quat4f();
axisAngle = new AxisAngle4f();
axisAngle.set(0f, 0f, 1f, 0f);
quats[0].set(axisAngle);
quats[1] = new Quat4f();
axisAngle = new AxisAngle4f();
axisAngle.set(0f, 0f, 1f, (float) deltaAngle/2f);
quats[1].set(axisAngle);
quats[2] = new Quat4f();
axisAngle = new AxisAngle4f();
axisAngle.set(0f, 0f, 1f, (float) deltaAngle);
quats[2].set(axisAngle);
quats[3] = new Quat4f();
axisAngle = new AxisAngle4f();
axisAngle.set(0f, 0f, 1f, (float) deltaAngle);
quats[3].set(axisAngle);
// The x-axis is the axis of transform
Transform3D positionalDelta = new Transform3D();
AxisAngle4f ang = new AxisAngle4f(1f, 0f, 1f, 0f);
positionalDelta.set(ang);
// The intermediate positions
Point3f[] positions = new Point3f[4];
positions[0] = new Point3f(0, 0, 0);
positions[1] =
new Point3f(
(float) delta[0] * .25f,
(float) delta[1] * .25f,
(float) delta[2] * .25f);
positions[2] =
new Point3f(
(float) delta[0] * .5f,
(float) delta[1] * .5f,
(float) delta[2] * .5f);
positions[3] =
new Point3f((float) delta[0], (float) delta[1], (float) delta[2]);
RotPosPathInterpolator rotPathInterpolator =
new RotPosPathInterpolator(
alpha,
unitBridge.getTransformGroup(),
positionalDelta,
knots,
quats,
positions);
BoundingSphere bounds =
new BoundingSphere(new Point3d(0, 0, 0), Double.MAX_VALUE);
rotPathInterpolator.setSchedulingBounds(bounds);
BranchGroup aBranchGroup = new BranchGroup();
aBranchGroup.addChild(rotPathInterpolator);
getBranchGraph().addChild(aBranchGroup);
rotPathInterpolator.setEnable(true);
// END of Code snippet
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".