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 Professional Discussion / Animation, Set Object Interpolation etc (can VanB help?)

Author
Message
adr
22
Years of Service
User Offline
Joined: 21st May 2003
Location: Job Centre
Posted: 24th Jun 2004 02:58 Edited at: 24th Jun 2004 03:00
I thought I'd revive on old post from Fallout. He never really did get an answer and I sure as hell can't find a satisfactory answer.

here's the original post http://www.thegamecreators.com/?m=forum_view&t=2429&b=1 with a measly 2 replies. Someone explain to me, in the most simple terms if it is possible to blend to animations in DBP. I'm not looking for a manual limb rotation work around. From my point of view, blending bone animations should be possible (they did it in the original Tomb Raider game for pete's sake, let alone an engine which is 4, 5 years later?).

Here's the scenario for those who might not be familiar with animation blending.

I have an idle animation of a dude tapping his foot. I have a walk animation. If he's walking, and then all of a sudden I want him to stop walking, it would look crap if the animation just did a hard switch from on to the other. I think you should be able to blend from one to the other so that you don't notice the switch.

Judging from the docs, set object interpolation should have something to do with this, but I can't seem to figure out exactly how to use it. set object frame I'm sure is also involved, but you can't set the object to a frame which doesn't exist! So, that's where I get stuck on my understanding...

Reading this post leads me to believe there's no way to do it in DBP.

I did read another couple of posts which made me think people had done it though. I can't seem to find those (after 20 minutes of searching). However, one of the people who did claim to have an animation blending system working was VanB. I'm not talking about the character aiming system in OIE here - I understand how that works using limb commands. I'm talking about automatic animation transition...

Anyway - Thanks in advance,

Floats like a butterfly, stings like when I pee
twinsengb
21
Years of Service
User Offline
Joined: 17th May 2004
Location: Japan
Posted: 24th Jun 2004 04:58
Object Interpolation - How to use
Isn't it your topic?:http://darkbasicpro.thegamecreators.com/?m=forum_view&t=31001&b=15
I have showed a example of how it works.
We can interpolate between 2 frames using OBJECT INTERPOLATION, so your character will change frames smoothly.

Blending Animations:
If you are referring blend animations as EACH BONE to use different animations, you can't.

If you want to make a character walk/run/jump while shot,etc you can use 2 objects: upper body and lower body. (and the head you can animate rotating bones manually)
Usually a small separation between upper and lower body will not have any problem.

I agree that Blend Animations would be nice, but, in my opinion, It is far of a necessity. This is a feature that most of dbpro programmers will not use... I don't see not even good animated characters in dbgames! Almost nobody uses even object interpolation.. (or don't know what is this!).

A feature that we really need is to use different characters models using the same bone structure. (have many differents characters models using the same animations). But I think it will not be implemented. (maybe it can be done, using some limb commands and extra model)

I hope I have explained the right thing!
adr
22
Years of Service
User Offline
Joined: 21st May 2003
Location: Job Centre
Posted: 24th Jun 2004 13:13 Edited at: 24th Jun 2004 13:16
No, I'm not talking about assigning different animations to different limbs - I appreciate that's quite difficult. If I were trying to do that, then I would do the upper/lower body split idea.

With regards to your reply to my original post, it's kinda odd. I was asking about spline interpolation back then, but you answered this question 6 weeks before I was going to ask it . That's quite some forsight you have there

Quote: "
inc change
if change=1 then set object frame 1,1
if change=30 then set object frame 1,210
"


I would've assumed that this code would have just switched the object's frame to 210. However, If what you're saying there is correct, then when object interpolation is set to 100, and I repeatedly set object frame to 210, then it will transform the current frame's pose to that of frame 210?

erk ... back to work

Floats like a butterfly, stings like when I pee
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 24th Jun 2004 14:51
Apparantly Wolf got the limb angles figured out for his ragdoll system, so this is what I would try.

Firstly figure out them freakin limb angles - they're a right pain, you need to be able to calculate the angles nicely.

Once you have that - build an array, like say your object has 10 limbs - you'd DIM SmoothANIM#(10,3,3) - 10 limbs x 3 frames x 3 axis.

Then, in the first set you store the angles from the current frame, and in the second set the angles from the target frame - to work this out you could use a dummy copy of the model to avoid conflicts but either way you need to set the frames and grab the angles.

Now you'll have noticed that I said 3 frames - well the extra frame data is for the difference between the angles.

Once you have all that - you can set the object to the first frame, and rotate the limbs to 0,0,0 (you'll see why). Rotating the limbs to 0 should reset the effect and return your model to normality - so once you've done that you need to adjust the angles to suit whatever stage in the transition your at. You need a multiplier - which is just a number from 0.0 to 1.0 and that controls the strength of your adjustment, like a strength of 0 will mean a standard first frame, strength of 1.0 will mean a full second frame. The idea is you simply offset each bone by the angles in the extra frame data by the strength.

So...

1) Set the object to the required TARGET frame and reset the angles by rotating them to 0,0,0
2) Grab the real world limb angles and store them in the second set of array data.
3) Do the same with the FIRST frame (no need to reset limb angles again - limb rotations are not permanent)
4) Set the 3rd set of array data to the difference between each frames angles (all angles)
5) Rotate the limbs to suit the strength and the angles in the extra set - like ROTATE LIMB 1,1,SmoothANIM#(1,0,0)*STRENGTH#,SmoothANIM#(1,0,1)*STRENGTH#,SmoothANIM#(1,0,2)*STRENGTH#


That's the only method I can think off that has a chance of working how you'd like - we really need better animation control!.

My smooth animations are really just well organised traditional methods, like making sure start and end frames match up or at least blend to the next animation loop with less jerk.


Van-B


Van-B


The nature of Monkey was irrepressible!.
adr
22
Years of Service
User Offline
Joined: 21st May 2003
Location: Job Centre
Posted: 24th Jun 2004 16:16 Edited at: 24th Jun 2004 16:17
Hmm. Your example is quite complex, to say the least. I can't help but think I must be misunderstanding DBP's native animation commands, because my request is so straightfoward:

Walking -> Stop.

That's it. I'm walking, and then mid-stride I stop walking and (under the current system) my legs jerk back to a standing position in an instant. In the industry, that's widely termed "crap"....

@VanB - So, just to clarify, you're suggesting that I manually move the leg limbs so that they move towards a particular pose?

Floats like a butterfly, stings like when I pee
twinsengb
21
Years of Service
User Offline
Joined: 17th May 2004
Location: Japan
Posted: 24th Jun 2004 16:40
Adr,

Sorry for my bad english, but your doubt is not very clear for me
Anyway, I will try to explain better...

OBJECT INTERPOLATION will interpolate the last/current frame.
object interpolation tips:
100 = very fast (no interpolation) - 1 = very slow (more frames between the 2 frames)
FIRST, You need to SET FRAME. Only LOOP OBJECT will not interpolate!
You can set object interpolation outside the LOOP, only 1 time.
You can use the command SET FRAME only 1 time, and it will interpolate.
OBJECT FRAME() will change(update) AFTER the interpolated animation is over.


EXAMPLE


You need this model to run:
http://www.badnose.com/dbpro/bug_skinnedmesh.zip

(I got this model here:http://darkbasicpro.thegamecreators.com/?m=forum_view&t=33907&b=1)

You can make a better animation system. This example is only to show interpolation working. I took more than 1 hour to make this code, because I didn't also know how to use right that command too! Now I understood well how it work

Quote: "
1) Set the object to the required TARGET frame and reset the angles by rotating them to 0,0,0
2) Grab the real world limb angles and store them in the second set of array data.
3) Do the same with the FIRST frame (no need to reset limb angles again - limb rotations are not permanent)
4) Set the 3rd set of array data to the difference between each frames angles (all angles)
5) Rotate the limbs to suit the strength and the angles in the extra set - like ROTATE LIMB 1,1,SmoothANIM#(1,0,0)*STRENGTH#,SmoothANIM#(1,0,1)*STRENGTH#,SmoothANIM#(1,0,2)*STRENGTH#

My smooth animations are really just well organised traditional methods, like making sure start and end frames match up or at least blend to the next animation loop with less jerk.
"


Van B,

What you are trying to code? I didn't understand what you are explaining... Smooth limb animations?? Spline interpolation??
twinsengb
21
Years of Service
User Offline
Joined: 17th May 2004
Location: Japan
Posted: 24th Jun 2004 16:45 Edited at: 24th Jun 2004 16:45
Walking -> Stop.

You want to do a smooth frame transition between Walking(anyframe) and Stop(start frame)?

If yes, you can use interpolation commands

Set object Frame 1,stopstart
(will interpolate the current frame TO stopstart frame)
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 24th Jun 2004 16:51
Yeah, like you have 2 frames in memory - and you interpolate into the next frame set - but while the animation is running of course. If you image 2 models, 1 walking, 1 running.

If you wanted a third model to be half walking and half running you would work out the average movement between the 2. The idea is the strength variable gets increased until the required animation is playing fully (until strength#=1.0), this system would manually adjust the bones until they matched the target frame - at which point you could reset the adjustments and stop adjusting every loop - at least until the player does something else.


Van-B


The nature of Monkey was irrepressible!.
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 24th Jun 2004 16:57
I think that code would be good if you only have to blend between 2 frames, but having a model loop through an animation and smoothly blend into another animation loop is a different animal totally. I'd be very surprised if DBPro could do that - TGC would be singing and dancing about their animation handling .


Van-B


The nature of Monkey was irrepressible!.
Lampton Worm
22
Years of Service
User Offline
Joined: 4th Sep 2002
Location: United Kingdom
Posted: 24th Jun 2004 17:05
Hi,

@adr - I'm not at my DBP machine, and won't be for a while (especially with the footie tonight...), so no snips yet, but I got the object interpolation command to work. I have Psionic's ninja, exported from cshop, and I can flip between all animation sequences, using interpol to make the switch between sequences smooth, as apposed to the instant change. It took me a while to figure it out, but I got it.

The problems/restrictions I found with it, are that once you are interpolating between two frames, the only interuption you can do is pause/stop, i.e. you can't set a new target frame during the interpol so you have to wait for it to complete before doing another anim. If you have interpol really low, i.e. mega slow/smooth, this will make your charaters animation seem unresponsive, so its a question of balancing this value out along side the anim speed and intertia speed of the player. However, I've found normally interpol is set fairly high so this shouldn't really matter, and isn't overly noticable.

Also I found that some poses can interpol in such a way that limbs go through each other on their way to the target frame, but there ya go. I mean, its basically a smoothing of limb angles, so it's not going to know about limb collisions.

So, its quite cool, and does make basic flipping between anim sequences much nicer, but there are the draw backs above. A system more like half life, using proper blends would be groovy.

I found how I stored the animation data and player data/states was key to implementing it well. For each anim sequence you need to know start and end frames, say in an array. For the player, (s)he needs to have a state. When you change states, i.e. from idle to walk, you need to trigger interpolation. Thats the bit that I got stuck on as I was calling it every loop.

To get it going I had a seperate player interpol_state with three possibilities, 1) not interpolating (ie normal, loop object stuff), 2) interpol initiated, and 3) interpolating.

When a player state changed, interpol is now initiated. I'd use stop object, then set object interoplation, then set object frame (to newstate.startframe), then change the interpol state to 3. State 3 would then check if newstate.startframe had been met, using object frame(obj), and if so, go back to interpol state 1. Something like like.

Some pseudo that may help, sorry about my explanations

oldstate=state
if spacekey()=0 then state=idle
if spacekey()=1 then state=walk
if state<>oldstate
interpol=init
endif

if interpol=normal
play animation normally, loop object etc.
endif

if interpol=init
stop object
set object interpolation 10
set object frame state.walk.startframe
interpol=happening
endif

if interpol=happening
if object frame(player)=state.walk.startframe
set object interpolation to 0
interpol=normal
endif
endif

The key thing, for me at least, was seperating out the interopl. The basics of it are, stop the player, set interpol value, use set object frame, then let DB take the player from where they are to the intended frame. Don't have loop/play object happening while interpol is happening, make sure you stop the player obj before you set a new frame.

This is all from memory, but I hope it helps you in some way for now! I did nearly finish a function to do this, might dig that out and/or make a tutorial.

p.s. I just read a comment in your first post, about setting frame to a frame that doesn't exist. This isn't how it works, you take your current frame, then let DBP interpol to a target frame. That frame has to exist. All interpol does is work out the angles between current_frame and target_frame and then smoothly rotate the limbs to meet their target angles. Just like people do in manual animation systems.

At least you know now that the basics can be done, using the command set, not many commands etc. sorry I can't pass you anything at the moment, work calls.

Cheers.
twinsengb
21
Years of Service
User Offline
Joined: 17th May 2004
Location: Japan
Posted: 24th Jun 2004 17:09 Edited at: 24th Jun 2004 17:09
Oh, I understood what you said (VAN-B)... but it is very complicated for me

If it was me, I would use 4 or 5 animations (for lower body object), and just change the animation (using interpolation).
I prefer to spend work on animation quality than in code because I am very bad to program..hehe. Hey, this system is cool to make facial animations!

A problem that is not solutioned yet is when walking in stairs or turning left/right. It is very hard to make reallistic animations... Even Doom3 or HL2 will have this trouble!

Dbpro animations commands are very confused! hehe...
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 24th Jun 2004 18:11
Yeah, if I was animating a face, interpolation would be ideal - like just have several different expressions and 'tween' between them, I have to do that at some point so I'll definately try interpolation out.

To tell the truth I'm fairly tired of DB animation and would really like something a bit more dynamic. I was thinking that the way we animate is backwards compared to how we actually move. When animating we plonk the guy down and move is legs as if he was walking - I reckon we should be letting the animation decide on the movement. It's be really awesome to have a fighting game where the players move exactly like their animations should make them. That's very doable in DB because we can get the real world location of any bone, and adjust them to suit ourselves - locking feet to the ground, kinetics and jumping should be fairly straightforward. Imagine being able to animate but simply concentrating on the character - not where his foot is gonna be, not that fake floor your pretending you can see, none of the typical orientation worries at all really - just pretend your dude has been pinned to the wall and is pretending to run!.


Van-B


The nature of Monkey was irrepressible!.
adr
22
Years of Service
User Offline
Joined: 21st May 2003
Location: Job Centre
Posted: 24th Jun 2004 20:35 Edited at: 24th Jun 2004 20:39
Excellent - I think I understand. Seems like we've had a lot of input on a troublesome topic. I hope someone else finds this thread useful in the future.

Needless to say, I'll be trying this out later tonight.

@LamptonWorm:
Yeah, I can see the limbs crossing through each other happening, but then again, you shouldn't really be trying to blend two totally different animations. If you need a stop off to stop limb-crossing happening, then you could interpolate between different set poses.

Another potential problem though:

I like using set object frame to animate my characters. It means I can animate independant of machine speed...


But, I can't do that when interpolating across two poses. If I set object interpolation to a value, and then set object frame to try and blend to a new pose, then the amount of time taken to do that will vary depending on machine speed. Put in another way, the number of syncs required to go from one pose to another, given an interpolation rate value, will always take the same number of frames.

Now, how do I cope with that? I need to set the object's interpolation value based on the speed of the machine. set object interpolation objNum, CONST*dTime won't be a good solution. Anyway, like I said, thanks for the help, and I'll try this tonight when I get back from work....

Floats like a butterfly, stings like when I pee
twinsengb
21
Years of Service
User Offline
Joined: 17th May 2004
Location: Japan
Posted: 25th Jun 2004 04:03
Sorry but I don't know how to solve the dTime problem I also would like to know...
I don't use time based movements... (I only lock 60fps). Most of PS2 games run slow when framerate drop..hehe.

P.S. Are you using curvevalue/curveangle?
Lampton Worm
22
Years of Service
User Offline
Joined: 4th Sep 2002
Location: United Kingdom
Posted: 25th Jun 2004 11:56
Hi,

@adr, - ah, the speed thing, good point. So how come "set object interpolation objNum, CONST*dTime" isn't a good solution? Perhaps there is some value tied to timer that would work after some experiments, maybe.

Hope you got it working by the way!

Cheers.
adr
22
Years of Service
User Offline
Joined: 21st May 2003
Location: Job Centre
Posted: 25th Jun 2004 18:10 Edited at: 25th Jun 2004 18:11
@LamptonWorm > DBP will be working out how much to interpolate the frames based on the "set object interpolation value" so if that value is jumping around on a per sync basis, the interpolated limbs will jump around with it.

@Twinsengb > No I'm not using curvevalue. I'm avoiding it because of the same problems described above (to lamptonworm).

I didn't get much (read: anything) done last night. My night was otherwise occupied by a football match which ran on a bit longer than expected.

Floats like a butterfly, stings like when I pee
Lampton Worm
22
Years of Service
User Offline
Joined: 4th Sep 2002
Location: United Kingdom
Posted: 25th Jun 2004 18:24
Ah yup, good point.

p.s. I'm still hungover I've never hurled so much abuse at a TV before.

Login to post a reply

Server time is: 2025-06-06 15:59:47
Your offset time is: 2025-06-06 15:59:47