private void AddLineSegment(nQuad q, Vector2 start, Vector2 end, float w1, float w2) { var p = new nProp(q); p.Visible = true; p.Listen(_cam, nInputEvent.ENTER, delegate (nPropEvent e) { e.Prop.Color = new Color(1.0f, 1.0f, 0.0f, 0.3f); }); p.Listen(_cam, nInputEvent.EXIT, delegate (nPropEvent e) { e.Prop.Color = new Color(1.0f, 1.0f, 1.0f, 1.0f); }); nStrip.PopulateLineSegment(p.Vertices, start, end, w1, w2); p.PushVertexUpdate(); }
/** Render this leaf and add it to the set of items */ public void Render(List<nProp> elements, bool force) { if (_dead) return; if (!Growing()) return; if ((Display == null) || (force)) { if (Display != null) { Display.Visible = false; Display = null; } var quad = new nQuad("leaf", new Vector2(1.0f, 1.0f)); quad.Texture = Texture; Display = new nProp(quad); Display.Visible = true; Display.Vertices = new Vector3[4] { new Vector3(1.0f, 1.0f, 0f), new Vector3(1.0f, 0f, 0f), new Vector3(0f, 1.0f, 0f), new Vector3(0f, 0f, 0f) }; Display.PushVertexUpdate(); Display.Rotation = Parent.FullAngle + 90f + Angle; Display.Depth = 2.0f; Display.Color = new Color(1f, 1f, 1f, 0.5f); var sSize = 0.05f; var r = new System.Random(); Scatter = new Vector2(sSize * (float)r.NextDouble(), sSize * (float)r.NextDouble()); } var angle = Parent.FullAngle; var o = Offset > Parent.Length ? Parent.Length : Offset; if (o < 0f) o = 0f; float x = (float) Math.Sin(angle * Math.PI / 180) * (Parent.Length - o); float y = (float) Math.Cos(angle * Math.PI / 180) * (Parent.Length - o); var start = Parent.Base + new Vector2(x, y) + Scatter; start[1] += MagicOffset; Display.Scale = new Vector2(Size, Size); Display.Position = start; //var offset = new Vector2(y, -x); //offset.Normalize(); //offset = offset * Size; //var end = start + offset; //nStrip.PopulateLineSegment(Display.Vertices, start, end, Size, Size); //Display.PushVertexUpdate(); }