Skip to main content
gamedev.net
🔒 Locked

Camera Track

Started by PumpkinPieman Jan 4, 2005 at 12:38 AM 1 replies 600+ views
Original Post
PumpkinPieman
PumpkinPieman
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;
}

JohnBolton
JohnBolton
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.
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
PumpkinPieman
PumpkinPieman
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++;

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.