Vijay,
I used to use code like you've written but found it unreliable and buggy. I'm guessing your "picker" is a "PickTool". Well... I found the Java 3D Utilities to be buggy and had to stop using PickTool and switched to branchgroup picking. Like: sceneGroup.pickAll(pickRay); Then check if the returned scene graph path is null or not. If it is null you didn't hit anything. If you did then step through the entire returned array testing each Shape3D to see if you intersected it and the distance to that intersection. Then return the shortest distance you found and that's your nearest collision.
- John Wright Starfire Research
Vjiay Dharap wrote:
Hi,
In an Attempt to implement terrain following I have used the following code
Point3d pickStart = new Point3d(); Vector3d down = new Vector3d(0.0, -15.0, 0.0); Transform3D newT3d = new Transform3D(); newT3d.setTranslation(new Vector3d(0.0, 1.5, STEP)); newT3d.mul(ourTrans); newT3d.transform(pickStart);
picker.setShapeRay(pickStart, down);
PickResult picked = picker.pickClosest(); if (picked != null){ PickIntersection intersect = picked.getIntersection(0); //i get Exception on this //line Point3d nextpoint = intersect.getPointCoordinates();
System.out.println("moveStep : Start Point !! " + pickStart); System.out.println("moveStep : Next Point !! " + nextpoint);
double pickY = (pickStart.y);
pickY = pickY - 1.5;
if (nextpoint != null) { if (nextpoint.y != pickY) { Vector3d translate = new Vector3d(); ourTrans.get(translate); translate.y = nextpoint.y +1.5; ourTrans.setTranslation(translate); //ourTrans.setTranslation(new // Vector3d(pickStart.x, nextpoint.y, // pickStart.z)); trans.setTransform(ourTrans); } } }
I have a world made in 3dMax and imported using a 3ds loader the PROBLEM IS i get
Exception occurred during Behavior execution: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.RangeCheck(ArrayList.java:507) at java.util.ArrayList.get(ArrayList.java:324) at com.sun.j3d.utils.picking.PickResult.getIntersection(PickResult.java:441) at SimpleKeyBehavior.processStimulus(SimpleKeyBehavior.java:83) at javax.media.j3d.BehaviorScheduler.doWork(BehaviorScheduler.java:172) at javax.media.j3d.J3dThread.run(J3dThread.java:250)
very often at Line marked with java comment "//"
If anyone could help me why this exception is thrown or why should the pick results have no intersection even though the result is not null ...that is going to be quite a help
Vijay Dharap, Infosys Technologies Ltd.
---- Introducing Spymac MailPro: http://www.spymac.com/mailpro/
=========================================================================== 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".
---- Introducing Spymac MailPro: http://www.spymac.com/mailpro/
=========================================================================== 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".
