Author Topic: Multiple projectile and splash effects  (Read 5873 times)

will

  • Golem
  • ******
  • Posts: 783
    • View Profile
Multiple projectile and splash effects
« on: 12 June 2011, 21:44:18 »
We have some simple use-cases in mind:

  • both smoke and flames following a missile or arrow
  • both smoke and flames following each individual missile or arrow in a volley (e.g. the Industaron's MIRV superweapon)
  • a nuclear bomb mushroom cloud made from multiple splash effects (suggests each has a start-delay)

However, in the implementation I don't want to design-out or limit other obvious use-cases and scenarios, so if you have other uses or thoughts its useful to add them!

At the moment each unit attack skill has a projectile and splash specified.  The projectile is used for determining what you hit and the splash is triggered when the projectile has landed.

This means that there is strictly 1:1 particle projectile.

Should I add the additional particles as 'sub particles' specified in the particle xml, or specify them in the unit xml?  Any suggestions on what the XML might look like?

What happens if you have multiple 'top level' projectile effects?  Will only one be used for scoring?

How will the engine know when to trigger splashes if the projectiles have potentially different flight times?

How and where will we specify delay for a splash effect?

Any other questions?

We really want to open the door to new things without breaking the default behavior or stepping out-of-character in the XML....


(A feel a new fresh topic is required, although similar things have cropped up in the past )

will

  • Golem
  • ******
  • Posts: 783
    • View Profile
Re: Multiple projectile and splash effects
« Reply #1 on: 17 June 2011, 21:10:29 »
(click to show/hide)

There is a basic prototype for multiple particles per projectile and splash on github

Particles can have child particles specified in the XML, which in turn can have child particles - its actually a tree data-structure.  All children are technically unit particles even if they are attached to a projectile or splash.

These child particle systems are positioned relative to the parent system.

Here's that twin-zap projectile particle from the picture:

Code: [Select]
<?xml version="1.0" standalone="yes"?>
<?xml version="1.0" standalone="yes"?>
<projectile-particle-system>
     <texture value="false"/>
     <model value="false"/>
<primitive value="quad"/>
<offset x="0" y="0.5" z="1.2"/>
<color red="1.0" green="0.5" blue="0.2" alpha="0.8" />
<color-no-energy red="1.0" green="1.0" blue="1.0" alpha="0.0" />
     <size value="0.2" />
     <size-no-energy value="0.03" />
     <speed value="7.0" />
<gravity value="0"/>
     <emission-rate value="0" />
     <energy-max value="20" />
     <energy-var value="2" />

     <child-particles value="true">
     <particle-file path="../chemical_trooper/particle_flame.xml">
     <offset x="0.5" y="0.5" z="0"/>
     <radius value="0.1"/>
     <size value="0.1"/>
     <gravity value="0"/>
     <direction x="0" y="0" z="-2"/>
     </particle-file>
     <particle-file path="../chemical_trooper/particle_flame.xml">
     <offset x="-0.5" y="0.5" z="0"/>
     <radius value="0.1"/>
     <size value="0.1"/>
     <gravity value="0"/>
     <direction x="0" y="0" z="-2"/>
     </particle-file>
     </child-particles>

<trajectory type="linear">
<speed value="15.0"/>
</trajectory>
</projectile-particle-system>

The old particle had a model that had twin torpedoes in it.  However, it was easier to rip that out and instead have two child particles.  I reused the chemical trooper's flame-thrower particle, only overrode some values such as offset and direction (so it points backwards not forwards).

There's still a few features and bugs to fix:

  • Delay triggering of chained systems
  • Conical and blast effects
  • Models in unit particles are not quite positioned right?
  • We only orientate on the horizontal plane; we really need to make unit particles have vertical rotation too so they can be properly aligned with the projectile missiles they are following
  • Check for cyclic dependencies

All tester feedback welcome!
« Last Edit: 17 June 2011, 21:16:24 by will »

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,240
    • View Profile
    • http://www.titusgames.de
Re: Multiple projectile and splash effects
« Reply #2 on: 18 June 2011, 00:11:08 »
If you want multiple projectiles you shoudl use multiple particle systems.
If you want to have just some more effect do it the way you did it with additional unit particle systems for one projectile particle system.
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

ElimiNator

  • Airship
  • ********
  • Posts: 3,391
  • The MegaGlest Moder.
    • View Profile
Re: Multiple projectile and splash effects
« Reply #3 on: 18 June 2011, 05:03:15 »
If you want multiple projectiles you shoudl use multiple particle systems.
How to do this?
Get the Vbros': Packs 1, 2, 3, 4, and 5!

will

  • Golem
  • ******
  • Posts: 783
    • View Profile
Re: Multiple projectile and splash effects
« Reply #4 on: 18 June 2011, 07:29:54 »
If you want multiple projectiles you shoudl use multiple particle systems.
I am not implementing this.  After consideration, I thought that should wait until a clearer use-case is explained to me.  So I went the other route:

Quote
If you want to have just some more effect do it the way you did it with additional unit particle systems for one projectile particle system.
Exactly.  The purpose of this work is entirely visual, e.g. smoke and flames on a fire arrow.

A lot of Mr War's models have double shot - ships in Imperial, the Tripod in Martians etc.  This is entirely for visual effect.  Only the normal projectile particle effect is centred and singular, so it didn't look especially good.

The purpose of this code is to make things prettier, not in any way to affect the actual interaction of units.
« Last Edit: 18 June 2011, 07:55:43 by will »

will

  • Golem
  • ******
  • Posts: 783
    • View Profile
Re: Multiple projectile and splash effects
« Reply #5 on: 27 June 2011, 11:45:20 »
now with delay chaining and separate child particle lifetimes: https://github.com/williame/megaglest/compare/master...radial_particles

child particles can have a <delay value="..."/> tag, which will cause them to delay starting until n game-ticks (40 per second) after their parent starts.

They can also have a <lifetime value="..."/> tag, which specifies how long (in game ticks) until they fade.

This is quite a usable useful state as it is now; still outstanding however is:

  • Conical and blast effects
  • We only orientate on the horizontal plane; we really need to make unit particles have vertical rotation too so they can be properly aligned with the projectile missiles they are following
  • Check for cyclic dependencies

Of these, I will probably not tackle the orientation problem.  This would properly need a matrix that is inherited from parents and such.  Not too difficult, but a big departure for the code-base that Mr War can live without.

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,240
    • View Profile
    • http://www.titusgames.de
Re: Multiple projectile and splash effects
« Reply #6 on: 27 June 2011, 12:46:40 »
uhm thats what I was afraid of  :scared: A lot of patches changing a lot of things ....
Small steps please!

Please provide an exact description of what you changed and which patches( based on a diff with our svn ) are needed to make it work. Please test these patches for you vs current svn version. And only include things which are needed for this functionality!

I know it may sound picky, but we really try to keep it stable.
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: Multiple projectile and splash effects
« Reply #7 on: 27 June 2011, 12:56:24 »
Lots of changes are good things, though. Lots of choices for the modder and such. One note, though, since you're explicitly stating the length of the delay and lifetime in world frames, which is *defaultly* 40, wouldn't it be better as, for example, a float of world frames, where 1.0 = One full world frames cycle (defaults to 40). This way if someone changes the world frame rate, to, say 30, the timing wouldn't be off. As well, this would make it simpler (?) to understand seconds, while maintaining capability of increasing or decreasing with the game speed.
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert

will

  • Golem
  • ******
  • Posts: 783
    • View Profile
Re: Multiple projectile and splash effects
« Reply #8 on: 27 June 2011, 12:58:41 »
Lots of changes are good things, though. Lots of choices for the modder and such. One note, though, since you're explicitly stating the length of the delay and lifetime in world frames, which is *defaultly* 40, wouldn't it be better as, for example, a float of world frames, where 1.0 = One full world frames cycle (defaults to 40). This way if someone changes the world frame rate, to, say 30, the timing wouldn't be off. As well, this would make it simpler (?) to understand seconds, while maintaining capability of increasing or decreasing with the game speed.

Yeah I'll make the delays in seconds

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,240
    • View Profile
    • http://www.titusgames.de
Re: Multiple projectile and splash effects
« Reply #9 on: 27 June 2011, 14:33:59 »
Seconds are a pretty bad idea ( multiplayer/speedup and so on ). Better use time in the way it is used for starting sounds in skills and so on.
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

ElimiNator

  • Airship
  • ********
  • Posts: 3,391
  • The MegaGlest Moder.
    • View Profile
Re: Multiple projectile and splash effects
« Reply #10 on: 27 June 2011, 15:38:04 »
If you want multiple projectiles you shoudl use multiple particle systems.
Once again, is there a way to do this? If so how?
Get the Vbros': Packs 1, 2, 3, 4, and 5!

will

  • Golem
  • ******
  • Posts: 783
    • View Profile
Re: Multiple projectile and splash effects
« Reply #11 on: 27 June 2011, 16:43:23 »
There is not.  It could be added, but i think that is easier after the merge

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: Multiple projectile and splash effects
« Reply #12 on: 27 June 2011, 16:58:40 »
Seconds are a pretty bad idea ( multiplayer/speedup and so on ). Better use time in the way it is used for starting sounds in skills and so on.
Thinking about it better, the multiplier idea wouldn't work because the world frames increase when you increase the game speed (default is 40 frames per second, but, for example, on faster speed, which is 1.5x, it would be 60 frames per second). Thus, 40*2 = 80 frames, but 60*2 = 120, which would be wrong (unless the game speed is reversed for this calculation).

However, you seem to misunderstand how starting times in skills work. They aren't time at all, they are a ratio of how complete the skill cycle is. Thus, 0.0 means at the very start, 0.5 would be halfway through, 1.0 would be at the very end (values outside of this range don't work. If I recall, it makes the attack skip or not do anything). This ratio is easiest to find out by using the G3DHack tool, since it displays the ratio on the animation bar.

There is not.  It could be added, but i think that is easier after the merge
100% agreement. Let's merge first, then worry about these things. :)
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert

will

  • Golem
  • ******
  • Posts: 783
    • View Profile
Re: Multiple projectile and splash effects
« Reply #13 on: 27 June 2011, 18:33:15 »
To my thinking, its entirely appropriate that delay and lifetime should be specified in 'game seconds' which, as we know, can be sped up in some circumstances.  The movement of particles is governed by this speed, so should their lifetimes.

ElimiNator

  • Airship
  • ********
  • Posts: 3,391
  • The MegaGlest Moder.
    • View Profile
Re: Multiple projectile and splash effects
« Reply #14 on: 27 June 2011, 19:44:14 »
There is not.  It could be added, but i think that is easier after the merge
Dude there will be no merge, didn't you see the post?
Get the Vbros': Packs 1, 2, 3, 4, and 5!

will

  • Golem
  • ******
  • Posts: 783
    • View Profile
Re: Multiple projectile and splash effects
« Reply #15 on: 27 June 2011, 20:11:11 »
Dude there will be no merge, didn't you see the post?

the merge of my patch

ElimiNator

  • Airship
  • ********
  • Posts: 3,391
  • The MegaGlest Moder.
    • View Profile
Re: Multiple projectile and splash effects
« Reply #16 on: 28 June 2011, 03:58:39 »
O, It isn't in MG yet? OK when are you going to "merge" it?
Get the Vbros': Packs 1, 2, 3, 4, and 5!

will

  • Golem
  • ******
  • Posts: 783
    • View Profile
Re: Multiple projectile and splash effects
« Reply #17 on: 29 June 2011, 19:37:43 »
https://github.com/williame/megaglest/compare/master...radial_particles

This is quite a usable useful state as it is now; still outstanding however is:

  • Conical and blast effects
  • We only orientate on the horizontal plane; we really need to make unit particles have vertical rotation too so they can be properly aligned with the projectile missiles they are following
  • Check for cyclic dependencies

Of these, I will probably not tackle the orientation problem.  This would properly need a matrix that is inherited from parents and such.  Not too difficult, but a big departure for the code-base that Mr War can live without.

The blast effect is toggled by <shape value="spherical"/>; then all particles fly away from the centre point.

On close examination of the existing code, speed is relative to the game update fps, so I have done likewise with my timing code.

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,240
    • View Profile
    • http://www.titusgames.de
Re: Multiple projectile and splash effects
« Reply #18 on: 30 June 2011, 00:09:59 »
Is there anything meant to be ready yet? If not please really try to make a patch available. I really don't want to apply anykind of huge monster patch in a year or so!
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: Multiple projectile and splash effects
« Reply #19 on: 30 June 2011, 06:17:02 »
Is there anything meant to be ready yet? If not please really try to make a patch available. I really don't want to apply anykind of huge monster patch in a year or so!

Er, to my understanding, the link is a patch:
https://github.com/williame/megaglest/compare/master...radial_particles
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert

will

  • Golem
  • ******
  • Posts: 783
    • View Profile
Re: Multiple projectile and splash effects
« Reply #20 on: 30 June 2011, 09:00:37 »
This is not a collection of unrelated features; the component parts are not particularly useful alone, and only work as a synergy.  Its one big chunk of new functionality that allows for nice missiles for Mr War's mods.  Of course, everyone wants nicer missiles too, or just smoke from fire arrows and such :)

ETA is beginning of next week.

I need to see some great particles in Industarons so we have confidence the code works as intended.

I will use git format-patch and paste it here in this thread when done.

When it's in the trunk then I'll add some documentation to the wiki.

will

  • Golem
  • ******
  • Posts: 783
    • View Profile
Re: Multiple projectile and splash effects
« Reply #21 on: 3 July 2011, 04:24:23 »
https://www.youtube.com/watch?v=8lWqZM0zSaA

Mr War

  • Guest
Re: Multiple projectile and splash effects
« Reply #22 on: 3 July 2011, 09:48:55 »
Sweet man

will

  • Golem
  • ******
  • Posts: 783
    • View Profile
[PATCH] Multiple projectile and splash effects
« Reply #23 on: 6 July 2011, 15:51:27 »
(click to show/hide)

will

  • Golem
  • ******
  • Posts: 783
    • View Profile
Re: Multiple projectile and splash effects
« Reply #24 on: 7 July 2011, 06:24:32 »
softcoder integrated it: svn revision 2455