コード例 #1
0
        public static void AddArrow(this DynamicPrimitive dynamicPrimitive, Vector3 start, Vector3 end, Color color, float lineWidth)
        {
            const float Ratio = 0.2f;
            var         mid   = Vector3.Lerp(end, start, Ratio);
            var         head  = (end - start).Length() * Ratio;

            dynamicPrimitive.AddLine(start, mid, null, color, lineWidth);
            dynamicPrimitive.AddSolidCone(Vector3.Zero, head, head * 0.5f, 24,
                                          MatrixHelper.CreateRotation(Vector3.Up, Vector3.Normalize(end - start)) *
                                          Matrix.CreateTranslation(mid), color);
        }
コード例 #2
0
        public static void AddFrustum(this DynamicPrimitive dynamicPrimitive, BoundingFrustum boundingFrustum, Matrix?world, Color color, float lineWidth)
        {
            Vector3[] corners = boundingFrustum.GetCorners();

            // near plane
            dynamicPrimitive.AddLine(corners[0], corners[1], color, lineWidth);
            dynamicPrimitive.AddLine(corners[1], corners[2], color, lineWidth);
            dynamicPrimitive.AddLine(corners[2], corners[3], color, lineWidth);
            dynamicPrimitive.AddLine(corners[3], corners[0], color, lineWidth);

            // connections
            dynamicPrimitive.AddLine(corners[0], corners[4], color, lineWidth);
            dynamicPrimitive.AddLine(corners[1], corners[5], color, lineWidth);
            dynamicPrimitive.AddLine(corners[2], corners[6], color, lineWidth);
            dynamicPrimitive.AddLine(corners[3], corners[7], color, lineWidth);

            // far plane
            dynamicPrimitive.AddLine(corners[4], corners[5], color, lineWidth);
            dynamicPrimitive.AddLine(corners[5], corners[6], color, lineWidth);
            dynamicPrimitive.AddLine(corners[6], corners[7], color, lineWidth);
            dynamicPrimitive.AddLine(corners[7], corners[4], color, lineWidth);
        }
コード例 #3
0
 public static void AddLineSegment(this DynamicPrimitive dynamicPrimitive, LineSegment line, float z, Matrix?world, Color color, float lineWidth)
 {
     dynamicPrimitive.AddLine(new Vector3(line.Start, z), new Vector3(line.End, z), world, color, lineWidth);
 }