XNA Creators Club Online
Page 1 of 1 (2 items)
Sort Posts: Previous Next

Design question + quaternion problem

Last post 4/17/2007 5:30 PM by LamoThe31st. 1 replies.
  • 4/17/2007 12:54 PM

    Design question + quaternion problem

    I'm designing a game where the player will walk along a globe. I'm trying to decide if it's easier to move the player on the globe or fake the movement by actually rotating the globe underneath the player.

    I decided to do the latter and the code for it is confusing me. mainly because i want the globe to rotate around the world axis and not the globes axis. If i press up on the thumbstick i want the top of the globe to always come towards me and if i press Left i want the left of the globe to always come twords me.

    I've tried using euler rotations but if the model is flipped by moving 180 degrees on one axis, then one of the other axis will be flipped.

    I've also tried using quaternions for rotation, but i dont understand them enough to do the rotations correctly.

    my question is should i stick with this method of rotating the globe? if so how do i set the globes rotation so the controls act as wanted?

    The more i think about it the more i am starting to think that i might just want to move the player model and link the camera to the player. But i can't think of what math to use to set the player model's position so it is a certain distance from the center of the globe and so the rotation is always set so the down axis is always pointed at the center of the globe.

    basicly, i'm a noob and i need help. :(

  • 4/17/2007 5:30 PM In reply to

    Re: Design question + quaternion problem

    i figured out how to do the rotations. The tutorial i was trying to figure out quaternions from used 3 axis; yaw, pitch and roll. Took me most of the day thinking to realize i didn't need to rotate on more than one axis to rotate on. I got the axis by doing through user input.

    Vector3 rotAngle = new Vector3(currentState.ThumbSticks.Left.Y, (currentState.ThumbSticks.Left.X * -1), currentState.ThumbSticks.Right.X);

    Once i had the vector i had to make the quaternion based on that.

    Quaternion rot = Quaternion.Normalize(Quaternion.CreateFromAxisAngle(rotAngle, stickMovement));

    stickMovement i got from getting the absolute value of each thumbstick and using the highest value of the 3.

    I never would have figured this out if it wasn't for Brandon Sharp's website. http://www.sharpwebsolutions.ca/programming/xna_game/ball_roll.html

    WOOT!!!

Page 1 of 1 (2 items) Previous Next