I tried to modify Sphere class so that instead of
having only one child (transform group and shape3D as it's' child), I define
several shape3Ds as children of this Sphere itself ( I've also tried to put it
as children of the transformgroup).
I have set all the new shape3D's to be pickable,
hopin' that I can get them by picking operation, and set pickable false to the
first shape3D (child of objTrans).
After that, in my applet, I tried to pick them
using pickAllSorted. But I always get null for the result.
Why can't I get those shape3d from
picking?
This is my picking code, where e is mouse event
:
PickRay pickRay = (PickRay)
objPick.generatePickRay(e.getX(),e.getY());
// SceneGraphPath[] objResult = objPick.pickAllSorted(e.getX(),e.getY(),PickObject.USE_GEOMETRY);
SceneGraphPath[] objResult = objRoot.pickAllSorted(pickRay);
if (objResult == null)
{ System.out.println("NULL");
}
else {
if (objResult[0] != null)
{ System.out.println("not null");
Node node = objResult[0].getObject();
if (node == null)
{System.out.println("Node null");
}
if (node instanceof Shape3D)
{ System.out.println("SHAPE3D");
Shape3D objShape = (Shape3D) node;
double[] distance = new double[3];
found = objShape.intersect(objResult[0],pickRay,distance);
if (found)
{Area area = (Area) objShape.getUserData();
System.out.println("Area : " +area.AreaName);
}
else {
System.out.println("not found");
}
}
} // end if
} // end else
// SceneGraphPath[] objResult = objPick.pickAllSorted(e.getX(),e.getY(),PickObject.USE_GEOMETRY);
SceneGraphPath[] objResult = objRoot.pickAllSorted(pickRay);
if (objResult == null)
{ System.out.println("NULL");
}
else {
if (objResult[0] != null)
{ System.out.println("not null");
Node node = objResult[0].getObject();
if (node == null)
{System.out.println("Node null");
}
if (node instanceof Shape3D)
{ System.out.println("SHAPE3D");
Shape3D objShape = (Shape3D) node;
double[] distance = new double[3];
found = objShape.intersect(objResult[0],pickRay,distance);
if (found)
{Area area = (Area) objShape.getUserData();
System.out.println("Area : " +area.AreaName);
}
else {
System.out.println("not found");
}
}
} // end if
} // end else
Regards,
Tria
