Пример #1
0
//============================================================================//
#if UNITY_EDITOR
        // INITALIZE //
        //
        override public void Initialize(BaseStack theOwnerStack, AmpsBlueprint theOwnerBlueprint)
        {
            base.Initialize(theOwnerStack, theOwnerBlueprint);

            subMenuName = AmpsHelpers.formatEnumString(eCategories.Basic.ToString());
            type        = "Scalar condition";
            SetDefaultName();

            useStackValue = ScriptableObject.CreateInstance <BoolProperty>();
            useStackValue.Initialize("Use stack value?", true, theOwnerBlueprint);
            AddProperty(useStackValue, true);

            valueA = ScriptableObject.CreateInstance <ScalarProperty>();
            valueA.Initialize("Value A", 0f, theOwnerBlueprint);
            AddProperty(valueA, true);

            condition = ScriptableObject.CreateInstance <DropdownProperty>();
            condition.Initialize("Condition", 0, theOwnerBlueprint);
            condition.SetDataModes(true, false, false, false, false, false);
            AddProperty(condition, false);

            valueB = ScriptableObject.CreateInstance <ScalarProperty>();
            valueB.Initialize("Value B", 1f, theOwnerBlueprint);
            AddProperty(valueB, true);

            valueFalse = ScriptableObject.CreateInstance <ScalarProperty>();
            valueFalse.Initialize("Output for FALSE", 1f, theOwnerBlueprint);
            AddProperty(valueFalse, true);

            valueTrue = ScriptableObject.CreateInstance <ScalarProperty>();
            valueTrue.Initialize("Output for TRUE", 1f, theOwnerBlueprint);
            AddProperty(valueTrue, true);
        }
Пример #2
0
        // CALCULATE FINAL POSITION //
        //
        public void CalculateFinalPosition()
        {
            foreach (Pool <ParticleMarker> .Node node in particleMarkers.ActiveNodes)
            {
                // We calculate velocity coming from direct positioning.
                Vector4 velocityFromPosition = (blueprint.positionStack.values[node.NodeIndex] - blueprint.positionStack.oldValues[node.NodeIndex]) / deltaTime;
                // Since we have no need for the old value anymore, we update it.
                blueprint.positionStack.oldValues[node.NodeIndex] = blueprint.positionStack.values[node.NodeIndex];
                // We factor in velocity coming from the velocity stack.
                blueprint.positionStack.values[node.NodeIndex] += AmpsHelpers.ConvertVector3Vector4(velocityAccumulators[node.NodeIndex], 0);

                // Update velocity data with the velocity change coming from direct positioning.
                blueprint.velocityStack.values[node.NodeIndex] += velocityFromPosition;
                // We calculate acceleration coming from direct velocity setting plus direct positioning.
                Vector4 accelerationFromVelocity = (blueprint.velocityStack.values[node.NodeIndex] - blueprint.velocityStack.oldValues[node.NodeIndex]) / deltaTime;
                // Since we have no need for the old value anymore, we update it.
                blueprint.velocityStack.oldValues[node.NodeIndex] = blueprint.velocityStack.values[node.NodeIndex];
                // Update acceleration data with some smoothing.
                blueprint.accelerationStack.values[node.NodeIndex] = Vector4.Lerp(blueprint.accelerationStack.oldValues[node.NodeIndex], blueprint.accelerationStack.values[node.NodeIndex]
                                                                                  + accelerationFromVelocity,
                                                                                  Mathf.Lerp(100, 0, emitterModule.accelerationNoiseSmoothing.constant) * deltaTime);
                // We store the current values for later use.
                blueprint.accelerationStack.oldValues[node.NodeIndex] = blueprint.accelerationStack.values[node.NodeIndex];
            }
        }
Пример #3
0
        // EVALUATE //
        //
        // Evaluate when particle specific data IS available.
        override public void Evaluate(ref Vector4[] input)
        {
            int particleIndex;

            for (int i = 0; i < ownerBlueprint.ownerEmitter.activeParticleIndices.Length; i++)
            {
                particleIndex = ownerBlueprint.ownerEmitter.activeParticleIndices[i];
                switch (conversionMode.GetValue())
                {
                case (int)eConversionModes.DirectionToRotation:
                    // TODO: Choose upvector.
                    Vector3 lookRotation = input[particleIndex];
                    if (lookRotation == Vector3.zero)
                    {
                        lookRotation.x = 0.00001f;
                    }
                    input[particleIndex] = Quaternion.LookRotation(lookRotation, Vector3.up).eulerAngles;
                    break;

                case (int)eConversionModes.RotationToDirection:
                    input[particleIndex] = Quaternion.Euler(input[particleIndex]) * Vector3.forward;
                    break;

                case (int)eConversionModes.HSVToRGB:
                    input[particleIndex] = AmpsHelpers.HSVAtoRGBA(input[particleIndex]);
                    break;

                case (int)eConversionModes.RGBToHSV:
                    input[particleIndex] = AmpsHelpers.RGBAtoHSVA(input[particleIndex]);
                    break;
                }
            }
        }
Пример #4
0
//============================================================================//
#if UNITY_EDITOR
        // INITIALIZE //
        //
        override public void Initialize(BaseStack theOwnerStack, AmpsBlueprint theOwnerBlueprint)
        {
            base.Initialize(theOwnerStack, theOwnerBlueprint);

            subMenuName = AmpsHelpers.formatEnumString(eCategories.Basic.ToString());
            type        = "Property sampler";
            SetDefaultName();

            property = ScriptableObject.CreateInstance <DropdownProperty>();
            property.Initialize("Property", 0, theOwnerBlueprint);
            AddProperty(property, true);
            sampleFromParent = ScriptableObject.CreateInstance <BoolProperty>();
            sampleFromParent.Initialize("Sample parent?", false, property.ownerBlueprint);
            AddProperty(sampleFromParent, true);
            modifyX = ScriptableObject.CreateInstance <BoolProperty>();
            modifyX.Initialize("Modify X?", true, theOwnerBlueprint);
            AddProperty(modifyX, true);
            modifyY = ScriptableObject.CreateInstance <BoolProperty>();
            modifyY.Initialize("Modify Y?", true, theOwnerBlueprint);
            AddProperty(modifyY, true);
            modifyZ = ScriptableObject.CreateInstance <BoolProperty>();
            modifyZ.Initialize("Modify Z?", true, theOwnerBlueprint);
            AddProperty(modifyZ, true);
            modifyW = ScriptableObject.CreateInstance <BoolProperty>();
            modifyW.Initialize("Modify W?", true, theOwnerBlueprint);
            AddProperty(modifyW, true);
        }
Пример #5
0
        // EVALUATE //
        //
        // Evaluate when particle specific data IS available.
        override public void Evaluate(ref Vector4[] input)
        {
                        #if UNITY_EDITOR
            Vector4 v;
            if (ownerBlueprint.ownerEmitter.exampleInputParticleIndex < 0)
            {
                return;
            }

            if (showCurrentStack.GetValue())
            {
                v = input[ownerBlueprint.ownerEmitter.exampleInputParticleIndex];
            }
            else
            {
                v = AmpsHelpers.GetSystemProperty(ownerBlueprint, ownerBlueprint.ownerEmitter.exampleInputParticleIndex, (AmpsHelpers.eCurveInputs)property.GetValue());
            }

            label.value = v.x.ToString("F3") + ", " +
                          v.y.ToString("F3") + ", " +
                          v.z.ToString("F3") + ", " +
                          v.w.ToString("F3");
            moduleName.value = label.value;
                        #endif
        }
Пример #6
0
//============================================================================//
#if UNITY_EDITOR
        // INITIALIZE //
        //
        virtual public void Initialize(AmpsBlueprint theOwnerBlueprint, AmpsHelpers.eStackFunction theStackFunction, string theModuleType)
        {
            stackFunction  = theStackFunction;
            name           = AmpsHelpers.formatEnumString(theStackFunction.ToString());
            moduleType     = theModuleType;
            ownerBlueprint = theOwnerBlueprint;
        }
Пример #7
0
//============================================================================//
#if UNITY_EDITOR
        // INITALIZE //
        //
        override public void Initialize(BaseStack theOwnerStack, AmpsBlueprint theOwnerBlueprint)
        {
            base.Initialize(theOwnerStack, theOwnerBlueprint);

            subMenuName = AmpsHelpers.formatEnumString(eCategories.Math.ToString());
            type        = "Normalize";
            SetDefaultName();
        }
Пример #8
0
 // ACCUMULATE ROTATION RATE //
 //
 public void AccumulateRotationRate()
 {
     foreach (Pool <ParticleMarker> .Node node in particleMarkers.ActiveNodes)
     {
         rotationRateAccumulators[node.NodeIndex] += AmpsHelpers.ConvertVector4Vector3(blueprint.rotationRateStack.values[node.NodeIndex])
                                                     * deltaTime;
     }
 }
Пример #9
0
 // ACCUMULATE VELOCITY //
 //
 public void AccumulateVelocity()
 {
     foreach (Pool <ParticleMarker> .Node node in particleMarkers.ActiveNodes)
     {
         blueprint.velocityStack.values[node.NodeIndex] += AmpsHelpers.ConvertVector3Vector4(accelerationAccumulators[node.NodeIndex], 0);
         velocityAccumulators[node.NodeIndex]           += AmpsHelpers.ConvertVector4Vector3(blueprint.velocityStack.values[node.NodeIndex]) * deltaTime;
     }
 }
Пример #10
0
        // SHOW POSITION VISUALIZATION //
        //
        private void ShowPositionVisualization()
        {
            Vector4 v;

            BaseProperty.eDataMode dm;

            if (value.dataMode == BaseProperty.eDataMode.Reference)
            {
                dm = value.reference.property.dataMode;
            }
            else
            {
                dm = value.dataMode;
            }

            switch (dm)
            {
            case VectorProperty.eDataMode.Constant:
                Handles.color = new Color(1f, 1f, 1f, 1f);
                v             = value.GetValue(ownerBlueprint.ownerEmitter.exampleInputParticleIndex);
                AmpsHelpers.DrawPositionHandle(v, 0.125f, weight.GetValue(ownerBlueprint.ownerEmitter.exampleInputParticleIndex));
                break;

            case VectorProperty.eDataMode.RandomConstant:
                if (value.coordSystemConversionMode != BaseProperty.eCoordSystemConversionMode.NoConversion)
                {
                    v = value.ConvertCoordinateSystem(value.randomMin, ownerBlueprint.ownerEmitter.exampleInputParticleIndex);
                }
                else
                {
                    v = value.randomMin;
                }
                Handles.color = new Color(1f, 1f, 1f, 1f);
                AmpsHelpers.DrawPositionHandle(v, 0.0625f, weight.GetValue(ownerBlueprint.ownerEmitter.exampleInputParticleIndex));

                if (value.coordSystemConversionMode != BaseProperty.eCoordSystemConversionMode.NoConversion)
                {
                    v = value.ConvertCoordinateSystem(value.randomMax, ownerBlueprint.ownerEmitter.exampleInputParticleIndex);
                }
                else
                {
                    v = value.randomMax;
                }
                Handles.color = new Color(1f, 1f, 1f, 1f);
                AmpsHelpers.DrawPositionHandle(v, 0.125f, weight.GetValue(ownerBlueprint.ownerEmitter.exampleInputParticleIndex));
                break;

            case VectorProperty.eDataMode.Curve:
                //Handles.color = Color.white;
                //v = value.GetValue(ownerEmitter.exampleInputParticleIndex);
                //AmpsHelpers.DrawCrossHandle(v, 0.125f);
                break;

            case VectorProperty.eDataMode.RandomCurve:
                // TODO: RandomCurve vis.
                break;
            }
        }
Пример #11
0
//============================================================================//
        #region GUI

        // SHOW PROPERTIES //
        //
        override public void ShowProperties(ref bool shouldRepaint)
        {
            moduleName.ShowProperty(ref selectedProperty, false);

            useCurrentStack.ShowProperty(ref selectedProperty, false);
            if (useCurrentStack.GetValue() == false)
            {
                if (property.displayData == null)
                {
                    property.displayData = () => AmpsHelpers.curveInputDisplayData;                                               // We have to do this here because delegates are not serialized.
                }
                property.ShowProperty(ref selectedProperty, false);
            }

            if ((useCurrentStack.GetValue() == false &&
                 AmpsHelpers.isFloatInput((AmpsHelpers.eCurveInputs)property.GetValue()) == false)
                ||
                (useCurrentStack.GetValue() &&
                 AmpsHelpers.isFloatStack(ownerStack.stackFunction) == false))
            {
                if (propertyVectorComponent.displayData == null)
                {
                    propertyVectorComponent.displayData = () => AmpsHelpers.vectorComponentsDisplayData;                                                              // We have to do this here because delegates are not serialized.
                }
                propertyVectorComponent.ShowProperty(ref selectedProperty, false);
            }

            if (condition.displayData == null)
            {
                condition.displayData = () => conditionsDisplayData;                                            // We have to do this here because delegates are not serialized.
            }
            condition.ShowProperty(ref selectedProperty, false);
            value.ShowProperty(ref selectedProperty, false);

            if (action.displayData == null)
            {
                action.displayData = () => actionsDisplayData;                                         // We have to do this here because delegates are not serialized.
            }
            action.ShowProperty(ref selectedProperty, false);

            PropertyGroup("Constraints");
            if (maxEventCount == null)                  // HACK
            {
                maxEventCount = ScriptableObject.CreateInstance <ScalarProperty>();
                maxEventCount.Initialize("Max event count per loop", 1f, ownerBlueprint);
                maxEventCount.SetDataModes(true, false, false, false, false, false);
                maxEventCount.isInteger = true;
                AddProperty(maxEventCount, false);
            }
            maxEventCount.ShowProperty(ref selectedProperty, false);
            minEventDelay.ShowProperty(ref selectedProperty, false);

            shouldRepaint = true;
        }
Пример #12
0
//============================================================================//
#if UNITY_EDITOR
        // INITALIZE //
        //
        override public void Initialize(BaseStack theOwnerStack, AmpsBlueprint theOwnerBlueprint)
        {
            base.Initialize(theOwnerStack, theOwnerBlueprint);

            subMenuName = AmpsHelpers.formatEnumString(eCategories.Math.ToString());
            type        = "Converter";
            SetDefaultName();

            conversionMode = ScriptableObject.CreateInstance <DropdownProperty>();
            conversionMode.Initialize("Conversion mode", 0, theOwnerBlueprint);
            AddProperty(conversionMode, true);
        }
Пример #13
0
//============================================================================//
#if UNITY_EDITOR
        // INITALIZE //
        //
        override public void Initialize(BaseStack theOwnerStack, AmpsBlueprint theOwnerBlueprint)
        {
            base.Initialize(theOwnerStack, theOwnerBlueprint);

            subMenuName = AmpsHelpers.formatEnumString(eCategories.Basic.ToString());
            type        = "Scalar";
            SetDefaultName();

            value = ScriptableObject.CreateInstance <ScalarProperty>();
            value.Initialize("Value", 1f, theOwnerBlueprint);
            AddProperty(value, true);
        }
Пример #14
0
        //============================================================================//
#if UNITY_EDITOR
        // INITIALIZE //
        //
        override public void Initialize(BaseStack theOwnerStack, AmpsBlueprint theOwnerBlueprint)
        {
            base.Initialize(theOwnerStack, theOwnerBlueprint);

            subMenuName = AmpsHelpers.formatEnumString(eCategories.Basic.ToString());
            type        = "Color";
            SetDefaultName();

            value = ScriptableObject.CreateInstance <ColorProperty>();
            value.Initialize("Color", Vector4.one, theOwnerBlueprint);
            AddProperty(value, true);
            implementsVisualization = false;
        }
Пример #15
0
//============================================================================//
#if UNITY_EDITOR
        // INITIALIZE //
        //
        override public void Initialize(BaseStack theOwnerStack, AmpsBlueprint theOwnerBlueprint)
        {
            base.Initialize(theOwnerStack, theOwnerBlueprint);

            subMenuName = AmpsHelpers.formatEnumString(eCategories.Basic.ToString());
            type        = "Vector sampler";
            SetDefaultName();

            vector = ScriptableObject.CreateInstance <VectorProperty>();
            vector.Initialize("Vector", Vector4.zero, theOwnerBlueprint);
            vector.coordSystemConversionMode = BaseProperty.eCoordSystemConversionMode.NoConversion;
            AddProperty(vector, true);
        }
Пример #16
0
//============================================================================//
#if UNITY_EDITOR
        // INITIALIZE //
        //
        override public void Initialize(BaseStack theOwnerStack, AmpsBlueprint theOwnerBlueprint)
        {
            base.Initialize(theOwnerStack, theOwnerBlueprint);

            subMenuName = AmpsHelpers.formatEnumString(eCategories.Misc.ToString());
            type        = "Event listener";
            SetDefaultName();

            eventName = ScriptableObject.CreateInstance <StringProperty>();
            eventName.Initialize("Event name", theOwnerBlueprint);
            eventName.value = "event";
            eventName.SetDataModes(true, false, false, false, false, false);
            AddProperty(eventName, false);

            untriggeredValue = ScriptableObject.CreateInstance <VectorProperty>();
            untriggeredValue.Initialize("Untriggered value", theOwnerBlueprint);
            AddProperty(untriggeredValue, false);

            triggeredCustomValue = ScriptableObject.CreateInstance <VectorProperty>();
            triggeredCustomValue.Initialize("Triggered value", theOwnerBlueprint);
            triggeredCustomValue.constant = new Vector4(1, 0, 0, 0);
            AddProperty(triggeredCustomValue, false);

            triggerDataMode = ScriptableObject.CreateInstance <DropdownProperty>();
            triggerDataMode.Initialize("Trigger data mode", 0, theOwnerBlueprint);
            triggerDataMode.SetDataModes(true, false, false, false, false, false);
            AddProperty(triggerDataMode, false);

            infiniteTriggerCount = ScriptableObject.CreateInstance <BoolProperty>();
            infiniteTriggerCount.Initialize("Infinite trigger count?", theOwnerBlueprint);
            infiniteTriggerCount.value = true;
            infiniteTriggerCount.SetDataModes(true, false, false, false, false, false);
            AddProperty(infiniteTriggerCount, false);

            maxTriggerCount = ScriptableObject.CreateInstance <ScalarProperty>();
            maxTriggerCount.Initialize("Max trigger count per loop", 1f, theOwnerBlueprint);
            maxTriggerCount.SetDataModes(true, false, false, false, false, false);
            maxTriggerCount.isInteger = true;
            AddProperty(maxTriggerCount, false);

            triggerToggle = ScriptableObject.CreateInstance <BoolProperty>();
            triggerToggle.Initialize("Does an event toggle?", theOwnerBlueprint);
            triggerToggle.value = true;
            triggerToggle.SetDataModes(true, false, false, false, false, false);
            AddProperty(triggerToggle, false);

            triggerDuration = ScriptableObject.CreateInstance <ScalarProperty>();
            triggerDuration.Initialize("Trigger duration", 1f, theOwnerBlueprint);
            triggerDuration.SetDataModes(true, true, false, false, false, false);
            AddProperty(triggerDuration, false);
        }
Пример #17
0
//============================================================================//
#if UNITY_EDITOR
        // INITIALIZE //
        //
        override public void Initialize(BaseStack theOwnerStack, AmpsBlueprint theOwnerBlueprint)
        {
            base.Initialize(theOwnerStack, theOwnerBlueprint);

            subMenuName = AmpsHelpers.formatEnumString(eCategories.Misc.ToString());
            type        = "Child control";
            SetDefaultName();

            value = ScriptableObject.CreateInstance <ScalarProperty>();
            value.Initialize("Value", 0f, theOwnerBlueprint);
            value.SetDataModes(true, false, false, false, false, false);
            AddProperty(value, false);

            condition = ScriptableObject.CreateInstance <DropdownProperty>();
            condition.Initialize("Condition", 0, theOwnerBlueprint);
            condition.SetDataModes(true, false, false, false, false, false);
            AddProperty(condition, false);

            useCurrentStack = ScriptableObject.CreateInstance <BoolProperty>();
            useCurrentStack.Initialize("Current stack?", theOwnerBlueprint);
            useCurrentStack.value = true;
            useCurrentStack.SetDataModes(true, false, false, false, false, false);
            AddProperty(useCurrentStack, false);

            property = ScriptableObject.CreateInstance <DropdownProperty>();
            property.Initialize("Property", 0, theOwnerBlueprint);
            property.SetDataModes(true, false, false, false, false, false);
            AddProperty(property, false);

            propertyVectorComponent = ScriptableObject.CreateInstance <DropdownProperty>();
            propertyVectorComponent.Initialize("Component", 0, theOwnerBlueprint);
            propertyVectorComponent.SetDataModes(true, false, false, false, false, false);
            AddProperty(propertyVectorComponent, false);

            action = ScriptableObject.CreateInstance <DropdownProperty>();
            action.Initialize("Action", 0, theOwnerBlueprint);
            action.SetDataModes(true, false, false, false, false, false);
            AddProperty(action, false);

            maxEventCount = ScriptableObject.CreateInstance <ScalarProperty>();
            maxEventCount.Initialize("Max event count per loop", 1f, theOwnerBlueprint);
            maxEventCount.SetDataModes(true, false, false, false, false, false);
            maxEventCount.isInteger = true;
            AddProperty(maxEventCount, false);

            minEventDelay = ScriptableObject.CreateInstance <ScalarProperty>();
            minEventDelay.Initialize("Min event delay", 0.1f, theOwnerBlueprint);
            minEventDelay.SetDataModes(true, false, false, false, false, false);
            AddProperty(minEventDelay, false);
        }
Пример #18
0
//============================================================================//
#if UNITY_EDITOR
        // INITIALIZE //
        //
        override public void Initialize(BaseStack theOwnerStack, AmpsBlueprint theOwnerBlueprint)
        {
            base.Initialize(theOwnerStack, theOwnerBlueprint);

            subMenuName = AmpsHelpers.formatEnumString(eCategories.Shapes.ToString());
            type        = "Point sampler";
            SetDefaultName();

            point = ScriptableObject.CreateInstance <VectorProperty>();
            point.Initialize("Point", Vector4.zero, theOwnerBlueprint);
            point.coordSystemConversionMode = BaseProperty.eCoordSystemConversionMode.AsPosition;
            implementsVisualization         = true;
            AddProperty(point, true);
        }
Пример #19
0
//============================================================================//
#if UNITY_EDITOR
        // INITIALIZE //
        //
        override public void Initialize(BaseStack theOwnerStack, AmpsBlueprint theOwnerBlueprint)
        {
            base.Initialize(theOwnerStack, theOwnerBlueprint);

            subMenuName = AmpsHelpers.formatEnumString(eCategories.Basic.ToString());
            type        = "Vector";
            SetDefaultName();

            value = ScriptableObject.CreateInstance <VectorProperty>();
            value.Initialize("Value", Vector4.zero, theOwnerBlueprint);
            value.SetConversionMode(theOwnerStack.stackFunction);
            value.SetDefaultCoordSystem(theOwnerStack.stackFunction);
            AddProperty(value, true);
            implementsVisualization = true;
        }
Пример #20
0
//============================================================================//
#if UNITY_EDITOR
        // INITALIZE //
        //
        override public void Initialize(BaseStack theOwnerStack, AmpsBlueprint theOwnerBlueprint)
        {
            base.Initialize(theOwnerStack, theOwnerBlueprint);

            subMenuName = AmpsHelpers.formatEnumString(eCategories.Basic.ToString());
            type        = "Scalar accumulator";
            SetDefaultName();

            useStackValue = ScriptableObject.CreateInstance <BoolProperty>();
            useStackValue.Initialize("Use stack value?", true, theOwnerBlueprint);
            AddProperty(useStackValue, true);

            changePerSecond = ScriptableObject.CreateInstance <ScalarProperty>();
            changePerSecond.Initialize("Change per second", 1f, theOwnerBlueprint);
            AddProperty(changePerSecond, true);
        }
Пример #21
0
        public int randomSeed = 0;                                      // A property specific random seed;

        // CONVERT COORDINATE SYSTEM //
        //
        // TODO: Move it to AmpsHelpers.
        public Vector4 ConvertCoordinateSystem(Vector4 v, int particleIndex)
        {
            Vector3 returnValue = v;

            switch (coordSystem)
            {
            case AmpsHelpers.eCoordSystems.World:
                //switch (coordSystemConversionMode)
                //{
                //    case eCoordSystemConversionMode.AsPosition:
                //        break;
                //    case eCoordSystemConversionMode.AsRotation:
                //        break;
                //    case eCoordSystemConversionMode.AsVelocity:
                //        break;
                //    case eCoordSystemConversionMode.AsScale:
                //        break;
                //}
                break;

            case AmpsHelpers.eCoordSystems.Emitter:
                switch (coordSystemConversionMode)
                {
                case eCoordSystemConversionMode.AsPosition:
                    returnValue += ownerBlueprint.ownerEmitter.transform.position;
                    returnValue  = AmpsHelpers.RotateAroundPoint(returnValue, ownerBlueprint.ownerEmitter.emitterPosition, ownerBlueprint.ownerEmitter.transform.rotation);
                    break;

                case eCoordSystemConversionMode.AsRotation:
                    returnValue += ownerBlueprint.ownerEmitter.transform.rotation.eulerAngles;
                    break;

                case eCoordSystemConversionMode.AsVelocity:
                    returnValue = ownerBlueprint.ownerEmitter.emitterMatrixPositionZero.MultiplyPoint3x4(returnValue);
                    break;

                case eCoordSystemConversionMode.AsScale:
                    returnValue.x *= ownerBlueprint.ownerEmitter.transform.lossyScale.x;
                    returnValue.y *= ownerBlueprint.ownerEmitter.transform.lossyScale.y;
                    returnValue.z *= ownerBlueprint.ownerEmitter.transform.lossyScale.z;
                    break;
                }
                break;
            }

            return(AmpsHelpers.ConvertVector3Vector4(returnValue, 0));
        }
Пример #22
0
//============================================================================//
#if UNITY_EDITOR
        // INITIALIZE //
        //
        override public void Initialize(BaseStack theOwnerStack, AmpsBlueprint theOwnerBlueprint)
        {
            base.Initialize(theOwnerStack, theOwnerBlueprint);

            subMenuName = AmpsHelpers.formatEnumString(eCategories.OtherObjects.ToString());
            type        = "Transform sampler";
            SetDefaultName();

            sampledObject = ScriptableObject.CreateInstance <GameObjectProperty>();
            sampledObject.Initialize("Object", null, theOwnerBlueprint);
            sampledObject.SetDataModes(false, false, false, false, false, true);
            AddProperty(sampledObject, false);
            sampledTransformElement = ScriptableObject.CreateInstance <DropdownProperty>();
            sampledTransformElement.Initialize("Transform", 0, theOwnerBlueprint);
            AddProperty(sampledTransformElement, true);
            implementsVisualization = false;
        }
Пример #23
0
        // SHOW OPTIONS //
        //
        public void ShowOptions()
        {
            GenericMenu propertyOptionsMenu = new GenericMenu();

            propertyOptionsMenu.AddItem(new GUIContent(AmpsHelpers.formatEnumString(AmpsHelpers.ePropertyOperations.Constant.ToString())),
                                        false,
                                        SetModeConstant);

            if (allowDataModeRandomConstant)
            {
                propertyOptionsMenu.AddItem(new GUIContent(AmpsHelpers.formatEnumString(AmpsHelpers.ePropertyOperations.Random.ToString())),
                                            false,
                                            SetModeRandom);
            }

            if (allowDataModeCurve)
            {
                propertyOptionsMenu.AddItem(new GUIContent(AmpsHelpers.formatEnumString(AmpsHelpers.ePropertyOperations.Curve.ToString())),
                                            false,
                                            SetModeCurve);
            }

            if (allowDataModeRandomCurve)
            {
                propertyOptionsMenu.AddItem(new GUIContent(AmpsHelpers.formatEnumString(AmpsHelpers.ePropertyOperations.RandomCurve.ToString())),
                                            false,
                                            SetModeRandomCurve);
            }

            if (allowDataModeReference)
            {
                propertyOptionsMenu.AddItem(new GUIContent(AmpsHelpers.formatEnumString(AmpsHelpers.ePropertyOperations.Reference.ToString())),
                                            false,
                                            SetModeReference);
            }

            if (allowDataModeParameter)
            {
                propertyOptionsMenu.AddItem(new GUIContent(AmpsHelpers.formatEnumString(AmpsHelpers.ePropertyOperations.Parameter.ToString())),
                                            false,
                                            SetModeParameter);
            }
            propertyOptionsMenu.ShowAsContext();
        }
Пример #24
0
        // MANAGE SAMPLING //
        //
        // Does the actual sampling.
        override public void ManageSampling(int particleIndex)
        {
            Vector3  testedPosition = Vector3.zero;
            Collider theCollider;

            // If this is the first frame of a new particle then we skip sampling and wait for the next round
            // when the position stack will have been evaluated and updated from its default (0,0,0) value.
            if (particleIndex >= 0 && ownerBlueprint.ownerEmitter.particleTimes[particleIndex] < 0.1)
            {
                return;                                                                                                         // HACK: There are misses when it's less than 0.1 for some reason.
            }
            if ((particleIndex < 0 && ShouldSample()) || (particleIndex >= 0 && ShouldSample(particleIndex)))
            {
                if (particleIndex < 0)
                {
                    testedPosition = AmpsHelpers.GetSystemProperty(ownerBlueprint, particleIndex, AmpsHelpers.eCurveInputs.EmitterPosition);
                }
                else
                {
                    testedPosition = AmpsHelpers.GetSystemProperty(ownerBlueprint, particleIndex, AmpsHelpers.eCurveInputs.Position);
                }

                theCollider = sampledObject.GetValue().GetComponent <Collider>();
                if (theCollider != null)
                {
                    Vector3    theRayVector    = theCollider.transform.position - testedPosition;
                    Ray        theRay          = new Ray(testedPosition, Vector3.Normalize(theRayVector));
                    RaycastHit theRaycastHit   = new RaycastHit();
                    bool       gotIntersection = theCollider.Raycast(theRay, out theRaycastHit, theRayVector.magnitude);
                    //Debug.DrawLine(theCollider.transform.position, testedPosition);

                    if (gotIntersection)
                    {
                        isInsideFlags[particleIndex] = false;
                    }
                    else
                    {
                        isInsideFlags[particleIndex] = true;
                    }
                }
            }
        }
Пример #25
0
        // EVALUATE //
        //
        public float Evaluate(AmpsEmitter ownerEmitter, int particleIndex)
        {
            float returnValue = 0;

            // If a particle related curve input was chosen but particle data is not available
            // then we just return 0 like a champ. (index == -1, typically when the owner
            // property is in an emitter property stack where particle data and index is meaningless.)
            //
            // TODO: We might need a mechanic to show warnings.
            if (AmpsHelpers.isParticleRelatedInput(curveInput) && particleIndex < 0)
            {
                return(0);
            }

            float finalCurveInput = GetCurveInput(ownerEmitter.blueprint, particleIndex);

            // Remap output.
            returnValue = Mathf.Lerp(outputRangeMin, outputRangeMax, curve.Evaluate(finalCurveInput));

            return(returnValue);
        }
Пример #26
0
        //============================================================================//
#if UNITY_EDITOR
        // INITIALIZE //
        //
        override public void Initialize(BaseStack theOwnerStack, AmpsBlueprint theOwnerBlueprint)
        {
            base.Initialize(theOwnerStack, theOwnerBlueprint);

            subMenuName = AmpsHelpers.formatEnumString(eCategories.Shapes.ToString());
            type        = "Mesh sampler";
            SetDefaultName();

            sampledMesh = ScriptableObject.CreateInstance <MeshProperty>();
            sampledMesh.Initialize("Mesh");
            AddProperty(sampledMesh, true);
            sampledMeshElement = ScriptableObject.CreateInstance <DropdownProperty>();
            sampledMeshElement.Initialize("Element", 0, theOwnerBlueprint);
            AddProperty(sampledMeshElement, true);
            samplingOrder = ScriptableObject.CreateInstance <DropdownProperty>();
            samplingOrder.Initialize("Order", 0, theOwnerBlueprint);
            AddProperty(samplingOrder, true);
            isEmitterRelative = ScriptableObject.CreateInstance <BoolProperty>();
            isEmitterRelative.Initialize("Emitter relative?", theOwnerBlueprint);
            AddProperty(isEmitterRelative, true);
            implementsVisualization = false;
        }
Пример #27
0
//============================================================================//
#if UNITY_EDITOR
        // INITIALIZE //
        //
        override public void Initialize(BaseStack theOwnerStack, AmpsBlueprint theOwnerBlueprint)
        {
            base.Initialize(theOwnerStack, theOwnerBlueprint);

            subMenuName = AmpsHelpers.formatEnumString(eCategories.Misc.ToString());
            type        = "Info";
            SetDefaultName();

            label = ScriptableObject.CreateInstance <StringProperty>();
            label.Initialize("=", theOwnerBlueprint);
            label.value = "n.a.";
            AddProperty(label, false);

            showCurrentStack = ScriptableObject.CreateInstance <BoolProperty>();
            showCurrentStack.Initialize("Show current stack value?", theOwnerBlueprint);
            showCurrentStack.value = true;
            showCurrentStack.SetDataModes(true, false, false, false, false, false);
            AddProperty(showCurrentStack, false);

            property = ScriptableObject.CreateInstance <DropdownProperty>();
            property.Initialize("Property", 0, theOwnerBlueprint);
            AddProperty(property, true);
        }
Пример #28
0
        // EVALUATE //
        //
        // Evaluate when particle specific data IS available.
        override public void Evaluate(ref Vector4[] input)
        {
            Vector4 finalValue = Vector4.zero;

            int particleIndex;

            for (int i = 0; i < ownerBlueprint.ownerEmitter.activeParticleIndices.Length; i++)
            {
                particleIndex = ownerBlueprint.ownerEmitter.activeParticleIndices[i];
                if (ownerStack.isVector3Stack)
                {
                    Vector3 v = new Vector3(input[particleIndex].x, input[particleIndex].y, input[particleIndex].z);
                    v          = v.normalized;
                    finalValue = AmpsHelpers.ConvertVector3Vector4(v, 0);
                }
                else
                {
                    finalValue = input[particleIndex].normalized;
                }

                input[particleIndex] = Blend(input[particleIndex], finalValue, weight.GetValue(particleIndex));
            }
        }
Пример #29
0
//============================================================================//
#if UNITY_EDITOR
        // INITIALIZE //
        //
        override public void Initialize(BaseStack theOwnerStack, AmpsBlueprint theOwnerBlueprint)
        {
            base.Initialize(theOwnerStack, theOwnerBlueprint);

            subMenuName = AmpsHelpers.formatEnumString(eCategories.OtherObjects.ToString());
            type        = "Volume sampler";
            SetDefaultName();

            sampledObject = ScriptableObject.CreateInstance <GameObjectProperty>();
            sampledObject.Initialize("Object", null, theOwnerBlueprint);
            sampledObject.SetDataModes(false, false, false, false, false, true);
            AddProperty(sampledObject, false);
            insideValue = ScriptableObject.CreateInstance <VectorProperty>();
            insideValue.Initialize("Value if inside", Vector4.one, theOwnerBlueprint);
            insideValue.SetConversionMode(theOwnerStack.stackFunction);
            insideValue.SetDefaultCoordSystem(theOwnerStack.stackFunction);
            AddProperty(insideValue, true);
            outsideValue = ScriptableObject.CreateInstance <VectorProperty>();
            outsideValue.Initialize("Value if outside", Vector4.one, theOwnerBlueprint);
            outsideValue.SetConversionMode(theOwnerStack.stackFunction);
            outsideValue.SetDefaultCoordSystem(theOwnerStack.stackFunction);
            AddProperty(outsideValue, true);
            implementsVisualization = false;
        }
Пример #30
0
        // EVALUATE //
        //
        public Vector4 Evaluate(AmpsEmitter ownerEmitter, int particleIndex)
        {
            Vector4 returnValue = Vector4.zero;

            // If a particle related curve input was chosen but particle data is not available
            // then we just return 0. (index == -1, typically when the owner property is in an
            // emitter property stack where particle data and index is meaningless.)
            //
            // TODO: We might need a mechanic to show warnings.
            if (AmpsHelpers.isParticleRelatedInput(curveInput) && particleIndex < 0)
            {
                return(Vector4.zero);
            }

            float finalCurveInput = GetCurveInput(ownerEmitter.blueprint, particleIndex);

            // Remap output.
            returnValue.x = Mathf.Lerp(outputRangeXMin, outputRangeXMax, curveX.Evaluate(finalCurveInput));
            returnValue.y = Mathf.Lerp(outputRangeYMin, outputRangeYMax, curveY.Evaluate(finalCurveInput));
            returnValue.z = Mathf.Lerp(outputRangeZMin, outputRangeZMax, curveZ.Evaluate(finalCurveInput));
            returnValue.w = Mathf.Lerp(outputRangeWMin, outputRangeWMax, curveW.Evaluate(finalCurveInput));

            return(returnValue);
        }