Hi,
 
I've asked several questions in different threads in java3D forums and this mailing list. I got many answers and suggestions, that have helped to make what you can see in this examples:
1. Only ship moves and rotates:
http://www.kingsware.de/j3d/gameRot2.zip (use mouse for rotation, strg for Fwd-movement and the Arrowkeys for Sliding up/left/right/down)
2. The ship rotates and moves and the view follows:
http://www.kingsware.de/j3d/gamerot3.zip (use mouse for rotation, strg for Fwd-movement and the Arrowkeys for Sliding up/left/right/down)
 
In the first example you can see, that my ship rotates correctly around his local x- and y-axis and moves relatively to the rotation!!! So this problem is solved!!!
In the second example you can see that the View seems to follow the ship correctly, because the ship is everytime at the same point in the window and even the Perspective to the ship doesn't change. But although I didn't change the Movement & rotation code of my Ship (processShipTransform), both ship and view don't rotate and move correctly!
 
Problems:
1. There is a rotation around the z-axis when you try to rotate up and down. This problem exists only when you had rotated to the left or to the right (around the x-axis) first. So only at a "x-rotation != 0" the ship and view rotates around the z-axis to!
2. Movement and rotation is stuttering, when using wakeupOnElapsedFrames and the movement and rotation depends on passed time between frames(e.g. MeterPerSecond/FramesPerSecond).  
   2.1 Movement/Rotation without using the timebased movement does NOT flicker(e.g. MeterPerSecond/CONSTANTFRAMERATE).
   2.2 When using WakeupOnElapsedTime(40) this problem does not exist, but updaterate wouldn't depend on machinespeed anymore!
3. The View follows the ship directly. I'd like to have smoothed camera movement. The View should accelerate a littlebit slower than the ship (rotation & movement)
 
here is a littlebit code used in the second example(at the end of this email)! The only difference to the first example is that there is an empty Transform3D returned by "processViewTransform"!
 
It would be nice if anyone could help me with this small mistakes (perhaps reply a little codecorrection
Wink)!
 
Thanks to all of you (especially endolf)!
 
Don't have a too deep look at my bad English, please!
I'm not only learning Java3d at all Wink!  
 
Greets,
Juan

 

Code:


private Transform3D processShipTransform(float fps) {
  //The change of position! x1, x2... is set in another method
  positionChange.x = x1 + x2;
  positionChange.y = y1 + y2;
  positionChange.z = z;
 
  /* The rotation! rY = -(e.getY()-(height/2)) and rX = ((e.getX()-(width/2)) (form the MouseEvent) */
  xAngle += (rY/(100.0f*fps)); // * yFactor;
  yAngle += -(rX/(100.0f*fps)); // * xFactor;
   
  //Rotation
  rotX3d.rotX(xAngle);
  rotY3d.rotY(yAngle);
  rotZ3d.rotZ(0.0f);
  rotXY3d.mul(rotX3d, rotY3d);
  rotXYZ3d.mul(rotXY3d, rotZ3d);
   
   
  //Die rotation an vpShipTrans3d weitergeben
  vpShipTrans3d = new Transform3D(rotXYZ3d);
   
  //Füge die Rotation in die Bewegung ein!!!
  rotXYZ3d.transform(positionChange);
   
  newPosition.x = oldPosition.x + positionChange.x;
  newPosition.y = oldPosition.y + positionChange.y;
  newPosition.z = oldPosition.z + positionChange.z;
   
  oldPosition.x = newPosition.x;
  oldPosition.y = newPosition.y;
  oldPosition.z = newPosition.z;
 
  rotXYZ3d.setTranslation(newPosition);
   
  return rotXYZ3d;
}/*Motion of the Ship END */  


 
Code:


 //Move the view
 private Transform3D processViewTransform(float fps) {  
  //Rotation
  vpXAngle += (rY/(100.0f*fps));  
  vpYAngle += -(rX/(100.0f*fps));
   
   
  vpRotX3d.rotX(vpXAngle);
  vpRotY3d.rotY(vpYAngle);
  vpRotZ3d.rotZ(0.0f);
  vpRotXY3d.mul(vpRotX3d, vpRotY3d);
  vpRotXYZ3d.mul(vpRotXY3d, vpRotZ3d);
   
  vpLocalPosition.x = vpSTARTX; //0.0f;
  vpLocalPosition.y = vpSTARTY; //50.0f;
  vpLocalPosition.z = vpSTARTZ; //130.0f;
   
  vpShipTrans3d.transform(vpLocalPosition);
   
  vpNewPosition.x = newPosition.x + vpLocalPosition.x;  
  vpNewPosition.y = newPosition.y + vpLocalPosition.y;  
  vpNewPosition.z = newPosition.z + vpLocalPosition.z;  
   
  vpRotXYZ3d.setTranslation(vpNewPosition);
   
  return vpRotXYZ3d;
 
 }//END processViewTransform


 
Code:


 public void update(float fps) {
   //Move & rotate the Ship
   trans3D = processShipTransform(fps);
   //Move & rotate the View (follow the ship)
   vpTrans3D = processViewTransform(fps);
 
   //Update the Transformgroups of the View and the Ship!
   
vpTrans.setTransform(vpTrans3D);
   //Der Ziel-TransformGroup die Position einspeisen ;)  
   targetTG.setTransform(trans3D);
 }

 

You can see more code at http://www.javagaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=3D;action="">! Please don’t use the code for your own commercial products!!!

=========================================================================== 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".

<<image001.gif>>

Reply via email to