# 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.

## 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 on other sites
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 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++;

1. 1
Rutin
29
2. 2
3. 3
4. 4
5. 5

• 13
• 13
• 11
• 10
• 13
• ### Forum Statistics

• Total Topics
632959
• Total Posts
3009467
• ### Who's Online (See full list)

There are no registered users currently online

×