public override void Draw(ref Particle particle, float globaltime, NodeReference reference, ResourceManager res, Billboards billboards, ref Matrix4 transform, float sparam) { var time = particle.TimeAlive / particle.LifeSpan; var node_tr = GetTranslation(reference, transform, sparam, time); var p = node_tr.Transform(particle.Position); Texture2D tex; Vector2 tl, tr, bl, br; HandleTexture(res, globaltime, sparam, ref particle, out tex, out tl, out tr, out bl, out br); var c = Color.GetValue(sparam, time); var a = Alpha.GetValue(sparam, time); var p2 = node_tr.Transform(particle.Position + particle.Normal); //var n = (p - p2).Normalized(); var n = Vector3.UnitZ; billboards.DrawPerspective( tex, p, new Vector2(Width.GetValue(sparam, time), Height.GetValue(sparam, time)), new Color4(c, a), tl, tr, bl, br, n, Rotate == null ? 0f : Rotate.GetValue(sparam, time), SortLayers.OBJECT, BlendInfo ); }
public override void Draw(ref Particle particle, int pidx, float lasttime, float globaltime, NodeReference reference, ResourceManager res, ParticleEffectInstance instance, ref Matrix4x4 transform, float sparam) { var time = particle.TimeAlive / particle.LifeSpan; var node_tr = GetAttachment(reference, transform); TextureHandler.Update(Texture, res); var c = Color.GetValue(sparam, time); var a = Alpha.GetValue(sparam, time); var q = particle.Orientation * Transform.GetDeltaRotation(sparam, lasttime, globaltime); particle.Orientation = q; var mat = Matrix4x4.CreateFromQuaternion(q); var p = Vector3.Transform(particle.Position, transform); var p2 = Vector3.Transform(particle.Position + particle.Normal, transform); var n = (p - p2).Normalized(); instance.Pool.DrawPerspective( particle.Instance, this, TextureHandler, Vector3.Transform(particle.Position, transform), mat, new Vector2(Size.GetValue(sparam, time)), new Color4(c, a), GetFrame(globaltime, sparam, ref particle), n, Rotate == null ? 0f : MathHelper.DegreesToRadians(Rotate.GetValue(sparam, time)), reference.Index ); if (DrawNormals) { Debug.DrawLine(p - (n * 100), p + (n * 100)); } }
public override void Draw(ref Particle particle, float lasttime, float globaltime, NodeReference reference, ResourceManager res, Billboards billboards, ref Matrix4 transform, float sparam) { var time = particle.TimeAlive / particle.LifeSpan; var node_tr = GetAttachment(reference, transform); var src_pos = particle.Position; var l = Length.GetValue(sparam, time); var w = Width.GetValue(sparam, time); var sc = Scale.GetValue(sparam, time); if (!CenterOnPos) { var nd = particle.Normal.Normalized(); src_pos += nd * (l * sc * 0.25f); } var p = node_tr.Transform(src_pos); Texture2D tex; Vector2 tl, tr, bl, br; HandleTexture(res, globaltime, sparam, ref particle, out tex, out tl, out tr, out bl, out br); var c = Color.GetValue(sparam, time); var a = Alpha.GetValue(sparam, time); var p2 = node_tr.Transform(src_pos + (particle.Normal * 20)); //var n = (p2 - p).Normalized(); var n = (transform * new Vector4(particle.Normal.Normalized(), 0)).Xyz.Normalized(); billboards.DrawRectAppearance( tex, p, new Vector2(l, w) * sc * 0.5f, new Color4(c, a), tl, tr, bl, br, n, Rotate == null ? 0f : MathHelper.DegreesToRadians(Rotate.GetValue(sparam, time)), SortLayers.OBJECT, BlendInfo ); if (DrawNormals) { Debug.DrawLine(p - (n * 12), p + (n * 12)); } }
public override void Draw(ref Particle particle, int pidx, float lasttime, float globaltime, NodeReference reference, ResourceManager res, ParticleEffectInstance instance, ref Matrix4x4 transform, float sparam) { var time = particle.TimeAlive / particle.LifeSpan; var node_tr = GetAttachment(reference, transform); var src_pos = particle.Position; var l = Length.GetValue(sparam, time); var w = Width.GetValue(sparam, time); var sc = Scale.GetValue(sparam, time); if (!CenterOnPos) { var nd = particle.Normal.Normalized(); src_pos += nd * (l * sc * 0.25f); } var p = Vector3.Transform(src_pos, node_tr); Texture2D tex; Vector2 tl, tr, bl, br; HandleTexture(res, globaltime, sparam, ref particle, out tex, out tl, out tr, out bl, out br); var c = Color.GetValue(sparam, time); var a = Alpha.GetValue(sparam, time); var p2 = Vector3.Transform(src_pos + (particle.Normal * 20), node_tr); //var n = (p2 - p).Normalized(); var n = Vector3.TransformNormal(particle.Normal, transform).Normalized(); instance.Pool.DrawRect( particle.Instance, this, tex, p, new Vector2(l, w) * sc * 0.5f, new Color4(c, a), tl, tr, bl, br, n, Rotate == null ? 0f : MathHelper.DegreesToRadians(Rotate.GetValue(sparam, time)) ); if (DrawNormals) { Debug.DrawLine(p - (n * 12), p + (n * 12)); } }
public override void Draw(ref Particle particle, int pidx, float lasttime, float globaltime, NodeReference reference, ResourceManager res, ParticleEffectInstance instance, ref Matrix4 transform, float sparam) { var time = particle.TimeAlive / particle.LifeSpan; var node_tr = GetAttachment(reference, transform); Texture2D tex; Vector2 tl, tr, bl, br; HandleTexture(res, globaltime, sparam, ref particle, out tex, out tl, out tr, out bl, out br); var c = Color.GetValue(sparam, time); var a = Alpha.GetValue(sparam, time); var q = particle.Orientation * Transform.GetDeltaRotation(sparam, lasttime, globaltime); particle.Orientation = q; var mat = Matrix4.CreateFromQuaternion(q); //TODO: why doesn't this work? //var n = (transform * new Vector4(particle.Normal.Normalized(), 0)).Xyz.Normalized(); var p = VectorMath.Transform(particle.Position, transform); var p2 = VectorMath.Transform(particle.Position + particle.Normal, transform); var n = (p - p2).Normalized(); instance.Pool.DrawPerspective( particle.Instance, this, tex, VectorMath.Transform(particle.Position, transform), mat, new Vector2(Size.GetValue(sparam, time)), new Color4(c, a), tl, tr, bl, br, n, Rotate == null ? 0f : MathHelper.DegreesToRadians(Rotate.GetValue(sparam, time)) ); if (DrawNormals) { Debug.DrawLine(p - (n * 100), p + (n * 100)); } }
public override void Draw(ref Particle particle, float lasttime, float globaltime, NodeReference reference, ResourceManager res, Billboards billboards, ref Matrix4 transform, float sparam) { var time = particle.TimeAlive / particle.LifeSpan; var node_tr = GetAttachment(reference, transform); Texture2D tex; Vector2 tl, tr, bl, br; HandleTexture(res, globaltime, sparam, ref particle, out tex, out tl, out tr, out bl, out br); var c = Color.GetValue(sparam, time); var a = Alpha.GetValue(sparam, time); var q = particle.Orientation * Transform.GetDeltaRotation(sparam, lasttime, globaltime); particle.Orientation = q; var mat = Matrix4.CreateFromQuaternion(q); var n = (transform * new Vector4(particle.Normal.Normalized(), 0)).Xyz.Normalized(); billboards.DrawPerspective( tex, VectorMath.Transform(particle.Position, transform), mat, new Vector2(Size.GetValue(sparam, time)), new Color4(c, a), tl, tr, bl, br, n, Rotate == null ? 0f : MathHelper.DegreesToRadians(Rotate.GetValue(sparam, time)), SortLayers.OBJECT, BlendInfo ); if (DrawNormals) { //Debug.DrawLine(p - (n * 100), p + (n * 100)); } }
public override void Draw(ref Particle particle, float globaltime, ParticleEffect effect, ResourceManager res, Billboards billboards, ref Matrix4 transform, float sparam) { var time = particle.TimeAlive / particle.LifeSpan; var node_tr = GetTranslation(effect, transform, sparam, time); var p = node_tr.Transform(particle.Position); Texture2D tex; Vector2 tl, tr, bl, br; HandleTexture(res, globaltime, sparam, ref particle, out tex, out tl, out tr, out bl, out br); var c = Color.GetValue(sparam, time); var a = Alpha.GetValue(sparam, time); var p2 = node_tr.Transform(particle.Position + particle.Normal); var n = (p - p2).Normalized(); billboards.DrawPerspective( tex, p, new Vector2(Size.GetValue(sparam, time)), new Color4(c, a), tl, tr, bl, br, n, Rotate == null ? 0f : Rotate.GetValue(sparam, time), SortLayers.OBJECT, BlendInfo ); if (DrawNormals) { Debug.DrawLine(p - (n * 8), p + (n * 8)); } }
public override void Draw(ref Particle particle, float globaltime, NodeReference reference, ResourceManager res, Billboards billboards, ref Matrix4 transform, float sparam) { var time = particle.TimeAlive / particle.LifeSpan; var node_tr = GetTranslation(reference, transform, sparam, time); var src_pos = particle.Position; var l = Length.GetValue(sparam, time); var w = Width.GetValue(sparam, time); var sc = Scale.GetValue(sparam, time); if (!CenterOnPos) { var nd = particle.Normal.Normalized(); src_pos += nd * (l * sc * 0.25f); } var p = node_tr.Transform(src_pos); Texture2D tex; Vector2 tl, tr, bl, br; HandleTexture(res, globaltime, sparam, ref particle, out tex, out tl, out tr, out bl, out br); var c = Color.GetValue(sparam, time); var a = Alpha.GetValue(sparam, time); var p2 = node_tr.Transform(src_pos + (particle.Normal * 20)); var n = (p2 - p).Normalized(); billboards.DrawRectAppearance( tex, p, new Vector2(l, w) * sc * 0.5f, new Color4(c, a), tl, tr, bl, br, n, Rotate == null ? 0f : Rotate.GetValue(sparam, time), SortLayers.OBJECT, BlendInfo ); /*var p1_proj = Project(billboards, p); * var p2_proj = Project(billboards, p2); * * var px1 = new Vector2( * (p1_proj.X + 1) / 2 * 1024, * (1 - p1_proj.Y) / 2 * 768); * var px2 = new Vector2( * (p2_proj.X + 1) / 2 * 1024, * (1 - p2_proj.Y) / 2 * 1024 * ); * * var angle = (float)Math.Atan2(px2.Y - px1.Y, px2.X - px1.X);*/ /*var src_pos2 = src_pos + (particle.Normal * 20); * var angle = (float)Math.Atan2(src_pos2.Y - src_pos.Y, src_pos2.Z - src_pos.Z); * var angle_deg = MathHelper.RadiansToDegrees(angle); * billboards.Draw( * tex, * p, * new Vector2(l, w) * sc * 0.5f, * new Color4(c, a), * tl, * tr, * bl, * br, * angle, //Rotate == null ? 0f : Rotate.GetValue(sparam, time), * SortLayers.OBJECT, * BlendInfo * );*/ if (DrawNormals) { Debug.DrawLine(p - (n * 8), p + (n * 8)); } }