Jump to content
  • Advertisement
Sign in to follow this  
PumpkinPieman

Camera Track

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

I've been looking over this function and I'm not sure what type of values supplied to it will serve the purpose that I think it does.
BOOL cCamera::Track(float Time, float Length)
{
  float x, y, z;
  float TimeOffset;

  TimeOffset = Length * Time;

  x = (m_EndXPos - m_StartXPos) / Length * TimeOffset;
  y = (m_EndYPos - m_StartYPos) / Length * TimeOffset;
  z = (m_EndZPos - m_StartZPos) / Length * TimeOffset;
  Move(m_StartXPos + x, m_StartYPos + y, m_StartZPos + z);

  x = (m_EndXRot - m_StartXRot) / Length * TimeOffset;
  y = (m_EndYRot - m_StartYRot) / Length * TimeOffset;
  z = (m_EndZRot - m_StartZRot) / Length * TimeOffset;
  Rotate(m_StartXRot + x, m_StartYRot + y, m_StartZRot + z);

  return TRUE;
}

Share this post


Link to post
Share on other sites
Advertisement
The math is weird. The value of Length is irrelevant (as long as it isn't 0), so I don't know what it means.

If you just want to use the function, set Length to any value other than 0, and set Time to a number between 0 and 1. When Time is 0, the camera will be at its starting position and orientation. When Time is 1, the camera will be at its final position and orientation.

That is probably not how the parameters are intended to be set, but the math doesn't make sense, and that will work.

Now, if the code were written as follows, then it would make a lot more sense:
  TimeOffset = Time / Length;

x = (m_EndXPos - m_StartXPos) * TimeOffset;
...

x = (m_EndXRot - m_StartXRot) * TimeOffset;
...
In this code, Time is the elapsed time of the transition, and Length is the total time of the transition.

Share this post


Link to post
Share on other sites
Yeah, that makes a hell of alot more sense than this does. I was just staring at wondering what exactly he was hoping to accomplish, for some reason when my brain gets stuck on someone elses code it decides to figure it out rather then finding ways around it.

R++;

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!