Cheers. I'm still having difficulties though. When
I go up it works fine, but left, right and back it just stalls the
program?
Here's the methods in question as it is (all
other methods are similar to the original):
I've not used stepper because he tends to shoot off
in the distance if there's a bit of lag
////////////////////////////// START
moveStep()
private void moveStep()
{ float sidestep = 0; float upstep = 0; if (rightDown || leftDown || fwDown || downDown) {
upSum=0;
double stepper = getStep(); Transform3D tempTrans = new Transform3D(); Transform3D ourTrans = new Transform3D(); ourTG.getTransform(ourTrans); if (rightDown || leftDown) { if (rightDown) { //tempTrans.rotY(0-0.2d); sidestep-=0.2; upSum++;
}
else { //tempTrans.rotY(0.2d); sidestep+=0.2; upSum++; } } if (fwDown) { upstep+=0.2; upSum++;
Point3d pickStart=new
Point3d();
Vector3d down = new Vector3d(0.0, -1.0, 0.0); Transform3D newT3d = new Transform3D(); newT3d.setTranslation(new Vector3d(0.0, 1.0, 0.2d)); newT3d.mul(ourTrans); newT3d.transform(pickStart); picker.setShapeRay(pickStart, down); PickResult picked = null; PickIntersection intersect = null; Point3d nextpoint = null; double pickY = 0; try{ picked = picker.pickClosest();
intersect =
picked.getIntersection(0);
nextpoint = intersect.getPointCoordinates(); pickY = (pickStart.y); }catch(Exception fd){return;} pickY = pickY-1.0;
if (nextpoint !=
null)
{ if (nextpoint.y != pickY) { Vector3d translate = new Vector3d(); ourTrans.get(translate); translate.y=nextpoint.y; ourTrans.setTranslation(translate); //ourTrans.setTranslation(new Vector3d(pickStart.x, nextpoint.y, pickStart.z)); } } } if (downDown) { upstep-=0.2; upSum++;
Point3d pickStart=new
Point3d();
Vector3d down = new Vector3d(0.0, -1.0, 0.0); Transform3D newT3d = new Transform3D(); newT3d.setTranslation(new Vector3d(0.0, 1.0, 0.2d)); newT3d.mul(ourTrans); newT3d.transform(pickStart); picker.setShapeRay(pickStart, down); PickResult picked = null; PickIntersection intersect = null; Point3d nextpoint = null; double pickY = 0; try{ picked = picker.pickClosest();
intersect =
picked.getIntersection(0);
nextpoint = intersect.getPointCoordinates(); pickY = (pickStart.y); }catch(Exception fd){return;} pickY = pickY-1.0;
if (nextpoint !=
null)
{ if (nextpoint.y != pickY) { Vector3d translate = new Vector3d(); ourTrans.get(translate); translate.y=nextpoint.y; ourTrans.setTranslation(translate); //ourTrans.setTranslation(new Vector3d(pickStart.x, nextpoint.y, pickStart.z)); } } } tempTrans.setTranslation(new Vector3d(0.0d, sidestep, upstep)); System.err.println(" Stepper is "+stepper); ourTrans.mul(tempTrans); ourTG.setTransform(ourTrans); translateCamera(ourTrans); wakeupOn(keepUpCondition); } } ////////////////////////////// END
moveStep()
////////////////////////////// START
processAWTEvent
private void processAWTEvent(AWTEvent[]
events)
{ for (int n=0;n<events.length;n++) { if (events[n] instanceof KeyEvent) { KeyEvent ek = (KeyEvent) events[n];
if (ek.getID() ==
KeyEvent.KEY_PRESSED)
{ System.err.println("key event "+ek.getKeyChar()); if (ek.getKeyChar() == 'w') { alpha.setStartTime(System.currentTimeMillis()); walking=true; fwDown= true; getStep(); upSum++; } else if (ek.getKeyChar() == 'a') { alpha.setStartTime(System.currentTimeMillis()); walking=true; getStep(); leftDown=true; upSum++; } else if (ek.getKeyChar() == 'd') { alpha.setStartTime(System.currentTimeMillis()); walking=true; getStep(); rightDown=true; upSum++; } else if (ek.getKeyChar() == 's') { alpha.setStartTime(System.currentTimeMillis()); walking=true; getStep(); downDown=true; upSum++; } } else if (ek.getID() == KeyEvent.KEY_RELEASED) { if (ek.getKeyChar() == 'w') { walking=false; fwDown=false; upSum--;
}
else if (ek.getKeyChar() == 'a') { walking=false; leftDown=false; upSum--; } else if (ek.getKeyChar() == 'd') { walking=false; rightDown=false; upSum--; } else if (ek.getKeyChar() == 'e') { walking=false; downDown=false; upSum--; } } } else { System.out.println("event error"); } } ////////////////////////////// START
processAWTEvent
=========================================================================== 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". |
- Re: [JAVA3D] newbie question Michael Newcomb
- Re: [JAVA3D] newbie question Kasparian, Raffi J.
- [JAVA3D] Newbie Question Wileynet
- Re: [JAVA3D] Newbie Question Alessandro borges
- Re: [JAVA3D] Newbie Question Wileynet
- [JAVA3D] Newbie Question FantasyFooty.org
- Re: [JAVA3D] Newbie Question Ben Moxon
- Re: [JAVA3D] Newbie Question FantasyFooty.org
- Re: [JAVA3D] Newbie Question Ben Moxon
- FantasyFooty.org