Hi,
I have been trying to tackle this problem for some time now. I have a VRML
file, which I read into my Java applet, and display in a Canvas3D. This
VRML file includes six faces, forming a box, and each face has a unique
name (using the DEF nodes in VRML). I want to be able to select the
faces, and have their names returned when I click the mouse pointer when
I'm above the face. This works fine in the regular Java3D View Model,
using vpTransGroup.setTransform(viewTrans) as was demonstrated in the
SimpleVrml97Viewer. However, since I have to synchronise my viewing
pipeline with an existing application, I need to use the Camera-Based
View Model, with a Center of Projection (eye), View Reference Point and
View-Up Vector, using a perspective transformation:
View.setVpcToEc(viewTrans) and
View.setLeftProjection(projTrans).
When I change to this view model, the system always returns the same
face, no matter where in the Canvas3D I click, even when I'm clicking in
an empty space. Am I missing something here, or is the picking
functionlity BranchGroup.PickClosest() method not able to handle the
Camera-Based View Model?
I am using JDK 1.2.2 and Java3D 1.2 OpenGL. I have included the Pick
function here:
void PickFace(int x, int y)
{
Point3d pointInScene=new Point3d();
canvas.getPixelLocationInImagePlate(x, y, pointInScene);
Vector3d direction=new Vector3d();
direction.sub(pointInScene, cop);
PickRay pr=new PickRay(cop, direction);
SceneGraphPath sgp=new SceneGraphPath();
sgp=sceneGroup.pickClosest(pr);
if (sgp!=null)
{
for (int i=0;i<sgp.nodeCount();i++)
{
System.out.println("Node: "+sgp.getNode(i).toString());
}
}
}
===========================================================================
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".