Time-Based Animation
Hi all...
Using Alex Diener's Time-Based Animation Tutorial, I have tried implementing time-based animation. However, it doesn't appear to be working at all!
Here is my code for MDOpenGLController.h:
And MDOpenGLController.m:
Any help would be really useful! Thanks!
Matt
Using Alex Diener's Time-Based Animation Tutorial, I have tried implementing time-based animation. However, it doesn't appear to be working at all!
Here is my code for MDOpenGLController.h:
Code:
#define kMaxFrameRate 600.0
#define kMinFrameRate 15.0
#define kUpdateInterval (1.0 / kMaxFrameRate)
#define kMaxCyclesPerFrame (kMaxFrameRate / kMinFrameRate)And MDOpenGLController.m:
Code:
- (void)mainTimerFires
{
NSTimeInterval currentTime;
NSTimeInterval updateIterations;
currentTime = [NSDate timeIntervalSinceReferenceDate];
updateIterations = ((currentTime - [self lastFrameTime]) + [self cyclesLeftOver]);
if (updateIterations > (kMaxCyclesPerFrame / kUpdateInterval))
{
updateIterations = (kMaxCyclesPerFrame / kUpdateInterval);
}
while (updateIterations > kUpdateInterval)
{
updateIterations -= kUpdateInterval;
[[self rotatingPyramid] update];
[[self rotatingCube] update];
}
[self setCyclesLeftOver:updateIterations];
[self setLastFrameTime:currentTime];
[[self openGLView] drawFrame];
}Any help would be really useful! Thanks!
Matt
Make the code exist.
Coin Wrote:Make the code exist.that might work.
It's not magic, it's Ruby.
ryan, he's referring to the fact that the code is invisible in the OP... perhaps just in the aqua style?
Silly. Its time based. You have to wait for the code to appear on the page.
Come on. Wait for it.
Come on. Wait for it.
"Yes, well, that's the sort of blinkered, Philistine pig-ignorance I've come to expect from you non-creative garbage."
mdavis1982 Wrote:Hi all...
Using Alex Diener's Time-Based Animation Tutorial, I have tried implementing time-based animation. However, it doesn't appear to be working at all!
Here is my code for MDOpenGLController.h:
Code:
#define kMaxFrameRate 600.0
#define kMinFrameRate 15.0
#define kUpdateInterval (1.0 / kMaxFrameRate)
#define kMaxCyclesPerFrame (kMaxFrameRate / kMinFrameRate)
And MDOpenGLController.m:
Code:
- (void)mainTimerFires
{
NSTimeInterval currentTime;
NSTimeInterval updateIterations;
currentTime = [NSDate timeIntervalSinceReferenceDate];
updateIterations = ((currentTime - [self lastFrameTime]) + [self cyclesLeftOver]);
if (updateIterations > (kMaxCyclesPerFrame / kUpdateInterval))
{
updateIterations = (kMaxCyclesPerFrame / kUpdateInterval);
}
while (updateIterations > kUpdateInterval)
{
updateIterations -= kUpdateInterval;
[[self rotatingPyramid] update];
[[self rotatingCube] update];
}
[self setCyclesLeftOver:updateIterations];
[self setLastFrameTime:currentTime];
[[self openGLView] drawFrame];
}
Any help would be really useful! Thanks!
Matt
DID IT WORK?!?!?!
i quoted him...... sooo yea..... SLEEPY TIME IS NOW!
Here is a quick little demo that clearly shows that the supposed time-based animation code on this page is not working. I was using this method for time based animation, but increasing the MINIMUM_FRAME_RATE causes the animation time to render slower. Go figure. I am working on a solution to this right now. Cheers.
Demo
Press 's' to start. Press the space bar to make the ball jump, and right and left arrow keys to move it. Watch as the background object is not rendered, the framerate, and velocity of the ball increase. To quit, close the window.
I'm running on a 12" TIPowerbook with 256 MiB RAM, stock 32 MBVRAM card.
Demo
Press 's' to start. Press the space bar to make the ball jump, and right and left arrow keys to move it. Watch as the background object is not rendered, the framerate, and velocity of the ball increase. To quit, close the window.
I'm running on a 12" TIPowerbook with 256 MiB RAM, stock 32 MBVRAM card.
Jericho
12-inch PowerBook G4, 640 Ram, no idea VRAM, whatever comes on my machine. I don't notice any problems other than the background isn't painted to the left and the right. Everything else seems to work smoothly. The background object appears just fine in the middle. There's no frame rate lag and the timing appears to be uniform.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Frame Based Animation | Nick | 6 | 3,506 |
Jan 27, 2007 06:25 AM Last Post: 007gamer |
|
| problem with time based animation | ferum | 5 | 2,782 |
Aug 4, 2006 01:45 PM Last Post: ferum |
|

