public RandomRotation(IKeyValueCollection keyValues)
        {
            random = new Random();

            if (keyValues.ContainsKey("m_flDegreesMin"))
            {
                degreesMin = keyValues.GetFloatProperty("m_flDegreesMin");
            }

            if (keyValues.ContainsKey("m_flDegreesMax"))
            {
                degreesMax = keyValues.GetFloatProperty("m_flDegreesMax");
            }

            if (keyValues.ContainsKey("m_flDegrees"))
            {
                degreesOffset = keyValues.GetFloatProperty("m_flDegrees");
            }

            if (keyValues.ContainsKey("m_nFieldOutput"))
            {
                fieldOutput = keyValues.GetIntegerProperty("m_nFieldOutput");
            }

            if (keyValues.ContainsKey("m_bRandomlyFlipDirection"))
            {
                randomlyFlipDirection = keyValues.GetProperty <bool>("m_bRandomlyFlipDirection");
            }
        }
        public RandomRotationSpeed(IKeyValueCollection keyValues)
        {
            if (keyValues.ContainsKey("m_nFieldOutput"))
            {
                fieldOutput = (ParticleField)keyValues.GetIntegerProperty("m_nFieldOutput");
            }

            if (keyValues.ContainsKey("m_bRandomlyFlipDirection"))
            {
                randomlyFlipDirection = keyValues.GetProperty <bool>("m_bRandomlyFlipDirection");
            }

            if (keyValues.ContainsKey("m_flDegrees"))
            {
                degrees = keyValues.GetFloatProperty("m_flDegrees");
            }

            if (keyValues.ContainsKey("m_flDegreesMin"))
            {
                degreesMin = keyValues.GetFloatProperty("m_flDegreesMin");
            }

            if (keyValues.ContainsKey("m_flDegreesMax"))
            {
                degreesMax = keyValues.GetFloatProperty("m_flDegreesMax");
            }
        }
Exemple #3
0
        public RenderSprites(IKeyValueCollection keyValues, VrfGuiContext vrfGuiContext)
        {
            shaderProgram = SetupShaderProgram();

            // The same quad is reused for all particles
            quadVao = SetupQuadBuffer();

            var textureSetup = LoadTexture(keyValues.GetProperty <string>("m_hTexture"), vrfGuiContext);

            glTexture       = textureSetup.TextureIndex;
            spriteSheetData = textureSetup.TextureData.GetSpriteSheetData();

            additive = keyValues.GetProperty <bool>("m_bAdditive");
            if (keyValues.ContainsKey("m_flOverbrightFactor"))
            {
                overbrightFactor = keyValues.GetFloatProperty("m_flOverbrightFactor");
            }

            if (keyValues.ContainsKey("m_nOrientationType"))
            {
                orientationType = keyValues.GetIntegerProperty("m_nOrientationType");
            }

            if (keyValues.ContainsKey("m_flAnimationRate"))
            {
                animationRate = keyValues.GetFloatProperty("m_flAnimationRate");
            }
        }
        public RenderSprites(IKeyValueCollection keyValues, VrfGuiContext vrfGuiContext)
        {
            shader      = vrfGuiContext.ShaderLoader.LoadShader("vrf.particle.sprite", new Dictionary <string, bool>());
            quadIndices = vrfGuiContext.QuadIndices;

            // The same quad is reused for all particles
            quadVao = SetupQuadBuffer();

            if (keyValues.ContainsKey("m_hTexture"))
            {
                var textureSetup = LoadTexture(keyValues.GetProperty <string>("m_hTexture"), vrfGuiContext);
                glTexture       = textureSetup.TextureIndex;
                spriteSheetData = textureSetup.TextureData?.GetSpriteSheetData();
            }
            else
            {
                glTexture = vrfGuiContext.MaterialLoader.GetErrorTexture();
            }

            additive = keyValues.GetProperty <bool>("m_bAdditive");
            if (keyValues.ContainsKey("m_flOverbrightFactor"))
            {
                overbrightFactor = keyValues.GetFloatProperty("m_flOverbrightFactor");
            }

            if (keyValues.ContainsKey("m_nOrientationType"))
            {
                orientationType = keyValues.GetIntegerProperty("m_nOrientationType");
            }

            if (keyValues.ContainsKey("m_flAnimationRate"))
            {
                animationRate = keyValues.GetFloatProperty("m_flAnimationRate");
            }
        }
Exemple #5
0
        public RandomTrailLength(IKeyValueCollection keyValues)
        {
            if (keyValues.ContainsKey("m_flMinLength"))
            {
                minLength = keyValues.GetFloatProperty("m_flMinLength");
            }

            if (keyValues.ContainsKey("m_flMaxLength"))
            {
                maxLength = keyValues.GetFloatProperty("m_flMaxLength");
            }
        }
        public RandomLifeTime(IKeyValueCollection keyValues)
        {
            random = new Random();

            if (keyValues.ContainsKey("m_fLifetimeMin"))
            {
                lifetimeMin = keyValues.GetFloatProperty("m_fLifetimeMin");
            }

            if (keyValues.ContainsKey("m_fLifetimeMax"))
            {
                lifetimeMax = keyValues.GetFloatProperty("m_fLifetimeMax");
            }
        }
Exemple #7
0
        public RandomRadius(IKeyValueCollection keyValues)
        {
            random = new Random();

            if (keyValues.ContainsKey("m_flRadiusMin"))
            {
                radiusMin = keyValues.GetFloatProperty("m_flRadiusMin");
            }

            if (keyValues.ContainsKey("m_flRadiusMax"))
            {
                radiusMax = keyValues.GetFloatProperty("m_flRadiusMax");
            }
        }
Exemple #8
0
        public InstantaneousEmitter(IKeyValueCollection baseProperties, IKeyValueCollection keyValues)
        {
            this.baseProperties = baseProperties;

            emitCount = keyValues.GetNumberProvider("m_nParticlesToEmit");
            startTime = keyValues.GetFloatProperty("m_flStartTime");
        }
 public FadeOutSimple(IKeyValueCollection keyValues)
 {
     if (keyValues.ContainsKey("m_flFadeOutTime"))
     {
         fadeOutTime = keyValues.GetFloatProperty("m_flFadeOutTime");
     }
 }
        public ColorInterpolate(IKeyValueCollection keyValues)
        {
            if (keyValues.ContainsKey("m_ColorFade"))
            {
                var vectorValues = keyValues.GetIntegerArray("m_ColorFade");
                colorFade = new Vector3(vectorValues[0], vectorValues[1], vectorValues[2]) / 255f;
            }

            if (keyValues.ContainsKey("m_flFadeStartTime"))
            {
                fadeStartTime = keyValues.GetFloatProperty("m_flFadeStartTime");
            }

            if (keyValues.ContainsKey("m_flFadeEndTime"))
            {
                fadeEndTime = keyValues.GetFloatProperty("m_flFadeEndTime");
            }
        }
Exemple #11
0
        public ContinuousEmitter(IKeyValueCollection baseProperties, IKeyValueCollection keyValues)
        {
            this.baseProperties = baseProperties;

            if (keyValues.ContainsKey("m_flEmissionDuration"))
            {
                emissionDuration = keyValues.GetFloatProperty("m_flEmissionDuration");
            }

            if (keyValues.ContainsKey("m_flStartTime"))
            {
                startTime = keyValues.GetFloatProperty("m_flStartTime");
            }

            if (keyValues.ContainsKey("m_flEmitRate"))
            {
                emitRate     = keyValues.GetFloatProperty("m_flEmitRate");
                emitInterval = 1 / emitRate;
            }
        }
        public Particle(IKeyValueCollection baseProperties)
        {
            if (baseProperties.ContainsKey("m_ConstantColor"))
            {
                var vectorValues = baseProperties.GetIntegerArray("m_ConstantColor");
                ConstantColor = new Vector3(vectorValues[0], vectorValues[1], vectorValues[2]) / 255f;
            }

            if (baseProperties.ContainsKey("m_flConstantRadius"))
            {
                ConstantRadius = baseProperties.GetFloatProperty("m_flConstantRadius");
            }

            if (baseProperties.ContainsKey("m_flConstantLifespan"))
            {
                ConstantLifetime = baseProperties.GetFloatProperty("m_flConstantLifespan");
            }

            Init();
        }
Exemple #13
0
        public FadeAndKill(IKeyValueCollection keyValues)
        {
            if (keyValues.ContainsKey("m_flStartFadeInTime"))
            {
                startFadeInTime = keyValues.GetFloatProperty("m_flStartFadeInTime");
            }

            if (keyValues.ContainsKey("m_flEndFadeInTime"))
            {
                endFadeInTime = keyValues.GetFloatProperty("m_flEndFadeInTime");
            }

            if (keyValues.ContainsKey("m_flStartFadeOutTime"))
            {
                startFadeOutTime = keyValues.GetFloatProperty("m_flStartFadeOutTime");
            }

            if (keyValues.ContainsKey("m_flEndFadeOutTime"))
            {
                endFadeOutTime = keyValues.GetFloatProperty("m_flEndFadeOutTime");
            }

            if (keyValues.ContainsKey("m_flStartAlpha"))
            {
                startAlpha = keyValues.GetFloatProperty("m_flStartAlpha");
            }

            if (keyValues.ContainsKey("m_flEndAlpha"))
            {
                endAlpha = keyValues.GetFloatProperty("m_flEndAlpha");
            }
        }
Exemple #14
0
        public BasicMovement(IKeyValueCollection keyValues)
        {
            if (keyValues.ContainsKey("m_Gravity"))
            {
                var vectorValues = keyValues.GetArray <double>("m_Gravity");
                gravity = new Vector3((float)vectorValues[0], (float)vectorValues[1], (float)vectorValues[2]);
            }

            if (keyValues.ContainsKey("m_fDrag"))
            {
                drag = keyValues.GetFloatProperty("m_fDrag");
            }
        }
        public RingWave(IKeyValueCollection keyValues)
        {
            if (keyValues.ContainsKey("m_bEvenDistribution"))
            {
                evenDistribution = keyValues.GetProperty <bool>("m_bEvenDistribution");
            }

            if (keyValues.ContainsKey("m_flParticlesPerOrbit"))
            {
                particlesPerOrbit = keyValues.GetFloatProperty("m_flParticlesPerOrbit");
            }

            if (keyValues.ContainsKey("m_flInitialRadius"))
            {
                initialRadius = keyValues.GetFloatProperty("m_flInitialRadius");
            }

            if (keyValues.ContainsKey("m_flThickness"))
            {
                thickness = keyValues.GetFloatProperty("m_flThickness");
            }
        }
        public InterpolateRadius(IKeyValueCollection keyValues)
        {
            if (keyValues.ContainsKey("m_flStartTime"))
            {
                startTime = keyValues.GetFloatProperty("m_flStartTime");
            }

            if (keyValues.ContainsKey("m_flEndTime"))
            {
                endTime = keyValues.GetFloatProperty("m_flEndTime");
            }

            if (keyValues.ContainsKey("m_flStartScale"))
            {
                startScale = keyValues.GetFloatProperty("m_flStartScale");
            }

            if (keyValues.ContainsKey("m_flEndScale"))
            {
                endScale = keyValues.GetFloatProperty("m_flEndScale");
            }
        }
        public Particle(IKeyValueCollection baseProperties)
        {
            ParticleCount    = 0;
            Alpha            = 1.0f;
            AlphaAlternate   = 1.0f;
            Position         = Vector3.Zero;
            PositionPrevious = Vector3.Zero;
            Rotation         = Vector3.Zero;
            RotationSpeed    = Vector3.Zero;
            Velocity         = Vector3.Zero;
            ConstantRadius   = 5.0f;
            ConstantAlpha    = 1.0f;
            ConstantColor    = Vector3.One;
            ConstantLifetime = 1;
            TrailLength      = 1;
            Sequence         = 0;

            if (baseProperties.ContainsKey("m_ConstantColor"))
            {
                var vectorValues = baseProperties.GetIntegerArray("m_ConstantColor");
                ConstantColor = new Vector3(vectorValues[0], vectorValues[1], vectorValues[2]) / 255f;
            }

            if (baseProperties.ContainsKey("m_flConstantRadius"))
            {
                ConstantRadius = baseProperties.GetFloatProperty("m_flConstantRadius");
            }

            if (baseProperties.ContainsKey("m_flConstantLifespan"))
            {
                ConstantLifetime = baseProperties.GetFloatProperty("m_flConstantLifespan");
            }

            Color    = ConstantColor;
            Lifetime = ConstantLifetime;
            Radius   = ConstantRadius;
        }
Exemple #18
0
        public CreateWithinSphere(IKeyValueCollection keyValues)
        {
            random = new Random();

            if (keyValues.ContainsKey("m_fRadiusMin"))
            {
                radiusMin = keyValues.GetFloatProperty("m_fRadiusMin");
            }

            if (keyValues.ContainsKey("m_fRadiusMax"))
            {
                radiusMax = keyValues.GetFloatProperty("m_fRadiusMax");
            }

            if (keyValues.ContainsKey("m_fSpeedMin"))
            {
                speedMin = keyValues.GetFloatProperty("m_fSpeedMin");
            }

            if (keyValues.ContainsKey("m_fSpeedMax"))
            {
                speedMax = keyValues.GetFloatProperty("m_fSpeedMax");
            }

            if (keyValues.ContainsKey("m_LocalCoordinateSystemSpeedMin"))
            {
                var vectorValues = keyValues.GetArray <double>("m_LocalCoordinateSystemSpeedMin");
                localCoordinateSystemSpeedMin = new Vector3((float)vectorValues[0], (float)vectorValues[1], (float)vectorValues[2]);
            }

            if (keyValues.ContainsKey("m_LocalCoordinateSystemSpeedMax"))
            {
                var vectorValues = keyValues.GetArray <double>("m_LocalCoordinateSystemSpeedMax");
                localCoordinateSystemSpeedMax = new Vector3((float)vectorValues[0], (float)vectorValues[1], (float)vectorValues[2]);
            }
        }
        /// <summary>
        /// Construct an animation class from the animation description.
        /// </summary>
        private void ConstructFromDesc(
            IKeyValueCollection animDesc,
            IKeyValueCollection decodeKey,
            AnimDecoderType[] decoderArray,
            IKeyValueCollection[] segmentArray)
        {
            // Get animation properties
            Name = animDesc.GetProperty <string>("m_name");
            Fps  = animDesc.GetFloatProperty("fps");

            var pDataObject = animDesc.GetProperty <object>("m_pData");
            var pData       = pDataObject is NTROValue[] ntroArray
                ? ntroArray[0].ValueObject as IKeyValueCollection
                : pDataObject as IKeyValueCollection;
            var frameBlockArray = pData.GetArray("m_frameblockArray");

            FrameCount = (int)pData.GetIntegerProperty("m_nFrames");
            var frameArray = new Frame[FrameCount];

            // Figure out each frame
            for (var frame = 0; frame < FrameCount; frame++)
            {
                // Create new frame object
                frameArray[frame] = new Frame();

                // Read all frame blocks
                foreach (var frameBlock in frameBlockArray)
                {
                    var startFrame = frameBlock.GetIntegerProperty("m_nStartFrame");
                    var endFrame   = frameBlock.GetIntegerProperty("m_nEndFrame");

                    // Only consider blocks that actual contain info for this frame
                    if (frame >= startFrame && frame <= endFrame)
                    {
                        var segmentIndexArray = frameBlock.GetIntegerArray("m_segmentIndexArray");

                        foreach (var segmentIndex in segmentIndexArray)
                        {
                            var segment = segmentArray[segmentIndex];
                            ReadSegment(frame - startFrame, segment, decodeKey, decoderArray, ref frameArray[frame]);
                        }
                    }
                }
            }
            Frames = frameArray;
        }
Exemple #20
0
        public InitialVelocityNoise(IKeyValueCollection keyValues)
        {
            if (keyValues.ContainsKey("m_vecOutputMin"))
            {
                var vectorValues = keyValues.GetArray <double>("m_vecOutputMin");
                outputMin = new Vector3((float)vectorValues[0], (float)vectorValues[1], (float)vectorValues[2]);
            }

            if (keyValues.ContainsKey("m_vecOutputMax"))
            {
                var vectorValues = keyValues.GetArray <double>("m_vecOutputMax");
                outputMax = new Vector3((float)vectorValues[0], (float)vectorValues[1], (float)vectorValues[2]);
            }

            if (keyValues.ContainsKey("m_flNoiseScale"))
            {
                noiseScale = keyValues.GetFloatProperty("m_flNoiseScale");
            }
        }
        public OscillateScalar(IKeyValueCollection keyValues)
        {
            if (keyValues.ContainsKey("m_nField"))
            {
                outputField = (ParticleField)keyValues.GetIntegerProperty("m_nField");
            }

            if (keyValues.ContainsKey("m_RateMin"))
            {
                rateMin = keyValues.GetFloatProperty("m_RateMin");
            }

            if (keyValues.ContainsKey("m_RateMax"))
            {
                rateMax = keyValues.GetFloatProperty("m_RateMax");
            }

            if (keyValues.ContainsKey("m_FrequencyMin"))
            {
                frequencyMin = keyValues.GetFloatProperty("m_FrequencyMin");
            }

            if (keyValues.ContainsKey("m_FrequencyMax"))
            {
                frequencyMax = keyValues.GetFloatProperty("m_FrequencyMax");
            }

            if (keyValues.ContainsKey("m_flOscMult"))
            {
                oscillationMultiplier = keyValues.GetFloatProperty("m_flOscMult");
            }

            if (keyValues.ContainsKey("m_flOscAdd"))
            {
                oscillationOffset = keyValues.GetFloatProperty("m_flOscAdd");
            }

            if (keyValues.ContainsKey("m_bProportionalOp"))
            {
                proportional = keyValues.GetProperty <bool>("m_bProportionalOp");
            }

            random = new Random();
        }
Exemple #22
0
 public static Quaternion ToQuaternion(this IKeyValueCollection collection) => new Quaternion(
     collection.GetFloatProperty("0"),
     collection.GetFloatProperty("1"),
     collection.GetFloatProperty("2"),
     collection.GetFloatProperty("3"));
Exemple #23
0
 public static Vector4 ToVector4(this IKeyValueCollection collection) => new Vector4(
     collection.GetFloatProperty("0"),
     collection.GetFloatProperty("1"),
     collection.GetFloatProperty("2"),
     collection.GetFloatProperty("3"));