Jump to content

[SOLVED] Dynamic run-time rescaling of effects (for a Semi-Procedural SRB)


Recommended Posts

Hi all,

Was curious if anyone had any experience or knowledge regarding rescaling of engine effects at run-time?

I have a modular-SRB system, where the user can select the diameter, number of segments, nozzle, and nosecone type for a single-part SRB.  That end of things all works great so far;  the one problem I have not yet been able to tackle is how to get the effects to properly scale with the size (and power) of the SRB.  These parts use the standard ModuleEnginesFX for the engine module (with a second custom module to do rescaling of the thrust and update resources), and uses standard EFFECTS definitions (and/or Real-Plume if installed).

Currently they all use the same effects regardless of SRB diameter/scale/number of segments.  This results in the offset position of the plume being incorrect for non-default diameters (due to scaling), as well as the overall size of the effects being wrong for non-default diameters (due to size and scale).

Looking at the FXGroup code briefly, I noticed it has a SetPower(float) method, but I'm unsure if this is the proper method to set the scale of them, or if it is the method that the engine-module uses to update the -current- visual status based on throttle.

I could also potentially modify the part ConfigNode data for the effects, but I'm unsure of how / if you can make a part re-initialize effects entirely (seems like it would cause problems for any modules already referencing those effects).

 

Any insight or knowledge towards this problem would be much appreciated;

Shadowmage

 

Edited by Shadowmage
Link to comment
Share on other sites

3 minutes ago, Crzyrndm said:

I would be looking through Real Plume to work out how they do it (EDIT looks like the plugin may actually be smokescreen)

Thanks for the suggestion. 

Sadly, from looking at the SmokeScreen code, Sarbian uses a special particle emitter with built-in support for run-time reloading (https://github.com/sarbian/SmokeScreen/blob/master/ModelMultiParticlePersistFX.cs#L922-L1002).

I'm looking for a method that can be used equally for both stock effects or real-plume effects (works on the FXGroup level, rather than on the emitter level).  Will do some investigation to see if I have access to any of those methods for generic FX group use / stock emitters.  They all derive from EffectBehaviour, so there might be something usable there.  I might be able to use something similar, if I can find the base effects emitters from the FXGroup, force-re-loading the config from nodes with modified values.

Hmm... going to require some testing and poking about to see what is going on with effects / if it'll crash things.

 

Link to comment
Share on other sites

4 hours ago, Crzyrndm said:

I would be looking through Real Plume to work out how they do it (EDIT looks like the plugin may actually be smokescreen)

It took a bit of work, but editing and reloading the config nodes does seem to work.  Sadly, I have to special-case support for real-plumes and stock effects separately, but at least it is all config-node based data so I don't need any reflection/etc.

Thanks for the suggestion :)

 

Will update with sample code as soon as I have it all cleaned up and implemented.

Link to comment
Share on other sites

On Saturday, February 20, 2016 at 3:42 AM, sarbian said:

SmokeScreen already has some code for the "old" ProceduralSRB so I could easily add something for yours if you want.

Thanks for the offer, but I appear to have it worked out at the moment, at least for Real-Plumes (and hopefully stock).

 

Code is a bit rough at the moment, and could certainly be cleaned up a bit, but is functional.

https://github.com/shadowmage45/SSTULabs/blob/master/Source/Module/SSTUModularBooster.cs#L801-L915

Results in a pretty decent scaling for my needs; and I can always adjust it later if needed.

NsSVqoZ.png

Link to comment
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.

×
×
  • Create New...