示例#1
0
		static DeferredCircle()
		{
			_deferredCircleArray = new DeferredCircle[SIZE];
			for (int i = 0; i < SIZE; i++)
			{
				_deferredCircleArray[i] = new DeferredCircle();
			}
		}
示例#2
0
 static DeferredCircle()
 {
     _deferredCircleArray = new DeferredCircle[SIZE];
     for (int i = 0; i < SIZE; i++)
     {
         _deferredCircleArray[i] = new DeferredCircle();
     }
 }
示例#3
0
        public static void DrawAll()
        {
            // draw all circles in the buffer
            for (int i = 0; i < _index; i++)
            {
                DeferredCircle dc = _deferredCircleArray[i];
                Drawing.DrawCircleOrDisk(dc._radius, dc._axis, dc._center, dc._color, dc._segments, dc._filled, dc._in3D);
            }

            // reset buffer index
            _index = 0;
        }
示例#4
0
 public static void AllDeferredCirclesOrDisks()
 {
     DeferredCircle.DrawAll();
 }
示例#5
0
        // General purpose circle/disk drawing routine.  Draws circles or disks (as
        // specified by "filled" argument) and handles both special case 2d circles
        // on the XZ plane or arbitrary circles in 3d space (as specified by "in3d"
        // argument)
        public static void DrawCircleOrDisk(float radius, Vector3 axis, Vector3 center, Color color, int segments, bool filled, bool in3D)
        {
            if (Demo.IsDrawPhase)
            {
                LocalSpace ls = new LocalSpace();
                if (in3D)
                {
                    // define a local space with "axis" as the Y/up direction
                    // (XXX should this be a method on  LocalSpace?)
                    Vector3 unitAxis = Vector3.Normalize(axis);
                    Vector3 unitPerp = Vector3.Normalize(axis.FindPerpendicularIn3d());
                    ls.Up       = unitAxis;
                    ls.Forward  = unitPerp;
                    ls.Position = (center);
                    ls.SetUnitSideFromForwardAndUp();
                }

                // make disks visible (not culled) from both sides
                if (filled)
                {
                    BeginDoubleSidedDrawing();
                }

                // point to be rotated about the (local) Y axis, angular step size
                Vector3 pointOnCircle = new Vector3(radius, 0, 0);
                float   step          = (float)(2 * Math.PI) / segments;

                // set drawing color
                SetColor(color);

                // begin drawing a triangle fan (for disk) or line loop (for circle)
                drawBegin(filled ? PrimitiveType.TriangleStrip : PrimitiveType.LineStrip);

                // for the filled case, first emit the center point
                if (filled)
                {
                    AddVertex(in3D ? ls.Position : center);
                }

                // rotate p around the circle in "segments" steps
                float sin = 0, cos = 0;
                int   vertexCount = filled ? segments + 1 : segments;
                for (int i = 0; i < vertexCount; i++)
                {
                    // emit next point on circle, either in 3d (globalized out
                    // of the local space), or in 2d (offset from the center)
                    AddVertex(in3D ? ls.GlobalizePosition(pointOnCircle) : pointOnCircle + center);

                    // rotate point one more step around circle
                    pointOnCircle = pointOnCircle.RotateAboutGlobalY(step, ref sin, ref cos);
                }

                // close drawing operation
                drawEnd();
                if (filled)
                {
                    EndDoubleSidedDrawing();
                }
            }
            else
            {
                DeferredCircle.AddToBuffer(radius, axis, center, color, segments, filled, in3D);
            }
        }