Will,
Yes, this is a J3D bug. OrientedShape3D is a special Shape3D node; it
was added in 1.2 release. We've unintentionally left out the needed picking
support for this special node. Thanks for reporting it to us.
BugId 4357843 - Picking doesn't handle OrientedShape3D's orientation when doing
intersect test.
- Chien Yang.
Java 3D Team.
> MIME-Version: 1.0
> Date: Mon, 31 Jul 2000 11:54:36 -0400
> From: me <[EMAIL PROTECTED]>
> Subject: [JAVA3D] OrientedShape3D picking bug
> Comments: To: [EMAIL PROTECTED]
> To: [EMAIL PROTECTED]
>
> my pick operation returns a result based on the original un"oriented"
> orientation of the shape. here is a test case illustrating what i mean.
> i've drawn a white box in the middle of the canvas3d with a pi/3 rotation
> about the Y axis. click near the middle and the edges of the white box to
> see what i mean. thanks.
>
> Will
>
> --test.java--
>
> import java.applet.Applet;
> import java.awt.BorderLayout;
> import java.awt.event.*;
> import java.awt.GraphicsConfiguration;
> import com.sun.j3d.utils.applet.MainFrame;
> import com.sun.j3d.utils.universe.*;
> import com.sun.j3d.utils.picking.*;
> import javax.media.j3d.*;
> import javax.vecmath.*;
>
> public class test extends Applet implements MouseListener {
> private PickCanvas pickCanvas;
>
> public BranchGroup createSceneGraph() {
> // Create the root of the branch graph
> BranchGroup objRoot = new BranchGroup();
>
> // Create the TransformGroup node and initialize it to the
> // identity. Enable the TRANSFORM_WRITE capability so that
> // our behavior code can modify it at run time. Add it to
> // the root of the subgraph.
> Transform3D trans = new Transform3D();
> trans.rotY(Math.PI*1/3);
> TransformGroup objTrans = new TransformGroup(trans);
> objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
> objRoot.addChild(objTrans);
>
> // Create a 2d square
> int[] v = {4};
> float[] cord = {-0.5f, -0.5f, 0f};
> QuadArray tfa = new QuadArray(4, QuadArray.COORDINATES);
> tfa.setCoordinate(3, cord);
> cord[0] = 0.5f; cord[1] = -0.5f; cord[2] = 0;
> tfa.setCoordinate(2, cord);
> cord[0] = 0.5f; cord[1] = 0.5f; cord[2] = 0;
> tfa.setCoordinate(1, cord);
> cord[0] = -0.5f; cord[1] = 0.5f; cord[2] = 0;
> tfa.setCoordinate(0, cord);
> tfa.setCapability(Geometry.ALLOW_INTERSECT);
>
> Appearance app = new Appearance();
> Material mat = new Material();
> mat.setLightingEnable(false);
> app.setMaterial(mat);
> ColoringAttributes ca = new ColoringAttributes();
> app.setColoringAttributes(ca);
> PolygonAttributes pa = new PolygonAttributes();
> pa.setCullFace(PolygonAttributes.CULL_NONE);
> app.setPolygonAttributes(pa);
>
> OrientedShape3D aShape = new OrientedShape3D(tfa, app,
>
> OrientedShape3D.ROTATE_ABOUT_POINT, new Point3f(0,0,0));
>
> aShape.setPickable(true);
> aShape.setBoundsAutoCompute(true);
>
> // Create a simple Shape3D node; add it to the scene graph.
> objTrans.addChild(aShape);
>
> // Have Java 3D perform optimizations on this scene graph.
> objRoot.compile();
>
> return objRoot;
> }
>
> public test() {
> setLayout(new BorderLayout());
> GraphicsConfiguration config =
> SimpleUniverse.getPreferredConfiguration();
>
> Canvas3D c = new Canvas3D(config);
> add("Center", c);
>
> c.addMouseListener(this);
>
> // Create a simple scene and attach it to the virtual universe
> BranchGroup scene = createSceneGraph();
> SimpleUniverse u = new SimpleUniverse(c);
>
> // set picker
> pickCanvas = new PickCanvas(c, scene);
> pickCanvas.setMode(PickTool.GEOMETRY);
> //pickCanvas.setTolerance(4.0f);
>
> // This will move the ViewPlatform back a bit so the
> // objects in the scene can be viewed.
> u.getViewingPlatform().setNominalViewingTransform();
>
> u.addBranchGraph(scene);
> }
>
>
> public void mouseClicked(MouseEvent e)
> {
> System.out.print("@(" + e.getX() + ", " + e.getY() + "): ");
> pickCanvas.setShapeLocation(e);
> PickResult results = pickCanvas.pickClosest();
> if(results != null)
> {
> System.out.println("We got something!");
> }
> else
> System.out.println("Found nothing :(");
> }
>
> public void mouseEntered(MouseEvent e)
> {
> }
>
> public void mouseExited(MouseEvent e)
> {
> }
>
> public void mousePressed(MouseEvent e)
> {
> }
>
> public void mouseReleased(MouseEvent e)
> {
> }
>
> //
> // The following allows HelloUniverse to be run as an application
> // as well as an applet
> //
> public static void main(String[] args) {
> new MainFrame(new test(), 256, 256);
> }
> }
>
> ===========================================================================
> 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".
===========================================================================
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".