Inverse Kinematics animations for Spring in Blender

Inverse Kinematics animations for Spring in Blender

Resources to get you going on your new project, or to help you over some emergent problems during your development cycle.

Moderator: Moderators

Post Reply
User avatar
Beherith
Moderator
Posts: 4957
Joined: 26 Oct 2007, 16:21

Inverse Kinematics animations for Spring in Blender

Post by Beherith »

Here we are, dragging BOS/COB animations into 2020 with a set of plugins that allow the following:

1. Import an S3O model directly into Blender
2. One-click convert the s3o into an animateable skeleton with Inverse Kinematics
3. One-click export into a BOS file for variable speed animation

https://github.com/Beherith/Skeletor_S3O

Full documentation available on the github link as well!

Using this tool is an easy and powerful way to create very pretty walk, idle, death animations for units!

Link to tutorial video: https://www.youtube.com/watch?v=DaMLNfOR6KU

Image
skeletor_s3o.png
(760.44 KiB) Not downloaded yet
6 x

User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6179
Joined: 29 Apr 2005, 01:14

Re: Inverse Kinematics animations for Spring in Blender

Post by FLOZi »

Awesome.


Why the hell BOS?
0 x

User avatar
Beherith
Moderator
Posts: 4957
Joined: 26 Oct 2007, 16:21

Re: Inverse Kinematics animations for Spring in Blender

Post by Beherith »

Cause i'm used to it. You can change out the lines to lua, or just convert it, or even submit a PR ;)
0 x

User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6179
Joined: 29 Apr 2005, 01:14

Re: Inverse Kinematics animations for Spring in Blender

Post by FLOZi »

I imagine there are lots(!) of lines generated which would be tricky to convert by hand. Got a sample of exported bos?
0 x

User avatar
Beherith
Moderator
Posts: 4957
Joined: 26 Oct 2007, 16:21

Re: Inverse Kinematics animations for Spring in Blender

Post by Beherith »

Walk(), Stopwalking() and Unitspeed() are straight up auto generated by the script:


https://github.com/beyond-all-reason/Be ... 67591e6a3
0 x

User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6179
Joined: 29 Apr 2005, 01:14

Re: Inverse Kinematics animations for Spring in Blender

Post by FLOZi »

Relatively clean output. I'm guessing that each 'if bMoving' section is a frame of the animation?



p.s. Why not using signals?
0 x

User avatar
Beherith
Moderator
Posts: 4957
Joined: 26 Oct 2007, 16:21

Re: Inverse Kinematics animations for Spring in Blender

Post by Beherith »

Yep, its clean as a whistle. Each bmoving is a frame.

Note how animspeed uses integer division to always have perfectly smooth interpolation.

On signals, why use them when they are not needed? Could you elaborate on why they would be a good thing here?
0 x

User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6179
Joined: 29 Apr 2005, 01:14

Re: Inverse Kinematics animations for Spring in Blender

Post by FLOZi »

IMO an approach using signals is better than OTA style 'if bMoving' for getting smooth transitions and avoiding 'walking on the spot when stopping'.

I suppose it's because it can kill a thread instantly rather than waiting for a frame to complete. I took the approach with MCL and again, IMO, it works better. My frame of reference was previous S44 and IW bos walk scripts and OTA 3rd party ones so ymmv. It was common to see 'ice skating' / 'walking on the spot at end of stop moving' type errors in scripts of that era with the bMoving approach. Probably it depends on the play duration of the keyframe; with an automated process you can have many, short frames and might not see any problems.

https://github.com/SpringMCLegacy/Sprin ... /Atlas.lua
https://github.com/SpringMCLegacy/Sprin ... h.lua#L424 to 473 relevant.


What's great about your tool (as opposed to Anarchid's table-heavy approach) is that it is easy to adapt to any animation control logic. :-)
0 x

User avatar
Beherith
Moderator
Posts: 4957
Joined: 26 Oct 2007, 16:21

Re: Inverse Kinematics animations for Spring in Blender

Post by Beherith »

On the 'wait for the frame to complete' part:

I think my current implementation of bMoving with StopWalking () being called from StopMoving() also does not wait for a frame, since:
StopWalking() commands all pieces to return to their default state immediately, and this overwrites any previous commands from Walk().

I'm trying to avoid many short frames, and use good interpolation because:
1. longer frames are easier to scale with unit movement speeds
2. Less frequent frames = better performance?

Am I thinking correctly here?

Is there any guarantee what order threads will be executed in? Because I was thinking along the following:

Code: Select all


UnitSpeed(){
	set-signal-mask SIG_WALK;
	while(TRUE){
		set animspeed;
		sleep animspeed;
	}
}

StartMoving(){
	start-script UnitSpeed();
	start-script Walk();
}

StopMoving(){
	signal SIG_WALK;
	call-script StopWalking();
}
The key here being that animspeed would thus be updated exactly on time. Or should I just update animspeed from Walk() as it doesnt matter?
0 x

User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6179
Joined: 29 Apr 2005, 01:14

Re: Inverse Kinematics animations for Spring in Blender

Post by FLOZi »

It is quite some time since I did the motion control logic for MCL, so my arguments may be from incorrect recollection of the problems I had, but note the total absence of the MotionControl function you are using (Which is a decompiled version of an OTA script, hence the terrible variable names!).

I'm not convinced that your StopWalking will immediately terminate any animation and reset to default but I am quite willing to be wrong as I assume you tested it pretty thoroughly. :P You use only Sleep and not WaitFor so perhaps that was my problem with animations interfering with one another.

On paper #2 is correct but there are so many confounding variables I wouldn't expect a huge difference in performance.

I wouldn't bank on their being a a guaranteed thread order but I don't know.

A quick glance at my own code suggests it probably isn't accounting for speed modifiers correctly though I would have thought someone might have noticed. :(
0 x

User avatar
Beherith
Moderator
Posts: 4957
Joined: 26 Oct 2007, 16:21

Re: Inverse Kinematics animations for Spring in Blender

Post by Beherith »

I've had no issues with bMoving even without signaling terminating anims on time, and I look very closely at them.

Thanks for the help, i was just trying to avoid function calls from Walk() (for clean looks), which is why I didnt want to UpdateSpeed from it.

Wait-for-x should be reserved for truly variable thing like heading.
0 x

SpikedHelmet
MC: Legacy & Spring 1944 Developer
Posts: 1948
Joined: 21 Sep 2004, 08:25

Re: Inverse Kinematics animations for Spring in Blender

Post by SpikedHelmet »

Getting an error trying to import any of my s3os:
Traceback (most recent call last):

File: ..."s3o_import.py", line 501, in execute if not context.scene.objects.active:
AttributeError: 'bpy_prop_collection' object has no attribute 'active'

location <unknown location>:-1
It also happens if I don't even select an .s3o file and just hit Import. Line 501 is also empty.
0 x

User avatar
Beherith
Moderator
Posts: 4957
Joined: 26 Oct 2007, 16:21

Re: Inverse Kinematics animations for Spring in Blender

Post by Beherith »

Which blender version? this is for 2.82

So you cant even import a model with the Spring ZY import?
0 x

SpikedHelmet
MC: Legacy & Spring 1944 Developer
Posts: 1948
Joined: 21 Sep 2004, 08:25

Re: Inverse Kinematics animations for Spring in Blender

Post by SpikedHelmet »

Oh, it's 2.83 I have. Any idea where I can get 2.82?

It happens with any .s3o i try to import using s3o_import.

EDIT: It seems it was the location of my file. I moved it to the desktop and it now loads. Dafuq.

Of course, I've never used Blender before in my life. Where are the "Correctly rotate s3o" and "Create skeleton" buttons? Lol
0 x

User avatar
PtaQ
Posts: 161
Joined: 15 Sep 2009, 10:40

Re: Inverse Kinematics animations for Spring in Blender

Post by PtaQ »

Image
Image

Top right corner of the viewport. Don't use "correctly rotate .s3o btw" - its deprecated.
0 x

User avatar
Beherith
Moderator
Posts: 4957
Joined: 26 Oct 2007, 16:21

Re: Inverse Kinematics animations for Spring in Blender

Post by Beherith »

Just an example of what this can do for you:
corcat_v2.gif
(2.64 MiB) Not downloaded yet
Image
2 x

Post Reply

Return to “Game Development Tutorials & Resources”

cron