Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

rash

How to Convert a float value into D3DXVECTOR3?

This topic is 5401 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, I m using Directional Control(1st Person Camera) for my game. I m using float value which indicates the direction of camera and the NPCs like one in the RPG book by Jim. I want to use D3DXVECTOR3 for direction in a particular situation so how can i convert that float value into that vector. Thanks for yours help!

Share this post


Link to post
Share on other sites
Advertisement
You''ll find it tough to do that... the best you can manage would be to take the vector (0,0,1) and rotate it about the Y axis using your float value. It''ll be 2D, though, not 3D; you''d need two float values to make it 3D.

Share this post


Link to post
Share on other sites
Hmmm... *pulls out old Algebra II notes from matrix transformations*

x = cos( θ ) - sin( θ )
y = cos( θ ) + sin( θ )

Note that the above deals with clockwise rotations. If you want counter-clockwise rotations you just switch the positive and negative sins making it

x = cos( θ ) + sin( θ )
y = cos( θ ) - sin( θ )

Nope that helps!

Also, if you intend to make it 3D (based on spherical coordinates with a radius of one) I can give you formulas for those too... You can either PM me or post and pray I see it .

Hope I was of some help.

- ms

Edit: my darn theta's turned into s.

[edited by - ms291052 on March 1, 2004 6:01:49 PM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!