Two possible reasons:
1) Do you use USE_BOUNDS or USE_GEOMETRY pickMode?
Try using USE_GEOMETRY, it will give you better presission
in piking.
2) Do you use the same appearance (or Material, or Coloring attributes)
for diffrent objects? In that case if you change values inside one of
them it will affect all objects that use it.
E.g. Say you used object Appearence app ,
to create two objects sph1 and sph2.
Then you want to change the color of sh1. What you do is
take an appearance of sh1, and set its material to something else
but the appearance of sh1 is app, which is an appearance of sh2 too.
So both objects will change their color.
Hope this helps.
Boris Epelman
On Wed, 6 Sep 2000, Glenn Rowe wrote:
> I've been experimenting with picking and have come across
> some odd behaviour - just wondering if anyone else has found something
> similar.
>
> Basically, I've defined a picking behaviour class that selects
> a list of all objects along a ray from the mouseposition,
> and changes the diffuse colour of all picked objects from white
> to red:
>
> //=====================================================
> public class MousePick extends PickMouseBehavior
> {
> Material redSurface = new Material();
>
> public MousePick(Canvas3D canvas, BranchGroup branch, Bounds bounds)
> {
> super(canvas, branch, bounds);
> setSchedulingBounds(bounds);
> pickCanvas.setMode(PickTool.GEOMETRY);
> setTolerance(0.0f);
> redSurface.setDiffuseColor(1.0f, 0.0f, 0.0f);
> }
>
> public void updateScene(int xPos, int yPos)
> {
> // randSpheres is an object that contains several random spheres
>
> randSpheres.resetColors(); // Resets all objects to white
> pickCanvas.setShapeLocation(xPos, yPos);
> PickShape pickShape = pickCanvas.getPickShape();
> PickResult[] results = pickCanvas.pickAll();
> if (results != null) {
> for (int i = 0; i < results.length; i++) {
> Shape3D shape =
>(Shape3D)results[i].getNode(PickResult.SHAPE3D);
> shape.getAppearance().setMaterial(redSurface);
> }
> }
> }
> //=========================================
>
> I then generated several Sphere objects of varying size and position,
> and test the MousePick class by clicking on the spheres in various
> places. Since the tolerance has been set to zero, a sphere should turn
> red only if the ray from the mouse into the scene actually intersects
> the sphere. In most places, this is true, but in some cases, a sphere
> will turn red when it is definitely NOT cut by the ray.
>
> If the mouse is clicked outside all the spheres, no sphere is ever
> selected, but occasionally when clicking on one sphere, the selected sphere
> and another one that is nowhere near the picked ray will turn red.
> Thus it seems that the picking is always able to determine whether or not
> the mouse is clicked over an object, but sometimes mistakenly
> includes objects in the picked list that shouldn't be there.
>
> Just in case there was something odd about the geometric primitives,
> I tried the same experiment using a Cube class that I wrote from scratch
> using QuadArrays, and the same thing happened.
>
> Is this a bug in the picking behaviour classes, or am I doing something
> wrong?
>
> ===========================================================================
> 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".