public override void Draw(IBaseRender render) { if (particleSystem != null && particleSystem.particles != null) { if (puntos == null || particleSystem.particles.Length != puntos.Length) { CrearVectores(); } ActualizarVectores(render); if (ParticleSystem.UseLighting == false) { render.TurnLightingOff(); } if (ParticleSystem.GlobalPosition) { render.DrawTriangles(Matrix4.Identity, puntos, (int)cantPuntos * 3 / 2, vertices, colores, renderMode); } else { render.DrawTriangles(Entity.Transformation.GlobalMatrix, puntos, (int)cantPuntos * 3 / 2, vertices, colores, renderMode); } if (ParticleSystem.UseLighting == false) { render.TurnLightingOn(); } } }
private void ActualizarVectores(IBaseRender render) { uint offsetPuntos = 0; Matrix4 camara = render.GetCamara(); for (int i = 0; i < particleSystem.particles.Length; i++) { Particle part = particleSystem.particles[i]; if (part.life > 0) { float halfSize = part.size / 2.0f; vertices[offsetPuntos] = new Vector3(-halfSize + part.position.X, -halfSize + part.position.Y, part.position.Z); vertices[offsetPuntos + 1] = new Vector3(halfSize + part.position.X, -halfSize + part.position.Y, part.position.Z); vertices[offsetPuntos + 2] = new Vector3(halfSize + part.position.X, halfSize + part.position.Y, part.position.Z); vertices[offsetPuntos + 3] = new Vector3(-halfSize + part.position.X, halfSize + part.position.Y, part.position.Z); colores[offsetPuntos] = colores[offsetPuntos + 1] = colores[offsetPuntos + 2] = colores[offsetPuntos + 3] = part.color; offsetPuntos += 4; } } cantPuntos = offsetPuntos; }
public void Render(IBaseRender render) { List <LightSource> lights = new List <LightSource>(); foreach (LightSource light in Component.AllComponentsOfType(typeof(LightSource))) { if (light.Enabled) { lights.Add(light); } } if (lights.Count < 8) { render.ResetAllLights(); foreach (LightSource light in lights) { render.AddLight(light); } foreach (Render comp in Component.AllComponentsOfType(typeof(Render))) { if (comp.Enabled) { comp.Draw(render); } } } else { foreach (Render comp in Component.AllComponentsOfType(typeof(Render))) { if (comp.Enabled) { render.ResetAllLights(); lucesOrdenar = new List <LuzOrdenable>(lights.Count); Vector3 centroLuces = comp.Entity.Transformation.GlobalTranslation; foreach (LightSource light in lights) { lucesOrdenar.Add(new LuzOrdenable(light, (light.Entity.Transformation.GlobalTranslation - centroLuces).LengthSquared)); } lucesOrdenar.Sort(OrdenarLucesPorDistancia); for (int k = 0; k < 8; k++) { render.AddLight(lucesOrdenar[k].light); } comp.Draw(render); } } } }
public override void DrawHelper(IBaseRender render) { if (RenderInEditor) { Mesh cube = (Mesh)Resource.FindResource(typeof(Mesh), "Cube"); Matrix4 mat = Entity.Transformation.GlobalMatrix; mat = Matrix4.Scale(size) * mat; render.Draw(cube, mat, RenderMode.Lines, new OpenTK.Graphics.Color4(0.0f, 1.0f, 0.0f, 1.0f)); } }
public override void Draw(IBaseRender render) { if (Entity != null && Mesh != null) { if (texture != null) { render.Draw(mesh, Entity.Transformation.GlobalMatrix, renderMode, texture); } else { render.Draw(mesh, Entity.Transformation.GlobalMatrix, renderMode); } } }
public void DrawHelper(IBaseRender render) { if (mesh == null) { mesh = (Mesh)Resource.FindResource(typeof(Mesh), "Light"); } if (Entity != null && mesh != null) { Matrix4 mat = Entity.Transformation.GlobalMatrix; Vector3 scale = Entity.Transformation.GlobalScale; mat = Matrix4.Scale(1.0f / scale.X, 1.0f / scale.Y, 1.0f / scale.Z) * mat; render.Draw(mesh, mat, RenderMode.Normal, new Color4(1.0f, 1.0f, 0.0f, 0.0f)); } }
public virtual void DrawHelper(IBaseRender render) { }
public virtual void Draw(IBaseRender render) { }