Jump to content
  • Advertisement
Sign in to follow this  

Quaterion first person style camera

This topic is 874 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

my update function is adding rotation around the view axis(roll),which is increasing over time.I only want to change the yaw and pitch part.

is my calculation wrong or is it the float accuracy?

m_orientation is my global Quaterion to hold the final rotation. Q is type of glm::quat. V is glm::vec3

return [this](glm::vec2 ls, glm::vec2 rs, double dTime) {
auto rightVec = m_orientation * V(1, 0, 0);
Q q1 = glm::angleAxis(-rs.x * (float)dTime, V(0,1,0)); // yaw
Q q2 = glm::angleAxis(rs.y * (float)dTime, rightVec); // pitch

auto roll = glm::roll(m_orientation);
printf("%f\n", roll);

m_orientation = q1 * m_orientation;
m_orientation = q2 * m_orientation;

m_position += m_orientation * V(1, 0, 0) * ls.x * (float)dTime * sensitivity; //sidewards
m_position += m_orientation * V(0, 0, -1) * ls.y * (float)dTime * sensitivity; //forwards

Share this post

Link to post
Share on other sites
Try making these changes

Q q2 = glm::angleAxis(rs.y * (float)dTime, V(1, 0, 0)); // pitch
m_orientation = q1 * m_orientation * q2;

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!