Hi Joel, Bug 4461310 - Object may disappear in Billboard/OrientedShape3D due to numerical problem is filed for this. In fact the ColorCube did show up in the first frame but after moving the window the cube disappear under D3D version. It seems didn't happen under OpenGL version because when window move, the frame need to render again under D3D version. And there is some kind of numerical error accumulate every frame which cause the function Math.acos() which use in Billboard return NaN after a while and the cube disappear ! Attach is the modified example which use application instead of applet. Thanks for your bug report. - Kelvin ----------- Java 3D Team Sun Microsystem Inc. >X-Unix-From: [EMAIL PROTECTED] Mon May 21 07:37:29 2001 >MIME-Version: 1.0 >Date: Mon, 21 May 2001 10:34:28 -0400 >From: "J. Lee Dixon" <[EMAIL PROTECTED]> >Subject: [JAVA3D] Billboard ROTATE_ABOUT_POINT bug >To: [EMAIL PROTECTED] > >Attached is an example applet that displays a ColorCube being >billboarded about a point. When I run with an applet size of 600x600, I >see nothing on the screen. If I change the applet size to 500x500, the >cube shows up. > >Also, if I switch to ROTATE_ABOUT_AXIS, it also works. Can somebody >else (Sun) please try this? I didn't set it up to use the plug-in, so >you will have to use the AppletViewer. > >I am running JDK 1.3.0_02 and J3D 1.2.1 DirectX > >Thanks. >-Lee > >J. Lee Dixon, Sr Software Engineer >SAIC - Celebration, FL >321-939-7917 >[EMAIL PROTECTED] AOL: LeeOrlando >
import java.applet.*; import java.awt.*; import javax.swing.*; import javax.media.j3d.*; import javax.vecmath.*; import com.sun.j3d.utils.universe.*; import com.sun.j3d.utils.geometry.*; import com.sun.j3d.utils.applet.MainFrame; // Bug repro program. Billboarded color cube does not display // when in ROTATE_ABOUT_POINT mode, but will display if the // applet size in HTML tag is changed from 600x600 to 500x500. public class BillBoardTestApplet extends Applet { private SimpleUniverse universe; private BoundingSphere infiniteBounds = new BoundingSphere( new Point3d(), Double.MAX_VALUE ); public BillBoardTestApplet() { setLayout( new BorderLayout() ); } public void init() { GraphicsConfiguration gcfg = SimpleUniverse.getPreferredConfiguration(); Canvas3D canvas = new Canvas3D(gcfg); add( canvas, BorderLayout.CENTER ); universe = new SimpleUniverse( canvas ); // This will move the ViewPlatform back a bit so the // objects in the scene can be viewed. universe.getViewingPlatform().setNominalViewingTransform(); // Create the scene with just a ColorCube, either billboarded // about a point or an axis. Seems to be broken when // set to true. boolean rotatePoint = true; // TURN THIS ON AND OFF -Lee BranchGroup mainBranch = createScene( rotatePoint ); mainBranch.compile(); universe.addBranchGraph( mainBranch ); } public void start() { } BranchGroup createScene(boolean rotatePoint) { // Create the main branch to be returned. BranchGroup bg = new BranchGroup(); // Scale the scene by 1/10. Transform3D xform = new Transform3D(); xform.setScale(0.1f); TransformGroup tg = new TransformGroup( xform ); bg.addChild( tg ); // Create an editable transform with a color cube. TransformGroup bbgrp = new TransformGroup(); bbgrp.setCapability( bbgrp.ALLOW_TRANSFORM_WRITE ); bbgrp.addChild( new ColorCube() ); // Create a billboard for the colorcube. Billboard bb = new Billboard( bbgrp ); bb.setRotationPoint( new Point3f( 0f, 0f, 0f ) ); bb.setAlignmentAxis( new Vector3f( 0f, 1f, 0f ) ); bb.setSchedulingBounds(infiniteBounds); bb.setEnable( true ); if( rotatePoint ) bb.setAlignmentMode( bb.ROTATE_ABOUT_POINT ); else bb.setAlignmentMode( bb.ROTATE_ABOUT_AXIS ); bg.addChild( bb ); tg.addChild(bbgrp); TransformGroup objTrans = new TransformGroup(); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); tg.addChild(objTrans); Transform3D yAxis = new Transform3D(); Alpha rotationAlpha = new Alpha(-1, 4000); RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, objTrans, yAxis, 0.0f, (float) Math.PI*2.0f); BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0); rotator.setSchedulingBounds(bounds); // tg.addChild(rotator); return( bg ); } public static void main(String[] args) { new MainFrame(new BillBoardTestApplet(), 256, 256); } }