public RemapParticleCountToScalar(IKeyValueCollection keyValues) { if (keyValues.ContainsKey("m_nFieldOutput")) { fieldOutput = keyValues.GetIntegerProperty("m_nFieldOutput"); } if (keyValues.ContainsKey("m_nInputMin")) { inputMin = keyValues.GetIntegerProperty("m_nInputMin"); } if (keyValues.ContainsKey("m_nInputMax")) { inputMax = keyValues.GetIntegerProperty("m_nInputMax"); } if (keyValues.ContainsKey("m_flOutputMin")) { outputMin = keyValues.GetIntegerProperty("m_flOutputMin"); } if (keyValues.ContainsKey("m_flOutputMax")) { outputMax = keyValues.GetIntegerProperty("m_flOutputMax"); } if (keyValues.ContainsKey("m_bScaleInitialRange")) { scaleInitialRange = keyValues.GetProperty <bool>("m_bScaleInitialRange"); } }
public RandomAlpha(IKeyValueCollection keyValue) { random = new Random(); if (keyValue.ContainsKey("m_nAlphaMin")) { alphaMin = (int)keyValue.GetIntegerProperty("m_nAlphaMin"); } if (keyValue.ContainsKey("m_nAlphaMax")) { alphaMax = (int)keyValue.GetIntegerProperty("m_nAlphaMax"); } }
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 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"); } }
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 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"); } }
public RandomSequence(IKeyValueCollection keyValues) { if (keyValues.ContainsKey("m_nSequenceMin")) { sequenceMin = (int)keyValues.GetIntegerProperty("m_nSequenceMin"); } if (keyValues.ContainsKey("m_nSequenceMax")) { sequenceMax = (int)keyValues.GetIntegerProperty("m_nSequenceMax"); } if (keyValues.ContainsKey("m_bShuffle")) { shuffle = keyValues.GetProperty <bool>("m_bShuffle"); } }
public OffsetVectorToVector(IKeyValueCollection keyValues) { if (keyValues.ContainsKey("m_nFieldInput")) { inputField = (ParticleField)keyValues.GetIntegerProperty("m_nFieldInput"); } if (keyValues.ContainsKey("m_nFieldOutput")) { outputField = (ParticleField)keyValues.GetIntegerProperty("m_nFieldOutput"); } if (keyValues.ContainsKey("m_vecOutputMin")) { var vectorValues = keyValues.GetArray <double>("m_vecOutputMin"); offsetMin = new Vector3((float)vectorValues[0], (float)vectorValues[1], (float)vectorValues[2]); } if (keyValues.ContainsKey("m_vecOutputMax")) { var vectorValues = keyValues.GetArray <double>("m_vecOutputMax"); offsetMax = new Vector3((float)vectorValues[0], (float)vectorValues[1], (float)vectorValues[2]); } }
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(); }
/// <summary> /// Read segment. /// </summary> private void ReadSegment(long frame, IKeyValueCollection segment, IKeyValueCollection decodeKey, AnimDecoderType[] decoderArray, ref Frame outFrame) { // Clamp the frame number to be between 0 and the maximum frame frame = frame < 0 ? 0 : frame; frame = frame >= FrameCount ? FrameCount - 1 : frame; var localChannel = segment.GetIntegerProperty("m_nLocalChannel"); var dataChannel = decodeKey.GetArray("m_dataChannelArray")[localChannel]; var boneNames = dataChannel.GetArray <string>("m_szElementNameArray"); var channelAttribute = dataChannel.GetProperty <string>("m_szVariableName"); // Read container var container = segment.GetArray <byte>("m_container"); using (var containerReader = new BinaryReader(new MemoryStream(container))) { var elementIndexArray = dataChannel.GetIntegerArray("m_nElementIndexArray"); var elementBones = new int[decodeKey.GetProperty <int>("m_nChannelElements")]; for (var i = 0; i < elementIndexArray.Length; i++) { elementBones[elementIndexArray[i]] = i; } // Read header var decoder = decoderArray[containerReader.ReadInt16()]; var cardinality = containerReader.ReadInt16(); var numBones = containerReader.ReadInt16(); var totalLength = containerReader.ReadInt16(); // Read bone list var elements = new List <int>(); for (var i = 0; i < numBones; i++) { elements.Add(containerReader.ReadInt16()); } // Skip data to find the data for the current frame. // Structure is just | Bone 0 - Frame 0 | Bone 1 - Frame 0 | Bone 0 - Frame 1 | Bone 1 - Frame 1| if (containerReader.BaseStream.Position + (decoder.Size() * frame * numBones) < containerReader.BaseStream.Length) { containerReader.BaseStream.Position += decoder.Size() * frame * numBones; } // Read animation data for all bones for (var element = 0; element < numBones; element++) { // Get the bone we are reading for var bone = elementBones[elements[element]]; // Look at the decoder to see what to read switch (decoder) { case AnimDecoderType.CCompressedStaticFullVector3: case AnimDecoderType.CCompressedFullVector3: case AnimDecoderType.CCompressedDeltaVector3: outFrame.SetAttribute(boneNames[bone], channelAttribute, new Vector3( containerReader.ReadSingle(), containerReader.ReadSingle(), containerReader.ReadSingle())); break; case AnimDecoderType.CCompressedAnimVector3: case AnimDecoderType.CCompressedStaticVector3: outFrame.SetAttribute(boneNames[bone], channelAttribute, new Vector3( ReadHalfFloat(containerReader), ReadHalfFloat(containerReader), ReadHalfFloat(containerReader))); break; case AnimDecoderType.CCompressedAnimQuaternion: case AnimDecoderType.CCompressedFullQuaternion: case AnimDecoderType.CCompressedStaticQuaternion: outFrame.SetAttribute(boneNames[bone], channelAttribute, ReadQuaternion(containerReader)); break; #if DEBUG default: if (channelAttribute != "data") { Console.WriteLine($"Unhandled animation bone decoder type '{decoder}'"); } break; #endif } } } }