Results 1 to 10 of 18

Thread: Direction between 2 Vectors

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    Dan, exactly the answer I needed, this is not the first time your post/replies have saved me from myself, I can't thank you enough but thank you very much

    @User137, Thanks for your reply, your function will also be useful for other purposes. Thanks.

    So my code so far (which works)

    Code:
    //
    // sets the look at target of the camera
    //
    procedure TCameraController.setTarget(const targ: TD3DXMatrix);
    var
      pos, rV: TD3DXVector3;
      diff: TD3DXVector3;
    begin
      pos := D3DXVector3(targ._41, targ._42, targ._43);
    
      D3DXVec3Subtract(diff, pos, position);
      D3DXVec3Normalize(diff, diff);
    
      rV := D3DXVector3(
                arctan2(diff.z, diff.x),
                arcsin(diff.y),
                diff.z
              );
    
      D3DXVec3Lerp(rotation, rV, rotation, 0.1);
    end;
    my only problem now is using the DX function MatrixLookAt for matView seems to have a rotation limit on the yaxis.
    Last edited by Colin; 15-11-2012 at 03:11 PM.
    Download the Ziron Assembler
    Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.

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
  •