Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / animation demo (and question)

Author
Message
29 games
18
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 14th Sep 2010 23:51
I am or rather was making the slow transition over to DBP, until I discovered the key frame commands in DBC (which are missing from DBP).

So I came up with this demo.





What should happen is that when the upkey is pressed the animation plays, which works fines. When the upkey is released the animation stops and the figure returns to its original standing pose. However, if I time it right and release the upkey just before the last keyframe of the animation (as the right foot comes fully forward) the figure becomes stuck in that pose.

I can't work out why this should be, does anyone have any ideas?

Thanks.
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 15th Sep 2010 19:20
Don't leave DBC! eh hemm... I've composed myself now.

What I think may be happening could be a result of the value of your keyframes. The reason these frames are called KEYFRAMEs, is because they are a key point in an animation. An animation is interpolated between keyframes. That is, whatever movement is suggested in between each keyframe, the computer fills is the extra movement computationally. You could, therefore have animations that run frames 1, 1.2, 1.4, 1.6, 1.8, 2, 2.2, etc.

Depending on the frame rate of the animation and the interpolation rate (as well as the FPS of the program), it may be possible that a frame calculated in between keyframes can be undefined. In the case of your last frame trying to loop around to the beginning, there may be enough time in between the loop from the last key to the first key where DB tries to interpolate a frame. Since there is no key after 7 in your example, it may be getting hung up on some weird value it came up with.

This is getting much wordier than I had planned and there's still more to come!

Your keyframes are very close together: 1,2,3,4,5,6,7 - and that allows for very little interpolation (based on the speed of the animation). That's fine. But here's where I think DBC runs into some problems.

Two things to try:
1. Set your key frames higher. Instead of 1,2,3,4,5,6,7, use 1,10,20,30,40,50,60 . That will smooth out the animation and allow you to see anything that doesn't look quite right. Also in this scenario, loop to frame 59. That will allow a little wiggle room in the release time of the up key . You probably won't be able to notice much difference between frames 59 and 60. If you want a little more time, set the last keyframe to 61 and loop to 60. That will balance it out a little differently but will slow down the last 10 frames (not noticeably) a teeny tiny bit.

2. Instead of using loop object, use play object and manage the looping yourself. I've run into trouble in the past using loop object. Play object allows for much more direct control.

And I like that you build your own meshes! That's a pretty cool looking ?robot? !

Enjoy your day.
29 games
18
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 15th Sep 2010 22:18
Thanks for the reply, I'll give your suggestions a go over the weekend.

I've been struggling with the whole 3D modelling, animation, texturing and so on, which is an odd as I use engineering 3D CAD software all the time (it's part of my job!). Figureing out memblocks and meshes has opened up DBC and allows me to concentrate on playing around with things that I'm interested.

I don't know if the figure is a robot or a person in armour. I don't think I'll ever know.

Although I'm playing around with DBP (easier now there's a free version) but I've decided to stick with DBC for some larger projects that I'm planning.

I've got to say though, I do feel that I've turned up late to the party.
LBFN
16
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 16th Sep 2010 18:00
Wow! Very impressive work! To me, it seems like the 3D modeling, animation, etc. would be a lot less work than this (unless maybe you're using Blender).

I was not able to duplicate the error that you saw.

So many games to code.......so little time.
29 games
18
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 20th Sep 2010 23:25
You're probably right about making and animating models but I think I just like playing around with DBC. Somehow coding meshes just seems more fun.

Back to the original question. Something funny is going on as I now can't replicate the problem I was having (I also had a maths collision demo that was achieving 10 FPS but then one day jumped to 60 FPS and now always achieved 60 FPS). I'm assuming it's resolved itself in a "hand-of-god" kind of way.

However, I still had a go with spacing out the keyframes but this just slowed the animation down. I've had a look in the help files but couldn't figure out how to speed it up. Is this possible and do you have any ideas?
LBFN
16
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 21st Sep 2010 00:26
Use SET OBJECT SPEED to make it go faster. I took your original code and used SET OBJECT SPEED with it, but it plays much faster than anything I've seen with boned animations. If I set it at around 5, it is pretty decent.

Computers do exactly what you tell them.........don't you hate that sometimes?
29 games
18
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 21st Sep 2010 01:50
Thanks for that, couldn't find it in the help files for looking.

I just had a quick play at spacing out the keyframe and adjusting the speed using SET OBJECT SPEED and it seems to give the control I'm after.

I'll have a play during the week and post what I come up with.

Thanks
LBFN
16
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 21st Sep 2010 02:37
Glad it helped. Looking forward to seeing what you come up with.

Computers do exactly what you tell them.........don't you hate that sometimes?

Login to post a reply

Server time is: 2024-03-29 04:39:44
Your offset time is: 2024-03-29 04:39:44