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.
Bookmarks