Ring particle emitter?

Ring particle emitter?

Postby Skinnytorus » Sunday, 08.June 2014, 12:13

Hi there.
1) I've been playing with particle code. In fxparticle.cpp at line 223 there is this code:
Code: Select all
sFORALL(Particles,p)
  {
    switch(Para.CreateFlags & 3)
    {
    case 0:
      r.InitRandom(rnd);
      break;
    case 1:
      r.x = rnd.Float(2)-1;
      r.y = rnd.Float(2)-1;
      r.z = rnd.Float(2)-1;
      break;
    case 2:
      r.InitRandom(rnd);
      r.Unit();
      break;
    }
    p->Pos = (sVector31)r;
    r.InitRandom(rnd);
    p->Speed = r;
    p->Time = rnd.Float(1);
  }

It initializes particle positions for Ballistic. I wonder is there is a simple way to create a ring emitter with particles oriented outwards?

2) I've also noticed that if we rem out string 241 (i.e. r.InitRandom(rnd); which randomizes particle speed vectors) we can orient particles outwards (in Forward and Fly mode in Chunks)! Thus, by making a switch that excludes this string we can orient particles correctly. I coded the switch, but just can't make it work (no difference if it's on or off). Maybe The Great Master Code Guru could do that properly? Thanks anyway ;)
Skinnytorus
Operator
Operator
 
Posts: 1300
Joined: Monday, 06.February 2012, 17:46

Re: Ring particle emitter?

Postby ikam » Monday, 09.June 2014, 06:02

1/ best way to create a ring (or other shape) emiter outward is maybe to use mesh and a normal emiter.

2/ You cannot simply add a new case in this switch, because it is relative to balistic shapes (0= sphere, 1 = square , 2 = bouble), if you add a case 4: (is that you did ?) there is nothing in the operator parameter that drive this new value, why it doesn't work...

first (in switch code part), r variable is used to compute the particle position according shape flag and set pos here : p->Pos = (sVector31)r;

in a second time, r variable is reused to compute speed particle :

r.InitRandom(rnd);
p->Speed = r;

In all cases (all shapes) speed will be a random value.

So yes this random could be run or not. if yes it works as usual, if not speed init value will be the same as pos, why not...
But best way is to create another parameter in the operator, because it is not really relative to shape and It will keep the backward behavior.

my test file :
You do not have the required permissions to view the files attached to this post.
ikam
Operator
Operator
 
Posts: 911
Joined: Friday, 14.October 2011, 13:00
Location: France

Re: Ring particle emitter?

Postby Skinnytorus » Monday, 09.June 2014, 07:52

1/ best way to create a ring (or other shape) emiter outward is maybe to use mesh and a normal emiter.

I agree with that, but how to orient the particles outwards without using workarounds (Explosion etc.)? Imho this should be a quick and easy operation.

if you add a case 4: (is that you did ?) there is nothing in the operator parameter that drive this new value, why it doesn't work...

Not really... I created a SameSpeed integer var, then a switch in the .ops file (like yours AnimateSource), then made a condition:
if(Para.SameSpeed&0) r.InitRandom(rnd);
Imho, it should be checked each cycle. Something is wrong here...
And thanks for the file. :) I will have a look at it this evening.
Skinnytorus
Operator
Operator
 
Posts: 1300
Joined: Monday, 06.February 2012, 17:46

Re: Ring particle emitter?

Postby ikam » Monday, 09.June 2014, 10:54

what is the SameSpeed variable, a param speed value instead of a random ?

it should work if you something like that :
in .ops => flags RandomSpeedFlag ("-|on") = 1; // 1 as default value ensure backward compatibility in balictic behavior
in .cpp => if(Para.RandomSpeedFlag ) r.InitRandom(rnd);

ps : don't forget to add new ops parameter at end of existing parameters, else it break operator backward compatibility and you need to to reorder parameters with a special syntax.

if it doesn't work show me your code.
I'm thinking on how to use fromvertex in combination with balisctic to emit from normals.
ikam
Operator
Operator
 
Posts: 911
Joined: Friday, 14.October 2011, 13:00
Location: France

Re: Ring particle emitter?

Postby Skinnytorus » Monday, 09.June 2014, 11:20

Edit:
what is the SameSpeed variable, a param speed value instead of a random ?

No. It's basically the name of the switch that turns random speed off and makes it equal to converted particle positions.

Many thanks for the code. I will check that and get back to you.
Combination with balisctic to emit from normals:
It would be great if FromVertex could initially align particles along normals (as an option) and then pass vertex normal vectors as initial speed direction to Ballistic.
Skinnytorus
Operator
Operator
 
Posts: 1300
Joined: Monday, 06.February 2012, 17:46

Re: Ring particle emitter?

Postby Skinnytorus » Monday, 09.June 2014, 17:32

It works! Many thanks! I called the switch RandomSpeed. Here are my test files. If you are fine with how it works, could you please commit that?
You do not have the required permissions to view the files attached to this post.
Skinnytorus
Operator
Operator
 
Posts: 1300
Joined: Monday, 06.February 2012, 17:46

Re: Ring particle emitter?

Postby CybeREX » Monday, 09.June 2014, 18:55

Work! Great job man!
CybeREX
Demomaker
Demomaker
 
Posts: 154
Joined: Thursday, 03.April 2014, 07:44

Re: Ring particle emitter?

Postby ikam » Monday, 09.June 2014, 18:58

great, ok i'll commit it.
ikam
Operator
Operator
 
Posts: 911
Joined: Friday, 14.October 2011, 13:00
Location: France

Re: Ring particle emitter?

Postby Skinnytorus » Monday, 09.June 2014, 19:11

Cool. Thanks. Any progress with FromVertex+Ballistic normal alignment? Vertex struct seems to have point normal member. I'm not the king of c++ but it should be quite easy to get normals from mesh... I wonder which function works best for particle alignment? Quaternions?
Skinnytorus
Operator
Operator
 
Posts: 1300
Joined: Monday, 06.February 2012, 17:46

Re: Ring particle emitter?

Postby ikam » Tuesday, 10.June 2014, 06:51

I added the direction information in the particle struct, particles operators can now use this info.
I also modified fromvertex to fill this info and balistic to add a mode that use it.
You can now combine them to emit from vertex normals of a mesh.
ikam
Operator
Operator
 
Posts: 911
Joined: Friday, 14.October 2011, 13:00
Location: France

Re: Ring particle emitter?

Postby Skinnytorus » Tuesday, 10.June 2014, 08:07

Yo! Great many thanks, Master Code Guru! :-({|=
I will check this one this evening. Did you decide to omit implementing RandomSpeed on/off switch because it seems useless now?
I suggest you implement it just for the hell of it. Someday it might still prove useful. No need for a mesh in simple cases will simplify the stack.
Skinnytorus
Operator
Operator
 
Posts: 1300
Joined: Monday, 06.February 2012, 17:46

Re: Ring particle emitter?

Postby ikam » Tuesday, 10.June 2014, 08:22

I added it, maybe It should be usefull in some case...
here some little examples.
Image
You do not have the required permissions to view the files attached to this post.
ikam
Operator
Operator
 
Posts: 911
Joined: Friday, 14.October 2011, 13:00
Location: France

Re: Ring particle emitter?

Postby ikam » Tuesday, 10.June 2014, 08:25

It should be possible now to modify chuncks to oriente meshes from particles directions.
ikam
Operator
Operator
 
Posts: 911
Joined: Friday, 14.October 2011, 13:00
Location: France

Re: Ring particle emitter?

Postby Skinnytorus » Tuesday, 10.June 2014, 09:58

Very nice. Huge thanks as always. =D>
I will comment on how it works this evening.
Skinnytorus
Operator
Operator
 
Posts: 1300
Joined: Monday, 06.February 2012, 17:46

Re: Ring particle emitter?

Postby Skinnytorus » Tuesday, 10.June 2014, 11:12

By the way... What do you think about adding normal alignment to the mesh FromVertex operator? That would be so cool for modeling!
Skinnytorus
Operator
Operator
 
Posts: 1300
Joined: Monday, 06.February 2012, 17:46


Return to Development and contribution



Who is online

Users browsing this forum: No registered users and 1 guest

cron