Sign in to follow this  
MARS_999

Rotate from one point to face another at XYZ coordinate

Recommended Posts

Not sure if the title works, but anyway....

I have my turret facing some direction, and I want to click on a object and have it point towards that object but it will need to rotate up on also not just XZ planes. So maybe I am making this harder than it needs to be, but any ideas would be great.

I am using CML and I have tried this

cml::matrix_rotation_aim_at(alignMatrix, cml::vector3f(0.0f, 0.0f, 0.0f), targetVector, cml:: axis_order_xyz);

and works but not correct. The turret will not keep its position and rotate accordingly. e.g. the turret will sometimes rotate on y 90 and then face the target(looks like its leaning on its side)

So I am out of ideas here....

Share this post


Link to post
Share on other sites
An image would probably go a long way here, I'm having a hard time exactly grasping what kind of rotation you desire.

I'm imagining a turret that could rotate 360 degrees and maybe point up/down, if that's your case it seems like the easiest thing would just be to totally decouple the up/down pitching from the XZ rotation.

So every step of the interpolation you would just do:

1) Rotate on the xz axis
2) Pitch up/down in the local space

I'd keep the direction and pitch as separate variables and then just reconstruct the final transformation matrix each frame from these values.

Is this the kind of situation you're going for?

Share this post


Link to post
Share on other sites
[quote name='karwosts' timestamp='1298232105' post='4776768']
An image would probably go a long way here, I'm having a hard time exactly grasping what kind of rotation you desire.

I'm imagining a turret that could rotate 360 degrees and maybe point up/down, if that's your case it seems like the easiest thing would just be to totally decouple the up/down pitching from the XZ rotation.

So every step of the interpolation you would just do:

1) Rotate on the xz axis
2) Pitch up/down in the local space

I'd keep the direction and pitch as separate variables and then just reconstruct the final transformation matrix each frame from these values.

Is this the kind of situation you're going for?
[/quote]

Thanks for the reply, Yeah that may work, but I found I needed a reference vector for my axis, in this case (0,1,0) and now it works great!

Thanks

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this