public ParticleRenderer(ParticleSystem particleSystem, VrfGuiContext vrfGuiContext) { this.particleSystem = particleSystem; childParticleRenderers = new List <ParticleRenderer>(); this.vrfGuiContext = vrfGuiContext; particles = new List <Particle>(); SetupEmitters(particleSystem.GetData(), particleSystem.GetEmitters()); SetupInitializers(particleSystem.GetInitializers()); SetupOperators(particleSystem.GetOperators()); SetupRenderers(particleSystem.GetRenderers()); SetupChildParticles(particleSystem.GetChildParticleNames(true)); Start(); }
// TODO: Passing in position here was for testing, do it properly public ParticleRenderer(ParticleSystem particleSystem, VrfGuiContext vrfGuiContext, Vector3 pos = default) { childParticleRenderers = new List <ParticleRenderer>(); this.vrfGuiContext = vrfGuiContext; particles = new List <Particle>(); systemRenderState = new ParticleSystemRenderState(); systemRenderState.SetControlPoint(0, pos); SetupEmitters(particleSystem.GetData(), particleSystem.GetEmitters()); SetupInitializers(particleSystem.GetInitializers()); SetupOperators(particleSystem.GetOperators()); SetupRenderers(particleSystem.GetRenderers()); SetupChildParticles(particleSystem.GetChildParticleNames(true)); Start(); }
public ParticleGrid(float cellWidth, int gridWidthInCells, VrfGuiContext guiContext) { BoundingBox = new AABB( new Vector3(-cellWidth * 0.5f * gridWidthInCells, -cellWidth * 0.5f * gridWidthInCells, 0), new Vector3(cellWidth * 0.5f * gridWidthInCells, cellWidth * 0.5f * gridWidthInCells, 0)); var vertices = GenerateGridVertexBuffer(cellWidth, gridWidthInCells); vertexCount = vertices.Length / 3; // Number of vertices in our buffer const int stride = sizeof(float) * 7; shader = guiContext.ShaderLoader.LoadShader("vrf.grid", new Dictionary <string, bool>()); GL.UseProgram(shader.Program); // Create and bind VAO vao = GL.GenVertexArray(); GL.BindVertexArray(vao); var vbo = GL.GenBuffer(); GL.BindBuffer(BufferTarget.ArrayBuffer, vbo); GL.BufferData(BufferTarget.ArrayBuffer, vertices.Length * sizeof(float), vertices, BufferUsageHint.StaticDraw); GL.EnableVertexAttribArray(0); var positionAttributeLocation = GL.GetAttribLocation(shader.Program, "aVertexPosition"); GL.EnableVertexAttribArray(positionAttributeLocation); GL.VertexAttribPointer(positionAttributeLocation, 3, VertexAttribPointerType.Float, false, stride, 0); var colorAttributeLocation = GL.GetAttribLocation(shader.Program, "aVertexColor"); GL.EnableVertexAttribArray(colorAttributeLocation); GL.VertexAttribPointer(colorAttributeLocation, 4, VertexAttribPointerType.Float, false, stride, sizeof(float) * 3); GL.BindVertexArray(0); // Unbind VAO GL.UseProgram(0); }
public static bool TryCreateRender(string name, IKeyValueCollection rendererInfo, VrfGuiContext vrfGuiContext, out IParticleRenderer renderer) { if (RendererDictionary.TryGetValue(name, out var factory)) { renderer = factory(rendererInfo, vrfGuiContext); return(true); } renderer = default; return(false); }