コード例 #1
0
ファイル: DrawHelpers.cs プロジェクト: weimingtom/Sakura
 public void DrawCoordinateSystem2D(Matrix3 mat, DrawHelpers.ArrowParams ap = null)
 {
     if (ap == null)
     {
         ap = new DrawHelpers.ArrowParams(1f);
     }
     this.ShaderPush();
     this.ImmBegin((DrawMode)3, 18u);
     this.SetColor(Colors.Red);
     this.DrawArrow(mat.Z.Xy, mat.Z.Xy + mat.X.Xy, ap);
     this.SetColor(Colors.Green);
     this.DrawArrow(mat.Z.Xy, mat.Z.Xy + mat.Y.Xy, ap);
     this.ImmEnd();
     this.ShaderPop();
 }
コード例 #2
0
ファイル: DrawHelpers.cs プロジェクト: weimingtom/Sakura
        public void DrawArrow(Vector2 start_point, Vector2 end_point, DrawHelpers.ArrowParams ap)
        {
            Vector2 vector  = (end_point - start_point).Normalize();
            Vector2 vector2 = Math.Perp(vector);

            start_point   += vector2 * ap.Offset;
            end_point     += vector2 * ap.Offset;
            ap.BodyRadius *= ap.Scale;
            ap.HeadRadius *= ap.Scale;
            ap.HeadLen    *= ap.Scale;
            float num  = ap.HeadRadius;
            float num2 = ap.HeadRadius;
            float num3 = ap.BodyRadius;
            float num4 = ap.BodyRadius;

            if ((ap.HalfMask & 1u) == 0u)
            {
                num2 = 0f;
                num4 = 0f;
            }
            if ((ap.HalfMask & 2u) == 0u)
            {
                num  = 0f;
                num3 = 0f;
            }
            this.ShaderPush();
            bool immActive = this.m_imm.ImmActive;

            if (ap.BodyRadius == 0f && !immActive)
            {
                this.ImmBegin((DrawMode)1, 2u);
                this.ImmVertex(start_point);
                this.ImmVertex(end_point);
                this.ImmEnd();
            }
            if (!immActive)
            {
                this.ImmBegin((DrawMode)3, 9u);
            }
            if (ap.BodyRadius != 0f)
            {
                Vector2 pos  = start_point + num3 * vector2;
                Vector2 pos2 = start_point - num4 * vector2;
                Vector2 pos3 = end_point - vector * ap.HeadLen + num3 * vector2;
                Vector2 pos4 = end_point - vector * ap.HeadLen - num4 * vector2;
                this.ImmVertex(pos);
                this.ImmVertex(pos2);
                this.ImmVertex(pos3);
                this.ImmVertex(pos2);
                this.ImmVertex(pos4);
                this.ImmVertex(pos3);
            }
            this.ImmVertex(end_point - vector * ap.HeadLen - num2 * vector2);
            this.ImmVertex(end_point);
            this.ImmVertex(end_point - vector * ap.HeadLen + num * vector2);
            if (!immActive)
            {
                this.ImmEnd();
            }
            this.ShaderPop();
        }