Page 2 of 2 FirstFirst 12
Results 11 to 20 of 20

Thread: Velocity based on angles

  1. #11

    Velocity based on angles

    Quote Originally Posted by NecroDOME
    (I not yet understand them, but they work)
    That's how you are supposed to feel working with quaternions
    Peregrinus, expectavi pedes meos in cymbalis
    Nullus norvegicorum sole urinat

  2. #12
    Legendary Member NecroDOME's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands, Eindhoven
    Posts
    1,059

    Velocity based on angles

    Ill post a screenshot soon of what I have made...
    NecroSOFT - End of line -

  3. #13
    Legendary Member NecroDOME's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands, Eindhoven
    Posts
    1,059

    Velocity based on angles

    1 final question:

    How can I rotate a point (vector).

    Need it to apply correct forces to fly forward with my helicopter (and to rotate te rotor on top)
    NecroSOFT - End of line -

  4. #14
    Legendary Member NecroDOME's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands, Eindhoven
    Posts
    1,059

    Velocity based on angles

    UPDATE: I think I got it working...


    I still need to know how to rotate a point. I want my helicopter to fly forward (or backward), but can it be done with the quaternions? it's flys up in the correct direction. But if I rotate the helicopter 90 degrees, how can I make it fly forward? it only pitches on the Z axis (local space) but need to transform the movement to global space.

    Screenshots I promised:




    3D max rendering


    I need to make the inside of the helicopter and some weapons + skinning...
    NecroSOFT - End of line -

  5. #15

    Velocity based on angles

    Looks pretty damn good!
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  6. #16

    re-

    I am not sure if i understand well what you want, but if you mean how to rotate your helicopter and move forward to the new direction it is now pointing then it is the same method used for any first person shooters.

    * You have a "position" point where you store your current hellicopter position.
    * You have a "forward" unit vector like 0,0,1 (if forward mean moving torward the positive Z), every time you add the forward vector to the position your hellicopter move forward one unit.
    * you store your current rotations for planes x,y,z like rx,ry,rz. you setup your keyboard for increment/decrement Rx,RY,RZ.

    Every time you update your hellicopter new position, you rotate your hellicopter model by rx,ry,rz, using as origin the last position, that will makes your hellicopter head to the desired direction. Then you copy the "forward" vector and you rotate that copy by Rx,Ry,RZ (using as origin always 0,0,0); then you just add this new resulting vector to the last position point for get the new hellicopter position.

    You can have more directions vectors like backward, slide_left, slide_right when rotated a copy of them by your acumulated rx,ry,rx then that copy will always point to the relative hellicopter direcion.

    hope that help

  7. #17
    Legendary Member NecroDOME's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands, Eindhoven
    Posts
    1,059

    Velocity based on angles

    I managed to make it fly forward, backward etc, but I can't get the main rotor in place. The position is correct, but the rotation is a little messed up.
    NecroSOFT - End of line -

  8. #18
    Legendary Member NecroDOME's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands, Eindhoven
    Posts
    1,059

    Velocity based on angles

    Anyone?
    NecroSOFT - End of line -

  9. #19

    Velocity based on angles

    It is your main rotor a different mesh?, if so be sure it's bind pose is located at (0,0,0).

    your rotor normally will be rotated using the Y plane (if Y mean Up in your engine), but when you rotate the whole hellicopter let's say about Z plane then the rotor is rotated in Y and in Z; so it is important to note the Order used for rotate things, you will not get the same result if you rotate first by Z then by Y than doing Y first then Z. that is why i have procedures like Quaternion_Rotation_XYZ and Quaternion_Rotation_YXZ, etc.

  10. #20

    Velocity based on angles

    This is taken from FastGeo.
    These routines rotate a 3D point around another 3D point (origin).

    FastGeo provides many useful calculations for 2D and 3D (so maybe other problems can be solved using it, too).



    Code:
    interface
    procedure Rotate&#40;const Rx,Ry,Rz&#58;TFloat; const x,y,z&#58;TFloat; out Nx,Ny,Nz&#58;TFloat&#41;;                                              overload;
    
    procedure Rotate&#40;const Rx,Ry,Rz&#58;TFloat; const x,y,z,ox,oy,oz&#58;TFloat; out Nx,Ny,Nz&#58;TFloat&#41;;                                     overload;
    
    function Rotate&#40;const Rx,Ry,Rz&#58;TFloat; const Point&#58;TPoint3D&#41;&#58;TPoint3D;                                                         overload;
    
    function Rotate&#40;const Rx,Ry,Rz&#58;TFloat; const Point,OPoint&#58;TPoint3D&#41;&#58;TPoint3D;                                                  overload;
    
    
    
    implementation
    
    ///////////Rotation around axis origin &#40;0,0,0&#41;
    
    procedure Rotate&#40;const Rx,Ry,Rz&#58;TFloat; const x,y,z&#58;TFloat; out Nx,Ny,Nz&#58;TFloat&#41;;
    var
      TempX   &#58; TFloat;
      TempY   &#58; TFloat;
      TempZ   &#58; TFloat;
      SinX    &#58; TFloat;
      SinY    &#58; TFloat;
      SinZ    &#58; TFloat;
      CosX    &#58; TFloat;
      CosY    &#58; TFloat;
      CosZ    &#58; TFloat;
      XRadAng &#58; TFloat;
      YRadAng &#58; TFloat;
      ZRadAng &#58; TFloat;
    begin
      XRadAng &#58;= Rx * PIDiv180;
      YRadAng &#58;= Ry * PIDiv180;
      ZRadAng &#58;= Rz * PIDiv180;
    
      SinX    &#58;= Sin&#40;XRadAng&#41;;
      SinY    &#58;= Sin&#40;YRadAng&#41;;
      SinZ    &#58;= Sin&#40;ZRadAng&#41;;
    
      CosX    &#58;= Cos&#40;XRadAng&#41;;
      CosY    &#58;= Cos&#40;YRadAng&#41;;
      CosZ    &#58;= Cos&#40;ZRadAng&#41;;
    
      Tempy   &#58;= y * CosY -     z * SinY;
      Tempz   &#58;= y * SinY +     z * CosY;
      Tempx   &#58;= x * CosX - Tempz * SinX;
    
      Nz      &#58;=     x * SinX + Tempz * CosX;
      Nx      &#58;= Tempx * CosZ - TempY * SinZ;
      Ny      &#58;= Tempx * SinZ + TempY * CosZ;
    end;
    &#40;* End of Rotate 3D Point *&#41;
    
    
    ///////////Rotation around 3D point &#40;x,y,z&#41;  -> This may be what you need
    
    procedure Rotate&#40;const Rx,Ry,Rz&#58;TFloat; const x,y,z,ox,oy,oz&#58;TFloat; out Nx,Ny,Nz&#58;TFloat&#41;;
    begin
      Rotate&#40;Rx,Ry,Rz,x - ox,y - oy,z - oz,Nx,Ny,Nz&#41;;
      Nx &#58;= Nx + ox;
      Ny &#58;= Ny + oy;
      Nz &#58;= Nz + oz;
    end;
    &#40;* End of Rotate 3D Point About Origin Point *&#41;
    
    ///////////Just other declarations with TPoint3D types
    function Rotate&#40;const Rx,Ry,Rz&#58;TFloat; const Point&#58;TPoint3D&#41;&#58;TPoint3D;
    begin
      Rotate&#40;Rx,Ry,Rz,Point.x,Point.y,Point.z,Result.x,Result.y,Result.z&#41;;
    end;
    &#40;* End of Rotate 3D Point *&#41;
    
    
    function Rotate&#40;const Rx,Ry,Rz&#58;TFloat; const Point,OPoint&#58;TPoint3D&#41;&#58;TPoint3D;
    begin
      Rotate&#40;Rx,Ry,Rz,Point.x,Point.y,Point.z,OPoint.x,OPoint.y,OPoint.z,Result.x,Result.y,Result.z&#41;;
    end;
    &#40;* End of Rotate 3D Point About Origin Point *&#41;
    Hope this helps.

    Greetings,
    Dirk
    <a href="http://www.greatgamesexperiment.com/game/Valgard/?utm_source=gge&amp;utm_medium=badge_game"><img border="0" alt="GGE" title="GGE" src="http://static.greatgamesexperiment.com/badge/game/valgard/gge400x56.png"></a>

Page 2 of 2 FirstFirst 12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •