Hi Martin: >MIME-Version: 1.0 >Content-Transfer-Encoding: 7bit >X-Priority: 3 >X-MSMail-Priority: Normal >X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211 >Date: Sun, 23 Apr 2000 18:15:33 +0100 >From: Martin Baker <[EMAIL PROTECTED]> >Subject: [JAVA3D] Differences between Java3D 1.1.x and Java3D 1.2beta2 >To: [EMAIL PROTECTED] > >Differences between Java3D 1.1.x and Java3D 1.2beta2 >--------------------------------------------------------- > >I have been trying my program with Java3D 1.2beta2, there appear to be a lot >of differences than when its run under Java3D 1.1.x. > >Can anyone tell me if these differences are due to bugs, bug fixes or >features? > >A lot of these differences seem to be connected with the way Java3D >calculates bounds and collision bounds, here are some examples: > >1) Locale.pickClosest(pickRay) does not work as expected under 1.2beta2 but >it works fine under 1.1 (Locale.pickAll(pickRay) works fine in both - ie >pick by geometry works fine in both but pick using bounds does not). > A test program and a detail description of the problem would be helpful for us to find the problem. Note that the bounds in v1.2 may be different (bigger or smaller) then v1.1.x (However it must enclose the whole shape). The specification did not restrict the bounds Java3D use internally. >2) WakeupOnCollisionEntry reports collisions at unexpected times under >1.2beta2. (both when using >WakeupOnCollisionEntry(armingPath,WakeupOnCollisionEntry.USE_GEOMETRY) or >WakeupOnCollisionEntry(armingPath,WakeupOnCollisionEntry.USE_BOUNDS) ) the >WakeupCriterion returned give the following: > getArmingPath() returned a TransformGroup as supplied in armingPath as >expected. > getTriggeringPath() returned a Shape3D node. > getArmingBounds() returned null > getTriggeringBounds() was not null! it returned the original bounds of >the Shape3D node. >Under 1.1 the collision happens when expected and getTriggeringBounds() >returns null. > getTriggeringBounds() is implemented correctly in v1.2, from the spec. /** * Retrieves the Bounds object that caused the collision */ This bounds is the collision bound if it is set by the user via setCollisionBound() or bounds if it is set by the user via setBounds() or internally compute bound. It is a bug in v1.1 which did not return the bound. The behavior is wakeup whenever object collide as soon as possible. If there is a test program which show collision does not report as expect or collision is report incorrectly, it would be helpful to send it for us to verify. >3) I can't get WakeupOnCollisionExit(bounds) to work in either version. under >1.1 it returns the following error: >java.lang.NullPointerException > at javax.media.j3d.CollisionThread.start_traverse(Compiled Code) > at javax.media.j3d.CollisionThread.updateCollisionState(Compiled Code) > at javax.media.j3d.CollisionThread.run(CollisionThread.java:1245) >under 1.2 I get no error but no collision is triggered. There are bugs in v1.1 which is fixed when collision is rewritten in v1.2. Attach is a simple example to show WakeupOnCollisionExit(bounds) works fine under v1.2. Note that if the bounds pass in overlap with any bounds in the scene graph. The it will never report WakeupOnCollisionExit. A common mistake is to pass the shape's bound in WakeupOnCollisionExit(), since the shape's bound always collide with the shape, WakeupOnCollisionExit will never invoke. >------------------------------------------------------------------------- >I could go on, but before I do, I would like to know if these differences >are already documented? >I am running OpenGL on NT4 (no h/w acceleration) >for screen shots of the program I used see: >http://www.martinb.com/mjbWorld/userGuide/dynamics_tutor/index.htm > >Martin Baker > Thanks. - Kelvin -------------------- Java 3D Team Sun Microsystems Inc.
/* * @(#)CollisionBound.java 1.3 99/09/15 13:37:40 * * Copyright (c) 1996-1999 Sun Microsystems, Inc. All Rights Reserved. * * Sun grants you ("Licensee") a non-exclusive, royalty free, license to use, * modify and redistribute this software in source and binary code form, * provided that i) this copyright notice and license appear on all copies of * the software; and ii) Licensee does not utilize the software in a manner * which is disparaging to Sun. * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF * OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE * POSSIBILITY OF SUCH DAMAGES. * * This software is not designed or intended for use in on-line control of * aircraft, air traffic, aircraft navigation or aircraft communications; or in * the design, construction, operation or maintenance of any nuclear * facility. Licensee represents and warrants that it will not use or * redistribute the Software for such purposes. */ import java.applet.Applet; import java.awt.*; import java.awt.event.*; import com.sun.j3d.utils.applet.MainFrame; import com.sun.j3d.utils.geometry.Sphere; import com.sun.j3d.utils.universe.*; import javax.media.j3d.*; import javax.vecmath.*; public class CollisionBound extends Applet { public BranchGroup createSceneGraph() { // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); // Create a Transformgroup to scale all objects so they // appear in the scene. Transform3D t3d = new Transform3D(); t3d.setScale(0.4); TransformGroup objScale = new TransformGroup(); objScale.setTransform(t3d); objRoot.addChild(objScale); // Create a bounds for the background and behaviors BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0); // Set up the background Color3f bgColor = new Color3f(0.05f, 0.05f, 0.2f); Background bg = new Background(bgColor); bg.setApplicationBounds(bounds); objScale.addChild(bg); // Create a transform group nodes and initialize them to // identity. Enable the TRANSFORM_WRITE capability so that // our behaviors can modify them at runtime. Add them to the // root of the subgraph. TransformGroup objTrans = new TransformGroup(); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objScale.addChild(objTrans); // Create the positioning and scaling transform group node. Transform3D t = new Transform3D(); t.set(0.3, new Vector3d(-1.5, 0.0, 0.0)); TransformGroup objTrans2 = new TransformGroup(t); objTrans.addChild(objTrans2); // Create a simple shape leaf node, add it to the scene graph. Appearance app = new Appearance(); app.setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_WRITE); ColoringAttributes ca = new ColoringAttributes(); ca.setColor(0.2f, 0.4f, 0.8f); app.setColoringAttributes(ca); Sphere sphere = new Sphere(1.5f, app); objTrans2.addChild(sphere); // Create a new Behavior object that will perform the desired // rotation on the specified transform object and add it into // the scene graph. Transform3D yAxis1 = new Transform3D(); Alpha alpha = new Alpha(-1, Alpha.INCREASING_ENABLE | Alpha.DECREASING_ENABLE, 0, 0, 2000, 1000, 100, 2000, 1000, 100); PositionInterpolator interpolator = new PositionInterpolator(alpha, objTrans, yAxis1, -1, 4); interpolator.setSchedulingBounds(bounds); objTrans2.addChild(interpolator); // Create a transform group nodes and initialize them to // identity. Enable the TRANSFORM_WRITE capability so that // our behaviors can modify them at runtime. Add them to the // root of the subgraph. TransformGroup cobjTrans = new TransformGroup(); cobjTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objScale.addChild(cobjTrans); // Create the positioning and scaling transform group node. t = new Transform3D(); t.set(0.3, new Vector3d(-1.5, 1.5, 0.0)); TransformGroup cobjTrans2 = new TransformGroup(t); cobjTrans.addChild(cobjTrans2); cobjTrans2.addChild(new Sphere(0.5f)); // Create the positioning and scaling transform group node. t = new Transform3D(); t.set(0.3, new Vector3d(-1.5, 0.0, 0.0)); TransformGroup cobjTrans3 = new TransformGroup(t); cobjTrans.addChild(cobjTrans3); yAxis1 = new Transform3D(); alpha = new Alpha(-1, Alpha.INCREASING_ENABLE | Alpha.DECREASING_ENABLE, 0, 0, 1000, 300, 40, 1000, 400, 50); PositionInterpolator cinterpolator = new PositionInterpolator(alpha, cobjTrans, yAxis1, -1, 4); cinterpolator.setSchedulingBounds(bounds); cobjTrans.addChild(cinterpolator); // create a collision Bound Bounds collisionBound = new BoundingSphere(new Point3d(0, 0, 0), 0); // Create a new Behavior object that will perform the collision // detection on the specified Bounding Box with is // the same as shape box CollisionDetectorBound cd = new CollisionDetectorBound(collisionBound, app); cd.setSchedulingBounds(bounds); // Add the behavior to the scene graph cobjTrans3.addChild(cd); // Have Java 3D perform optimizations on this scene graph. objRoot.compile(); return objRoot; } public CollisionBound() { setLayout(new BorderLayout()); GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); Canvas3D c = new Canvas3D(config); add("Center", c); // Create a simple scene and attach it to the virtual universe BranchGroup scene = createSceneGraph(); SimpleUniverse u = new SimpleUniverse(c); // This will move the ViewPlatform back a bit so the // objects in the scene can be viewed. u.getViewingPlatform().setNominalViewingTransform(); u.addBranchGraph(scene); } // // The following allows CollisionMorph to be run as an application // as well as an applet // public static void main(String[] args) { new MainFrame(new CollisionBound(), 700, 700); } }
/* * @(#)CollisionDetectorBound.java 1.2 99/09/15 13:37:42 * * Copyright (c) 1996-1999 Sun Microsystems, Inc. All Rights Reserved. * * Sun grants you ("Licensee") a non-exclusive, royalty free, license to use, * modify and redistribute this software in source and binary code form, * provided that i) this copyright notice and license appear on all copies of * the software; and ii) Licensee does not utilize the software in a manner * which is disparaging to Sun. * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF * OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE * POSSIBILITY OF SUCH DAMAGES. * * This software is not designed or intended for use in on-line control of * aircraft, air traffic, aircraft navigation or aircraft communications; or in * the design, construction, operation or maintenance of any nuclear * facility. Licensee represents and warrants that it will not use or * redistribute the Software for such purposes. */ import java.util.Enumeration; import javax.media.j3d.*; import javax.vecmath.*; public class CollisionDetectorBound extends Behavior { private boolean inCollision = false; private Bounds bound; private WakeupOnCollisionEntry wEnter; private WakeupOnCollisionExit wExit; private Appearance app; private ColoringAttributes ca1, ca2; public CollisionDetectorBound(Bounds bound, Appearance app) { this.bound = bound; this.app = app; inCollision = false; ca1 = new ColoringAttributes(); ca1.setColor(0.9f, 0.3f, 0.2f); ca2 = new ColoringAttributes(); ca2.setColor(0.2f, 0.4f, 0.8f); } public void initialize() { wEnter = new WakeupOnCollisionEntry(bound); wExit = new WakeupOnCollisionExit(bound); wakeupOn(wEnter); } public void processStimulus(Enumeration criteria) { inCollision = !inCollision; if (inCollision) { app.setColoringAttributes(ca1); wakeupOn(wExit); } else { app.setColoringAttributes(ca2); wakeupOn(wEnter); } } }