示例#1
0
        private Texture2D dummyTexture;         // Empty texture asset for drawing EditorGUI.DrawPreviewTexture().
#endif
//============================================================================//

        // 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)
                {
                    returnValue.x = Mathf.Lerp(randomMin.x, randomMax.x, (float)theRandom.NextDouble());
                    //Random.seed++;
                    returnValue.y = Mathf.Lerp(randomMin.y, randomMax.y, (float)theRandom.NextDouble());
                    //Random.seed++;
                    returnValue.z = Mathf.Lerp(randomMin.z, randomMax.z, (float)theRandom.NextDouble());
                    //Random.seed++;
                    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);

                    returnValue.x = Mathf.Lerp(curveMinResult.x, curveMaxResult.x, (float)theRandom.NextDouble());
                    //Random.seed++;
                    returnValue.y = Mathf.Lerp(curveMinResult.y, curveMaxResult.y, (float)theRandom.NextDouble());
                    //Random.seed++;
                    returnValue.z = Mathf.Lerp(curveMinResult.z, curveMaxResult.z, (float)theRandom.NextDouble());
                    //Random.seed++;
                    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)
                {
                    ColorProperty theReference = (ColorProperty)reference.property;
                    returnValue = theReference.GetValue();
                }
                break;
            }

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

            return(returnValue);
        }
示例#2
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);
        }