BahamutoD

[WIP Plugin] BDAnimationModules - v0.6.1

Recommended Posts

This is a library where I stuff all the animation related PartModules I use for my parts.

Contains:

- AnimatedContainer: a module for animating containers depending on how much resource they're holding

- AnimatedEngine: for engines to animate on activation/deactivation.

- AnimatedRCS: animation plays forward/backwards when RCS is toggled on vessel

- AnimatedThrust: Animation state depends on finalThrust/maxThrust (on rockets, it would do the same as stock animated thrust. this is mainly for jets/engines with lag)

- BDEngineCase: experimental. Disables all attached engines when in closed state(normalizedTime = 0), enables all attached engines when in open state (normalizedTime=1)

- BDAdjustableLandingGear: For Adjustable Landing Gear

- BDModuleLookatConstraint: similar to the stock lookat constraint, but constrains the up direction to the rotator's up direction so the transform doesn't rotate arbitrarily.

This can be used by other part creators so they can be more creative with how the parts look and function.

Source on Github

Download

Alpha version

v0.6.1

-added ability to toggle engine animations in editor

-fixed spotlight turret being on in editor

-made spotlight locked position persistent

-added FAR geometry update message after deploying/retracting adjustable gear

v0.6.0

-1.0+ Compatibility, animate thrust module fixes, fswheel etc fork, adjustable landing gear update.

Credit to Snjo for the original FSWheel and related classes.

v0.5.2

- Removed debug labels from BDAdjustableLandingGear

v0.5.1

- Fixed BDAdjustableLandingGear bug:

-- changed animation handling to work with FSwheel better (fixed motor bug)

v0.5

- Added BDAdjustableLandingGear

- Added BDModuleLookAtConstraint

v0.4.1

-fixed AnimatedEngines heat & dV measurements (DREC, KER, MechJeb compatibility)

v0.4

-0.24.2 update

-AnimatedRCS stays retracted if particular RCS thruster is disabled

-Removed Looped Kethane converter (sorry!)

-Animated containers update in editor

-Fixed stuttering bug in AnimatedEngine

-AnimatedThrusts's disableGimbalToggle combines multiple gimbals into one button and action group

-Added ModuleEnginesFX support in AnimatedThrust

-Added MouseAimLight

v0.3

=Bugfixes <-fail obviously

v0.2

=Animated Engine: added "WaitForAnimation"

+Deployable RCS

+GenericLoopAnimation

+BDEngineCase

+AnimatedThrust

v0.1

+AnimatedEngine

+AnimatedContainer

+LoopedKConverterAnimation

Usage:


MODULE
{
name = AnimatedContainer
ResourceType = RocketParts //resource you want the animation to depend on
ContainerAnimationName = expand //name of animation
}

MODULE
{
name = AnimatedEngine
EngineAnimationName = deploy //name of animation
WaitForAnimation = 0.73 //normalizedTime index of when to activate engine on deploy (default is 0 = instant. 1 = wait till animation plays fully)
}

MODULE
{
name = AnimatedRCS
AnimationName = Deploy
}

MODULE
{
name = AnimatedThrust
ThrustAnimationName = thrust2
disableGimbalToggle = false //if true, disables multiple gimbal buttons/actiongroups and combines them to one (I just needed this because my thrust vector jet had 24 gimbals)
}

Videos:

RCS animation, Animated Thrust, and fixed animated engine:

Test of the AnimatedContainer module in a rocketparts container for Extraplanetary Launchpads:

Test of the AnimatedEngine module with a vtol rocket engine part I made:

CC BY-SA 3.0

Credit to Snjo for the original FSWheel and related classes. (Modified)

Edited by BahamutoD

Share this post


Link to post
Share on other sites

Very cool! The parts used to demo the functionality are beyond awesome as well. Great works, I look forward to seeing what comes from this.

Share this post


Link to post
Share on other sites

Will it manage loop anim ? None of other anim module did it yet AFAIK (FS/Vanguard/stock).

I would like to have something which start/stop anim the same way as a extend/retract, and eventually add some stock resources consumption code, to make some parts which draw electric charge when moving without having to create a new module for it.

What's this rocketparts ? :) looks like a mater generator, sounds good.

Animated engine are a bit fast, the doors might be damaged by heat.

Share this post


Link to post
Share on other sites

Justin Kerbice, looping is on the todo list. I need to figure out how to implement it so stock modules can use it if specified.

The rocket parts container is just a container that's the same size as the stock EL 2.5m container, but expands when filled so it has almost double the capacity!

The engine still fires right when its turned on, regardless of what the animation is doing.. I made the animation as reasonably quick as possible so it doesn't look like its firing while closed too much. Perhaps I should look into a way to hold back the engine until the animation is finished?

Share this post


Link to post
Share on other sites

I would love to see the possibility of choosing arbitrary animation states from a list accessible by the default right click on part behavior.

Say for example that you have a very large cargo bay door, and you want it to go to a [50%] open state, then [close], and then finally a [100%] open, and then have a further option that is state based such as [activate radiator] which will toggle an unfold of the radiators, no matter what open state the door itself is in.

This project looks amazing, I look forward to what ever you end up doing with it.

Share this post


Link to post
Share on other sites

The animated vtol rocket engine....I have so many ideas for that. Cant wait to break....err...test....umm..utilize them :)

Share this post


Link to post
Share on other sites
I would love to see the possibility of choosing arbitrary animation states from a list accessible by the default right click on part behavior.

Say for example that you have a very large cargo bay door, and you want it to go to a [50%] open state, then [close], and then finally a [100%] open, and then have a further option that is state based such as [activate radiator] which will toggle an unfold of the radiators, no matter what open state the door itself is in.

This project looks amazing, I look forward to what ever you end up doing with it.

That's a good idea. I'll add that to the todo list.

Share this post


Link to post
Share on other sites
Justin Kerbice, looping is on the todo list. I need to figure out how to implement it so stock modules can use it if specified.

I advise you to look at other anim plugin code (FS/Vanguard), it doesn't looks like that hard and I have thought doing it myself but as you're on the duty already, I can offer some beta testing if you wish.

For the engine thing, don't know, perhaps it's also because the anim on the video is very fast so it could be confusing. It looks like a "shadow ninja engine" (no engine... firrrreeeeee !!!!! no no there is no engine ! :P)

Share this post


Link to post
Share on other sites

Aw yeah! You are a hero!

What do you think of a module for multiModeEngines where the selected engine mode controls the animation state? Would make for some cool rapiers.

Share this post


Link to post
Share on other sites

I wonder, for the rocket parts container, whether the bits that push out could do so sequentially rather than all at the same time? Like they're getting filled up one by one.

Share this post


Link to post
Share on other sites
I wonder, for the rocket parts container, whether the bits that push out could do so sequentially rather than all at the same time? Like they're getting filled up one by one.

That's what I originally planned, but rushed to do a quicker animation so that I could get on with testing the plugin. I might do that eventually..

Aw yeah! You are a hero!

What do you think of a module for multiModeEngines where the selected engine mode controls the animation state? Would make for some cool rapiers.

Added to the todo list.

Share this post


Link to post
Share on other sites

I added a module for looped animations in Kethane converter. Added a download link for alpha v0.1 and some info on the original post.

I'm wondering if I'll need to write different code or a new module for looped animations for other modules..

Edited by BahamutoD

Share this post


Link to post
Share on other sites

Before i forget. My other suggestion for an animation partmodule is one for moduleenginefx/moduleengine that plays an animation from frame 0 to last frame scaled with thrust, airspeed, velocity or throttle. Not sure if this is something that firespitter stuff can be adapted for but im thinking mainly in combination with your engines deploy animations module.

Very excellent work on the kethaneconverter animation module btw. Now i finally dont need to hack in running animations via the heating stuff anymore. Wohooow!:D

I was also thinking about that secure docking port stuff i was working on could perhaps be accomplished via a plugin instead of hacking it in via the squad docking module. Maybe some combined module with animations when the docking transforms get within "attraction" range and with support for a seperate type of transform for the prongs. (As im writing this im thinking i should probably post my wip docking port model so its easier to understand) i have two types of docking ports ideas now: one that just extends and has a big lever some distance behind it that supports the docked module (meant for docking stuff radially) and the one with the 4 prongs on the "a" side part that grab on to outside of the "b" side.

Edited by landeTLS

Share this post


Link to post
Share on other sites

Added loop was promising but as it is now, it's too much tied to Kethane and I don't think an "all-in-one" package/very specific was good, I mean it would be better to have one loopanim module which only deal with loop (start/stop loop), and another for deploy/retract.

For now and as-is, loop anim are just what they are and are always activated (both in VAB/SPH and outside).

Share this post


Link to post
Share on other sites

If you want the loop animation to be used when other modules are active (like when a comm dish is deployed), I have to write the module to specifically check for that. You can suggest some modules you think would commonly use a looped animation. I just did the kethane one first because I needed it for a part I made.

Share this post


Link to post
Share on other sites

Nice job on those new EPL parts.

I just think the 3D printer is a bit big. A smaller (perhaps slightly less efficient), 1.25m version would fit many designs better.

And the inflatable Kethane tank, did you make it un-tweakable on purpose? I can't edit the contents in the SPH/VAB.

Share this post


Link to post
Share on other sites
Nice job on those new EPL parts.

I just think the 3D printer is a bit big. A smaller (perhaps slightly less efficient), 1.25m version would fit many designs better.

And the inflatable Kethane tank, did you make it un-tweakable on purpose? I can't edit the contents in the SPH/VAB.

The kethane tanks were never tweakable. You gotta go out and mine it!

The printer is already smaller than the original rocketparts workshop so I'm not going to make it any smaller.

Anyways, thats a topic for the EPL parts thread

Could you write a module that allows deployable RCS?

Interesting, haven't thought of that. I can try.

Share this post


Link to post
Share on other sites
If you want the loop animation to be used when other modules are active (like when a comm dish is deployed), I have to write the module to specifically check for that. You can suggest some modules you think would commonly use a looped animation. I just did the kethane one first because I needed it for a part I made.

As far as I have understood your plan, creating THE ultimate animation plugin for everyone and every use, I think something that can manage loop anims independently to any other anims added to the part or as you have already made in a given sequence. Perhaps it can be possible to add an optional index as arg to the module, to let it know it have to play anim A before anim B before anim C and A is "open doors", B is "extend something" and C is "turn forever or until user ask to stop" (then stop = reversed order sequence, -> B -> A). Max index should be minimum between: max number of anims which can be added to an object (format dependant ? I don't know) and max from Unity (max animator components).

By making things comprehensive and fully modular, your plug-in could be THE one for animated part I think.

Share this post


Link to post
Share on other sites
I think something that can manage loop anims independently to any other anims added to the part or as you have already made in a given sequence.

This is easy to do for a custom module, but a little trickier for a generic one. One way that I can think of is to create one animation field specifically for the looped animation, something like "loopedAnimationName = ". Then have a field for how long you want to wait before the looped animation begins (ie. primary animation.length), a value of 0 would start it immediately.

All of this could be controlled with a coroutine that is called when the primary animation trigger is fired. Then it would play the primary animation, start the coroutine, and wait until a given time before starting the looped animation. Then there are a few ways to wind down the looped animation. The ugly way is to let it snap back to its start position then play the primary animation in reverse. The nicer way is to reset the looped animations normalized time to a value between 0 and 1, set it to clamp, and let it finish its last loop (though because of Unity's animation issues, this doesn't always look so great, sometimes an animation stops on the second to last frame), this also has some issues, but I think it's better than snapping it back to zero.

There's probably also some way to accomplish this using OnUpdate code, but I try to avoid that whenever I can.

I've been making something similar, combining the ModuleScienceExperiment with my own animation code and allowing for as much flexibility as possible using only the part.cfg file. The idea is to make a smarter way for science experiments to control animations. This is as much for my own sake (I have four parts with four custom plugins that are basically the same) as anything else, but I also plan on releasing it for others to use. Right now it can only call one animation, but I think adding at least the looping code shouldn't be too hard.

Share this post


Link to post
Share on other sites
Interesting, haven't thought of that. I can try.

I'd appreciate it.

Share this post


Link to post
Share on other sites
As far as I have understood your plan, creating THE ultimate animation plugin for everyone and every use, I think something that can manage loop anims independently to any other anims added to the part or as you have already made in a given sequence. Perhaps it can be possible to add an optional index as arg to the module, to let it know it have to play anim A before anim B before anim C and A is "open doors", B is "extend something" and C is "turn forever or until user ask to stop" (then stop = reversed order sequence, -> B -> A). Max index should be minimum between: max number of anims which can be added to an object (format dependant ? I don't know) and max from Unity (max animator components).

By making things comprehensive and fully modular, your plug-in could be THE one for animated part I think.

This is easy to do for a custom module, but a little trickier for a generic one. One way that I can think of is to create one animation field specifically for the looped animation, something like "loopedAnimationName = ". Then have a field for how long you want to wait before the looped animation begins (ie. primary animation.length), a value of 0 would start it immediately.

All of this could be controlled with a coroutine that is called when the primary animation trigger is fired. Then it would play the primary animation, start the coroutine, and wait until a given time before starting the looped animation. Then there are a few ways to wind down the looped animation. The ugly way is to let it snap back to its start position then play the primary animation in reverse. The nicer way is to reset the looped animations normalized time to a value between 0 and 1, set it to clamp, and let it finish its last loop (though because of Unity's animation issues, this doesn't always look so great, sometimes an animation stops on the second to last frame), this also has some issues, but I think it's better than snapping it back to zero.

There's probably also some way to accomplish this using OnUpdate code, but I try to avoid that whenever I can.

I've been making something similar, combining the ModuleScienceExperiment with my own animation code and allowing for as much flexibility as possible using only the part.cfg file. The idea is to make a smarter way for science experiments to control animations. This is as much for my own sake (I have four parts with four custom plugins that are basically the same) as anything else, but I also plan on releasing it for others to use. Right now it can only call one animation, but I think adding at least the looping code shouldn't be too hard.

I think I see what you're getting at, but if I make a generic module like that, it will only be a stand-alone animation that can play and stop on user command but it wont accompany other modules like the kethane one that plays when you activate the converter. You want me to make a module just like the stock ModuleAnimateGeneric but with loop capabilities?

Share this post


Link to post
Share on other sites
I think I see what you're getting at, but if I make a generic module like that, it will only be a stand-alone animation that can play and stop on user command but it wont accompany other modules like the kethane one that plays when you activate the converter. You want me to make a module just like the stock ModuleAnimateGeneric but with loop capabilities?

I think you can make it do a lot using only the .cfg file, it's just a matter of how many options you want to expose there and how complicated you want the plugin to be based on all of those .cfg fields.

Share this post


Link to post
Share on other sites
I think I see what you're getting at, but if I make a generic module like that, it will only be a stand-alone animation that can play and stop on user command but it wont accompany other modules like the kethane one that plays when you activate the converter. You want me to make a module just like the stock ModuleAnimateGeneric but with loop capabilities?

I don't mean to push you in a way you don't want. And yes I guess we understand each other on this.

Share this post


Link to post
Share on other sites
This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.