Obi Official Forum
Help Add External force to Fluid Particle - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Fluid (https://obi.virtualmethodstudio.com/forum/forum-3.html)
+--- Thread: Help Add External force to Fluid Particle (/thread-593.html)



Add External force to Fluid Particle - Renzo - 10-05-2018

Hi

I want to add an external force to all particles on the screen, could you help me sending a script.

thank you

Renzo


RE: Add External force to Fluid Particle - josemendez - 11-05-2018

(10-05-2018, 05:57 PM)Renzo Wrote: Hi

I want to add an external force to all particles on the screen, could you help me sending a script.

thank you

Renzo

Hi Renzo,

There's a component included that does exactly this (ObiAmbientForceZone).

If you want to calculate a external force and apply it yourself, call:

Code:
Oni.AddParticleExternalForce(solver.OniSolver,ref force,particleIndices, particleIndices.Length);

"solver" is a ObiSolver component, "force" is a Vector4[] of length 1, and "particleIndices" is a int[] containing the indices of the particles you want the force to affect.
Edit: Force is a Vector4 (instead of Vector3) for memory alignment reasons. The first 3 components should be your force's x,y,z and the 4th component should be zero.

cheers,