// EVALUATE //
        //
        // Evaluate when particle specific data is NOT available.
        override public void Evaluate(ref float input)
        {
            if (sampledObject.GetValue() != null)
            {
                ManageSampling(0);
            }

            // We only do anything if there is a valid sample to work with.
            if (lastSampleTimes[0] != -1)
            {
#if UNITY_EDITOR
                exampleInput = new Vector4(input, input, input, input);
                ownerBlueprint.ownerEmitter.exampleInputParticleIndex = -1;
#endif

                if (isInsideFlags[0])
                {
                    input = Blend(input, insideValue.GetValue(), weight.GetValue());
                }
                else
                {
                    input = Blend(input, outsideValue.GetValue(), weight.GetValue());
                }
            }
        }
Esempio n. 2
0
 // DO SAMPLE //
 //
 // Does the actual sampling.
 override public void ManageSampling(int particleIndex)
 {
     if (particleIndex < 0 && ShouldSample())
     {
         vector.Randomize();
         vectors[0] = vector.GetValue();
     }
     else if (particleIndex >= 0 && ShouldSample(particleIndex))
     {
         vector.Randomize();
         vectors[particleIndex] = vector.GetValue(particleIndex);
     }
 }
Esempio n. 3
0
 // MANAGE SAMPLING //
 //
 // Does the actual sampling.
 override public void ManageSampling(int particleIndex)
 {
     if (particleIndex < 0 && ShouldSample())
     {
         point.Randomize();
         points[0] = point.GetValue();
     }
     else if (particleIndex >= 0 && ShouldSample(particleIndex))
     {
         point.Randomize();
         points[particleIndex] = point.GetValue(particleIndex);
     }
 }
        // EVALUATE VELOCITY//
        //
        override public void Evaluate_Velocity()
        {
            if (modifyVelocity.GetValue() || modifyDisplacement.GetValue())
            {
                Vector4 v;

                int particleIndex;
                for (int i = 0; i < ownerBlueprint.ownerEmitter.activeParticleIndices.Length; i++)
                {
                    particleIndex = ownerBlueprint.ownerEmitter.activeParticleIndices[i];
                    if (modifyVelocity.GetValue())
                    {
                        v = velocityMultiplier.GetValue(particleIndex);
                        ownerBlueprint.velocityStack.values[particleIndex].x *= v.x;
                        ownerBlueprint.velocityStack.values[particleIndex].y *= v.y;
                        ownerBlueprint.velocityStack.values[particleIndex].z *= v.z;
                    }

                    if (modifyDisplacement.GetValue())
                    {
                        v = displacementMultiplier.GetValue(particleIndex);
                        ownerBlueprint.ownerEmitter.velocityAccumulators[particleIndex].x *= v.x;
                        ownerBlueprint.ownerEmitter.velocityAccumulators[particleIndex].y *= v.y;
                        ownerBlueprint.ownerEmitter.velocityAccumulators[particleIndex].z *= v.z;
                    }
                }
            }
        }
        // EVALUATE ACCELERATION//
        //
        override public void Evaluate_Acceleration()
        {
            if (modifyAcceleration.GetValue() || modifyMomentum.GetValue())
            {
                Vector4 v;

                int particleIndex;
                for (int i = 0; i < ownerBlueprint.ownerEmitter.activeParticleIndices.Length; i++)
                {
                    particleIndex = ownerBlueprint.ownerEmitter.activeParticleIndices[i];
                    if (modifyAcceleration.GetValue())
                    {
                        v = accelerationMultiplier.GetValue(particleIndex);
                        ownerBlueprint.accelerationStack.values[particleIndex].x *= v.x;
                        ownerBlueprint.accelerationStack.values[particleIndex].y *= v.y;
                        ownerBlueprint.accelerationStack.values[particleIndex].z *= v.z;
                    }

                    if (modifyMomentum.GetValue())
                    {
                        v = momentumMultiplier.GetValue(particleIndex);
                        ownerBlueprint.ownerEmitter.accelerationAccumulators[particleIndex].x *= v.x;
                        ownerBlueprint.ownerEmitter.accelerationAccumulators[particleIndex].y *= v.y;
                        ownerBlueprint.ownerEmitter.accelerationAccumulators[particleIndex].z *= v.z;
                    }
                }
            }
        }
        // EVALUATE //
        //
        // Evaluate when particle specific data is NOT available.
        override public void Evaluate(ref float input)
        {
            Vector4 finalValue = untriggeredValue.GetValue();

            if (ownerBlueprint.ownerEmitter.emitterLoopTime < previousLoopTime)
            {
                currentTriggerCount = 0;
            }
            previousLoopTime = ownerBlueprint.ownerEmitter.emitterLoopTime;
            if (triggerToggle.GetValue() == false &&
                ownerBlueprint.ownerEmitter.emitterTime > lastTriggerTime + triggerDuration.GetValue())
            {
                isTriggered = false;
            }

            if (isTriggered)
            {
                switch ((eTriggerDataModes)triggerDataMode.GetValue())
                {
                case eTriggerDataModes.CustomValue:
                    finalValue = triggeredCustomValue.GetValue();
                    break;

                case eTriggerDataModes.EventData1:
                    finalValue = lastEventData.DataSlot1;
                    break;

                case eTriggerDataModes.EventData2:
                    finalValue = lastEventData.DataSlot2;
                    break;

                case eTriggerDataModes.EventData3:
                    finalValue = lastEventData.DataSlot3;
                    break;

                case eTriggerDataModes.EventData4:
                    finalValue = lastEventData.DataSlot4;
                    break;
                }
            }

            input = Blend(input, finalValue, weight.GetValue());
        }
Esempio n. 7
0
 // EVALUATE POSITION//
 //
 override public void Evaluate_Position()
 {
     if (modifyPosition.GetValue())
     {
         int particleIndex;
         for (int i = 0; i < ownerBlueprint.ownerEmitter.activeParticleIndices.Length; i++)
         {
             particleIndex = ownerBlueprint.ownerEmitter.activeParticleIndices[i];
             ownerBlueprint.positionStack.values[particleIndex] = position.GetValue(particleIndex);
         }
     }
 }
Esempio n. 8
0
 // EVALUATE VELOCITY//
 //
 override public void Evaluate_Velocity()
 {
     if (modifyVelocity.GetValue())
     {
         int particleIndex;
         for (int i = 0; i < ownerBlueprint.ownerEmitter.activeParticleIndices.Length; i++)
         {
             particleIndex = ownerBlueprint.ownerEmitter.activeParticleIndices[i];
             ownerBlueprint.velocityStack.values[particleIndex] = velocity.GetValue(particleIndex);
         }
     }
 }
Esempio n. 9
0
 // EVALUATE SCALE//
 //
 override public void Evaluate_Scale()
 {
     if (modifyScale.GetValue())
     {
         int particleIndex;
         for (int i = 0; i < ownerBlueprint.ownerEmitter.activeParticleIndices.Length; i++)
         {
             particleIndex = ownerBlueprint.ownerEmitter.activeParticleIndices[i];
             ownerBlueprint.scaleStack.values[particleIndex] = scale.GetValue(particleIndex);
         }
     }
 }
Esempio n. 10
0
 // EVALUATE //
 //
 // Evaluate when particle specific data is NOT available.
 override public void Evaluate(ref float input)
 {
     input = Blend(input, value.GetValue(), weight.GetValue());
 }
Esempio n. 11
0
        // GET VALUE //
        //
        // GetValue when particle index is NOT known.
        public Vector4 GetValue()
        {
            Vector4 returnValue    = Vector4.zero;
            Vector4 curveMinResult = Vector4.zero;
            Vector4 curveMaxResult = Vector4.zero;

            System.Random theRandom = new System.Random(ownerBlueprint.ownerEmitter.randomSeed + randomSeed);

#if UNITY_EDITOR
            CheckReferences();
#endif

            switch (dataMode)
            {
            case eDataMode.Constant:
                returnValue = constant;
                break;

            case eDataMode.RandomConstant:
                if (usePerComponentRandom)
                {
                    if (useExtremes)
                    {
                        if ((float)theRandom.NextDouble() < 0.5)
                        {
                            returnValue.x = randomMin.x;
                        }
                        else
                        {
                            returnValue.x = randomMax.x;
                        }
                        if ((float)theRandom.NextDouble() < 0.5)
                        {
                            returnValue.y = randomMin.y;
                        }
                        else
                        {
                            returnValue.y = randomMax.y;
                        }
                        if ((float)theRandom.NextDouble() < 0.5)
                        {
                            returnValue.z = randomMin.z;
                        }
                        else
                        {
                            returnValue.z = randomMax.z;
                        }
                        if ((float)theRandom.NextDouble() < 0.5)
                        {
                            returnValue.w = randomMin.w;
                        }
                        else
                        {
                            returnValue.w = randomMax.w;
                        }
                    }
                    else
                    {
                        returnValue.x = Mathf.Lerp(randomMin.x, randomMax.x, (float)theRandom.NextDouble());
                        returnValue.y = Mathf.Lerp(randomMin.y, randomMax.y, (float)theRandom.NextDouble());
                        returnValue.z = Mathf.Lerp(randomMin.z, randomMax.z, (float)theRandom.NextDouble());
                        returnValue.w = Mathf.Lerp(randomMin.w, randomMax.w, (float)theRandom.NextDouble());
                    }
                }
                else
                {
                    returnValue = Vector4.Lerp(randomMin, randomMax, (float)theRandom.NextDouble());
                }
                break;

            case eDataMode.Curve:
                returnValue = curve.Evaluate(ownerBlueprint.ownerEmitter);
                break;

            case eDataMode.RandomCurve:
                if (usePerComponentRandom)
                {
                    curveMinResult = curveMin.Evaluate(ownerBlueprint.ownerEmitter);
                    curveMaxResult = curveMax.Evaluate(ownerBlueprint.ownerEmitter);

                    if (useExtremes)
                    {
                        if ((float)theRandom.NextDouble() < 0.5)
                        {
                            returnValue.x = curveMinResult.x;
                        }
                        else
                        {
                            returnValue.x = curveMaxResult.x;
                        }
                        if ((float)theRandom.NextDouble() < 0.5)
                        {
                            returnValue.y = curveMinResult.y;
                        }
                        else
                        {
                            returnValue.y = curveMaxResult.y;
                        }
                        if ((float)theRandom.NextDouble() < 0.5)
                        {
                            returnValue.z = curveMinResult.z;
                        }
                        else
                        {
                            returnValue.z = curveMaxResult.z;
                        }
                        if ((float)theRandom.NextDouble() < 0.5)
                        {
                            returnValue.w = curveMinResult.w;
                        }
                        else
                        {
                            returnValue.w = curveMaxResult.w;
                        }
                    }
                    else
                    {
                        returnValue.x = Mathf.Lerp(curveMinResult.x, curveMaxResult.x, (float)theRandom.NextDouble());
                        returnValue.y = Mathf.Lerp(curveMinResult.y, curveMaxResult.y, (float)theRandom.NextDouble());
                        returnValue.z = Mathf.Lerp(curveMinResult.z, curveMaxResult.z, (float)theRandom.NextDouble());
                        returnValue.w = Mathf.Lerp(curveMinResult.w, curveMaxResult.w, (float)theRandom.NextDouble());
                    }
                }
                else
                {
                    returnValue = Vector4.Lerp(curveMin.Evaluate(ownerBlueprint.ownerEmitter), curveMax.Evaluate(ownerBlueprint.ownerEmitter), (float)theRandom.NextDouble());
                }
                break;

            case eDataMode.Reference:
                if (reference != null)
                {
                    VectorProperty theReference = (VectorProperty)reference.property;
                    returnValue = theReference.GetValue();
                }
                break;

            case eDataMode.Parameter:
                if (wasParameterQueried == false)
                {
                    parameter           = ownerBlueprint.ownerEmitter.GetParameter(parameterName, AmpsHelpers.eParameterTypes.Vector);
                    wasParameterQueried = true;
                }
                if (parameter != null)
                {
                    returnValue = parameter.GetVectorValue();
                }
                else
                {
                    returnValue = constant;
                }
                break;
            }

            if (coordSystemConversionMode != BaseProperty.eCoordSystemConversionMode.NoConversion)
            {
                returnValue = ConvertCoordinateSystem(returnValue, -1);
            }

            return(returnValue);
        }