Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  ObiParticleRenderer
#9
(16-04-2019, 09:42 AM)mimarilker Wrote: Hi,

Thanks for the update! I have imported Obi to a new project and tried to run KarmanVortex scene. However, I got an error with ParticleAdvector.cs Triste

ArgumentNullException: Value cannot be null.
Parameter name: particles
UnityEngine.ParticleSystem.GetParticles (UnityEngine.ParticleSystem+Particle[] particles, System.Int32 size) (at C:/buildslave/unity/build/Runtime/ParticleSystem/ScriptBindings/ParticleSystem.bindings.cs:243)
UnityEngine.ParticleSystem.GetParticles (UnityEngine.ParticleSystem+Particle[] particles) (at C:/buildslave/unity/build/Runtime/ParticleSystem/ScriptBindings/ParticleSystem.bindings.cs:244)
Obi.ParticleAdvector.ReallocateParticles () (at Assets/Obi/Scripts/Emitter/ParticleAdvector.cs:49)


I have compared the older ParticleAdvector.cs with the new one. It seems that Solver_OnStepBegin is not included anymore, ad the line causing the error "alive = ps.GetParticles(particles);" is in the ReallocateParticles() which was in Solver_OnStepBegin, before. Could you please check it out?

I have resolved the problem by calling "alive = ps.GetParticles(particles);" in the "Solver_OnStepEnd" (see the attachment). However, I couldn't colourize unity native particles according to the other parameters like viscosity and vorticity. I am trying to colourize particles according to pressure. I thought that in this version it is possible. Btw, I can do colourize Obi particles according to pressure with ObiParticleRenderer like that;

void E_Solver_OnFrameEnd (object sender, EventArgs e)
{
if (!isActiveAndEnabled)
return;

for (int i = 0; i < emitter.particleIndices.Length; ++i)
{
int k = emitter.particleIndices[i];
float density = emitter.Solver.fluidData[k][0];
float restDensity = emitter.Solver.restDensities[k];

//calculate pressure
float Pressure = (density - restDensity) ;

//colorize Obi Particles according to pressure with considering user defined min and max values.
emitter.colors[i] = grad.Evaluate((Pressure - min) / (max - min));


}
}

(16-04-2019, 12:52 PM)mimarilker Wrote: I have resolved the problem by calling "alive = ps.GetParticles(particles);" in the "Solver_OnStepEnd" (see the attachment). However, I couldn't colourize unity native particles according to the other parameters like viscosity and vorticity. I am trying to colourize particles according to pressure. I thought that in this version it is possible. Btw, I can do colourize Obi particles according to pressure with ObiParticleRenderer like that;

void E_Solver_OnFrameEnd (object sender, EventArgs e)
{
   if (!isActiveAndEnabled)
return;

           for (int i = 0; i < emitter.particleIndices.Length; ++i)
       {
               int k = emitter.particleIndices[i];
               float density = emitter.Solver.fluidData[k][0];
               float restDensity = emitter.Solver.restDensities[k];
               
               //calculate pressure
               float Pressure = (density - restDensity) ;

               //colorize Obi Particles according to pressure with considering user defined min and max values.
               emitter.colors[i] = grad.Evaluate((Pressure - min) / (max - min));
             

           }
   }

Sorry for posting too much, but the script that I attached seemed to work to me, however, I have noticed that it's very problematic with respect to performance. So please don't consider it as a solution.


Attached Files
.cs   ParticleAdvector.cs (Size: 2.65 KB / Downloads: 1)
Reply


Messages In This Thread
ObiParticleRenderer - by mimarilker - 29-03-2019, 01:38 PM
RE: ObiParticleRenderer - by josemendez - 01-04-2019, 07:15 AM
RE: ObiParticleRenderer - by mimarilker - 09-04-2019, 09:55 AM
RE: ObiParticleRenderer - by josemendez - 09-04-2019, 10:09 AM
RE: ObiParticleRenderer - by josemendez - 10-04-2019, 12:47 PM
RE: ObiParticleRenderer - by mimarilker - 10-04-2019, 02:15 PM
RE: ObiParticleRenderer - by josemendez - 10-04-2019, 04:24 PM
RE: ObiParticleRenderer - by mimarilker - 16-04-2019, 09:42 AM
RE: ObiParticleRenderer - by mimarilker - 16-04-2019, 12:52 PM
RE: ObiParticleRenderer - by josemendez - 16-04-2019, 07:26 PM
RE: ObiParticleRenderer - by mimarilker - 17-04-2019, 07:44 AM