Point3 Up = new Point3 (0,0,1); //up vector //Remap public float remap(float s, float inMin, float inMax, float outMin, float outMax) {return outMin + (s-inMin)*(outMax-outMin)/(inMax-inMin);} //Clamp public float clamp(float value, float min, float max) { if (valuemax){value=max;} return value; } public void simulationStart() { } public void simulationStep() { for (int i = 0; i < eventParticleCount; i++) //this for-loop iterates through all particles in this event { int sInx = tf.GetSimIndex(i); int targetID = (int)tf.GetCustomFloat(sInx,"target"); int targetInx = tf.GetSimIndexFromID(targetID); Point3 ScaleTarget = tf.GetScale(targetInx); float radius = GetFloat("radiusMultiplier")*ScaleTarget.x/2; Point3 P = tf.GetPos(sInx); float dot = 1; if (GetFloat("useNormals")==1) { Matrix3 TM = tf.GetCustomTM(sInx,"TM"); Point3 N = TM.row3; N.Normalize(); Point3 TurbN = tf.GetTurbulence(0,N,0,GetFloat("turbNscale"),0); N = N + GetFloat("turbN")*TurbN; dot = (Point3.Dot(N,Up)+1)/2; dot = clamp(remap(dot,GetFloat("normalThreshold"),1,0,1),0,1); dot = (float)Math.Pow(dot,GetFloat("gamma")); } Point3 TurbP = tf.GetTurbulence(0,P,0,GetFloat("turbPscale"),0); P = P + GetFloat("turbP")*TurbP; Point3 Pobj = tf.GetPos(targetInx); float dist = 1-clamp(Point3.Distance(P,Pobj)/radius,0,1); Point3 UVW1 = new Point3(dist,0,0); float scaleDist = tex001.GetMonoVal(0,UVW1); float scaleNoise = 1; if (GetFloat("useTexture")==1) { Point3 UVW0 = GetFloat("useUVW")==1 ? tf.GetUVW(sInx,1) : P; scaleNoise = tex002.GetMonoVal(0,UVW0); } float scale = dot*scaleDist*scaleNoise*GetFloat("scaleMax"); Point3 Scale0 = new Point3 (scale,scale,scale); tf.SetScale(sInx,Scale0); Point3 UVW2 = new Point3 (0.99f,0,0); tf.SetUVW(sInx,2,UVW2); Point3 UVW3 = new Point3 (scale,0,0); tf.SetUVW(sInx,3,UVW3); tf.SetCustomFloat(sInx,"dot",dot); } } public void simulationStepThreaded(int startInx, int endInx, int threadInx) { } public void postSimulationStep() { } //__END__