Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Game Development

Reply
 
LinkBack Thread Tools Display Modes
Old 09-27-2010, 05:46 PM   #1 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 2
Inaop is on a distinguished road
Default OpenGL ES Keyframe Animation issue

Hey there, guys.

I'm having trouble with implementing keyframe animation on iPhone.

I originally based it on Jeff LaMarche's sample. In the example below I have three keyframes, it goes from the first through the second one, but then keeps going between the second and the third.

Here's the code:

Code:
if (lastKeyframeTime == 0.0) lastKeyframeTime = [NSDate     timeIntervalSinceReferenceDate];

NSTimeInterval timeSinceLastKeyFrame = [NSDate timeIntervalSinceReferenceDate] - lastKeyframeTime;

NSTimeInterval percentDone;


if (timeSinceLastKeyFrame > kAnimationDuration) {

++curFrame;
if (curFrame > numFrames-1)
curFrame = 0;

timeSinceLastKeyFrame = timeSinceLastKeyFrame - kAnimationDuration;
lastKeyframeTime = [NSDate timeIntervalSinceReferenceDate];
}

percentDone = timeSinceLastKeyFrame / kAnimationDuration;

source = animverts[curFrame];
dest = animverts[curFrame+1]; 
if ( curFrame == numFrames - 1)
dest = animverts[0];

for (int i = 0; i < (numIndices*3); i+=3) {
GLfloat diffX = dest[i] - source[i];
GLfloat diffY = dest[i+1] - source[i+1];
GLfloat diffZ = dest[i+2] - source[i+2];
curverts[i] = source[i] + (percentDone * diffX);
curverts[i+1] = source[i+1] + (percentDone * diffY);
curverts[i+2] = source[i+2] + (percentDone * diffZ);
}
then I update my VBO with curverts

What am I missing here?
Inaop is offline   Reply With Quote
Old 09-27-2010, 07:40 PM   #2 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 22
coded is on a distinguished road
Default

hmm I'm not an expert but I'll try to help...

umm did you indent on where its suppose to be indented?

if ( curFrame == numFrames - 1)
dest = animverts[0];

maybe you should change it to

if ( curFrame == numFrames - 1) dest = animverts[0];

Also, do you have

Jeff LaMarche's sample? Maybe it will help us to help you.
__________________
000000000000000000000000000000000000000000
1111111110011111000111110001111100111110000
111000000001100011011 00 1101100000110011000
111000000011000011011 0001101111100110001100
111000000011000011011 0001101100000110000110
111111111 0011111100111111001111100111111100
00000000000000000000000000000000000000000000
coded is offline   Reply With Quote
Old 09-28-2010, 06:40 AM   #3 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 2
Inaop is on a distinguished road
Default

I doubt indents matter, but they're fine in my XCode, it's just the way i pasted it here.

anyway here's the sample I was talking about:

iPhone Development: OpenGL ES from the Ground Up Part 9a: Fundamentals of Animation and Keyframe Animation

so like i was saying, I'm trying to make 3 frames to work now. after the last one it's supposed to start with the first frame, but for some reason gets stuck going between second and the third.
Inaop is offline   Reply With Quote
Reply

Bookmarks

Tags
iphone, keyframe animation, opengl es

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 408
10 members and 398 guests
7twenty7, ChrisYates, djohnson, gmarro, hussain1982, Kirkout, Retouchable, SLIC, walex, xzoonxoom
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,679
Threads: 94,128
Posts: 402,921
Top Poster: BrianSlick (7,990)
Welcome to our newest member, xzoonxoom
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 08:08 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0