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 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 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 RandomTrailLength(IKeyValueCollection keyValues) { if (keyValues.ContainsKey("m_flMinLength")) { minLength = keyValues.GetFloatProperty("m_flMinLength"); } if (keyValues.ContainsKey("m_flMaxLength")) { maxLength = keyValues.GetFloatProperty("m_flMaxLength"); } }
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 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"); } }
public PositionOffset(IKeyValueCollection keyValues) { if (keyValues.ContainsKey("m_OffsetMin")) { var vectorValues = keyValues.GetArray <double>("m_OffsetMin"); offsetMin = new Vector3((float)vectorValues[0], (float)vectorValues[1], (float)vectorValues[2]); } if (keyValues.ContainsKey("m_OffsetMax")) { var vectorValues = keyValues.GetArray <double>("m_OffsetMax"); offsetMax = new Vector3((float)vectorValues[0], (float)vectorValues[1], (float)vectorValues[2]); } }
private static IEnumerable <IKeyValueCollection> SubNodes(IKeyValueCollection node) { if (node.ContainsKey("vecChildren")) { return(node.GetArray("vecChildren")); } if (node.ContainsKey("child")) { return(new[] { node.GetSubCollection("child") }); } return(Array.Empty <IKeyValueCollection>()); }
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"); } }
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"); } }
/// <summary> /// Initializes a new instance of the <see cref="Skeleton"/> class. /// </summary> public static Skeleton FromModelData(IKeyValueCollection modelData, int meshIndex) { // Check if there is any skeleton data present at all if (!modelData.ContainsKey("m_modelSkeleton")) { Console.WriteLine("No skeleton data found."); } // Get the remap table and invert it for our construction method var remapTable = modelData.GetIntegerArray("m_remappingTable"); var remapTableStarts = modelData.GetIntegerArray("m_remappingTableStarts"); var start = (int)remapTableStarts[meshIndex]; var end = meshIndex < remapTableStarts.Length - 1 ? (int)remapTableStarts[meshIndex + 1] : remapTable.Length; var invMapTable = remapTable.Skip(start).Take(end - start) .Select((mapping, index) => (mapping, index)) .ToLookup(mi => mi.mapping, mi => mi.index); // Construct the armature from the skeleton KV return(new Skeleton(modelData.GetSubCollection("m_modelSkeleton"), invMapTable)); }
public RandomColor(IKeyValueCollection keyValues) { random = new Random(); if (keyValues.ContainsKey("m_ColorMin")) { var vectorValues = keyValues.GetArray <long>("m_ColorMin"); colorMin = new Vector3(vectorValues[0], vectorValues[1], vectorValues[2]) / 255f; } if (keyValues.ContainsKey("m_ColorMax")) { var vectorValues = keyValues.GetArray <long>("m_ColorMax"); colorMax = new Vector3(vectorValues[0], vectorValues[1], vectorValues[2]) / 255f; } }
/// <summary> /// Initializes a new instance of the <see cref="Skeleton"/> class. /// </summary> public Skeleton(IKeyValueCollection modelData) { // Check if there is any skeleton data present at all if (!modelData.ContainsKey("m_modelSkeleton")) { Console.WriteLine("No skeleton data found."); } // Get the remap table and invert it for our construction method var remapTable = modelData.GetIntegerArray("m_remappingTable"); var start = 0; var end = remapTable.Length; var remapTableStarts = modelData.GetIntegerArray("m_remappingTableStarts"); // we only use lod 1 if (remapTableStarts.Length > 1) { start = (int)remapTableStarts[0]; end = (int)remapTableStarts[1]; } var invMapTable = remapTable.Skip(start).Take(end - start) .Select((mapping, index) => (mapping, index)) .ToLookup(mi => mi.mapping, mi => mi.index); if (invMapTable.Any()) { AnimationTextureSize = invMapTable.Select(g => g.Max()).Max() + 1; } // Construct the armature from the skeleton KV ConstructFromNTRO(modelData.GetSubCollection("m_modelSkeleton"), invMapTable); }
public FadeOutSimple(IKeyValueCollection keyValues) { if (keyValues.ContainsKey("m_flFadeOutTime")) { fadeOutTime = keyValues.GetFloatProperty("m_flFadeOutTime"); } }
/// <summary> /// Initializes a new instance of the <see cref="Skeleton"/> class. /// </summary> public Skeleton(IKeyValueCollection modelData) { Bones = new Bone[0]; Roots = new List <Bone>(); // Check if there is any skeleton data present at all if (!modelData.ContainsKey("m_modelSkeleton")) { Console.WriteLine("No skeleton data found."); } // Get the remap table and invert it for our construction method var remapTable = modelData.GetIntegerArray("m_remappingTable"); var invMapTable = new Dictionary <long, int>(); for (var i = 0; i < remapTable.Length; i++) { if (!invMapTable.ContainsKey(remapTable[i])) { invMapTable.Add(remapTable[i], i); } } // Construct the armature from the skeleton KV ConstructFromNTRO(modelData.GetSubCollection("m_modelSkeleton"), invMapTable); }
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 InitialVelocityNoise(IKeyValueCollection keyValues) { if (keyValues.ContainsKey("m_vecOutputMin")) { outputMin = keyValues.GetVectorProvider("m_vecOutputMin"); } if (keyValues.ContainsKey("m_vecOutputMax")) { outputMax = keyValues.GetVectorProvider("m_vecOutputMax"); } if (keyValues.ContainsKey("m_flNoiseScale")) { noiseScale = keyValues.GetNumberProvider("m_flNoiseScale"); } }
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"); } }
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 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(); }
public ContinuousEmitter(IKeyValueCollection baseProperties, IKeyValueCollection keyValues) { this.baseProperties = baseProperties; if (keyValues.ContainsKey("m_flEmissionDuration")) { emissionDuration = keyValues.GetNumberProvider("m_flEmissionDuration"); } if (keyValues.ContainsKey("m_flStartTime")) { startTime = keyValues.GetNumberProvider("m_flStartTime"); } if (keyValues.ContainsKey("m_flEmitRate")) { emitRate = keyValues.GetNumberProvider("m_flEmitRate"); emitInterval = 1.0f / (float)emitRate.NextNumber(); } }
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 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"); } }
public static bool IsCompressedNormalTangent(IKeyValueCollection drawCall) { if (drawCall.ContainsKey("m_bUseCompressedNormalTangent")) { return(drawCall.GetProperty <bool>("m_bUseCompressedNormalTangent")); } if (!drawCall.ContainsKey("m_nFlags")) { return(false); } var flags = drawCall.GetProperty <object>("m_nFlags"); return(flags switch { string flagsString => flagsString.Contains("MESH_DRAW_FLAGS_USE_COMPRESSED_NORMAL_TANGENT", StringComparison.InvariantCulture), long flagsLong => // TODO: enum (flagsLong & 2) == 2, _ => false });
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; }
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]); } }