Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Detecting if Vector3 is within ObiFluid volume?
#1
Also:

 - Uninstantiating particles within the radius of a Vector3 location 

And / or:

 - Changing values of an Emitter Material at runtime, such as Resolution or Rest Density



So, given an arbitrary Vector3 world location, will it be easy to determine if that location is within the volume of a collection of Obi Fluid particles?  The Obi Fluid will be at rest in a container when I need to do this, so it wont be run while fluid is flying around the scene or anything.  I've not had the chance to properly trawl through the API documentation yet, so my apologies if there's an easy answer in there.

The two next questions are pretty much as written; is there an easy way to uninstantiate particular particles?  Again, apologies if this is obvious in the API docs!

And is it advisable / possible to alter the properties of Emitter Materials at runtime?


Thank you!
Reply
#2
(15-10-2018, 05:17 PM)Mitch@PG Wrote: Also:

 - Uninstantiating particles within the radius of a Vector3 location 

And / or:

 - Changing values of an Emitter Material at runtime, such as Resolution or Rest Density



So, given an arbitrary Vector3 world location, will it be easy to determine if that location is within the volume of a collection of Obi Fluid particles?  The Obi Fluid will be at rest in a container when I need to do this, so it wont be run while fluid is flying around the scene or anything.  I've not had the chance to properly trawl through the API documentation yet, so my apologies if there's an easy answer in there.

The two next questions are pretty much as written; is there an easy way to uninstantiate particular particles?  Again, apologies if this is obvious in the API docs!

And is it advisable / possible to alter the properties of Emitter Materials at runtime?


Thank you!

Hi there,

 - Uninstantiating particles within the radius of a Vector3 location:
There's two options: iterate over all particles checking if they're within range of the Vector3 point (which if done every frame, can be inefficient) or use a spherical trigger collider and consider particles inside it (a better option). Then just set their life to zero. There's an example that does exactly this here:
http://obi.virtualmethodstudio.com/tutor...sions.html

 - Changing values of an Emitter Material at runtime, such as Resolution or Rest Density
Yes, simply assign whatever values you need to the material properties, then call:
Code:
material.CommitChanges(ObiEmitterMaterial.MaterialChanges.PER_MATERIAL_DATA | ObiEmitterMaterial.MaterialChanges.PER_PARTICLE_DATA);
Reply
#3
(16-10-2018, 07:50 AM)josemendez Wrote: Hi there,


[snip]

That's fantastic, thank you, exactly what I need to proceed.  

Any thoughts on detecting if an arbitrary point is "within" an Obi Fluid volume?
Reply
#4
(16-10-2018, 04:31 PM)Mitch@PG Wrote: That's fantastic, thank you, exactly what I need to proceed.  

Any thoughts on detecting if an arbitrary point is "within" an Obi Fluid volume?

Hi,

Fluid is discretized as particles, so checking if a point is "within the volume" is equivalent to checking if it is close enough to any particle. Using a small spherical trigger would do the trick, just like in the "Uninstantiating particles within the radius of a Vector3 location" case. Just make sure the collider is roughly the same radius as a particle.
Reply
#5
(17-10-2018, 08:28 AM)josemendez Wrote: Hi,

Fluid is discretized as particles, so checking if a point is "within the volume" is equivalent to checking if it is close enough to any particle. Using a small spherical trigger would do the trick, just like in the "Uninstantiating particles within the radius of a Vector3 location" case. Just make sure the collider is roughly the same radius as a particle.

That's great, thank you; I'll have to have a think about efficiency and the best way to put the pieces of this together, but that gives me everything I need so far.
Reply
#6
(16-10-2018, 07:50 AM)josemendez Wrote: [...] use a spherical trigger collider and consider particles inside it (a better option)


So ... uh, how do I set up a trigger collider?  If I add an Obi Collider, the particles bounce off it, which I don't want; I tried setting the Thickness to -1.0, but this crashed Unity.   Gran sonrisa
Reply
#7
(31-10-2018, 03:34 PM)Mitch@PG Wrote: So ... uh, how do I set up a trigger collider?  If I add an Obi Collider, the particles bounce off it, which I don't want; I tried setting the Thickness to -1.0, but this crashed Unity.   Gran sonrisa

Enable the "is trigger" checkbox in the collider itself (not the ObiCollider).
Reply
#8
(31-10-2018, 04:38 PM)josemendez Wrote: Enable the "is trigger" checkbox in the collider itself (not the ObiCollider).

 ... the standard collider component properties affect the Obi component behaviour??
Reply
#9
(31-10-2018, 05:41 PM)Mitch@PG Wrote:  ... the standard collider component properties affect the Obi component behaviour??

Of course. The ObiCollider component simply tags the collider so that Obi particles become "aware" of it, and adds a couple properties that are only relevant for Obi (phase and thickness). However it does pretty much nothing by itself, it needs the presence of an actual collider.

The collider component itself is used for collision detection, and all its properties will work as usual (type of collider, size, shape, is trigger, etc). Same for rigidbodies. See:

http://obi.virtualmethodstudio.com/tutor...sions.html
Reply