コード例 #1
0
ファイル: Draw.cs プロジェクト: chadng/SharpSteer2
        // draw the edges of a box with a given position, orientation, size
        // and color.  The box edges are aligned with the axes of the given
        // LocalSpace, and it is centered at the origin of that LocalSpace.
        // "size" is the main diagonal of the box.
        //
        // use gGlobalSpace to draw a box aligned with global space
        public static void DrawBoxOutline(ILocalSpaceBasis localSpace, Vector3 size, Color color)
        {
            Vector3 s = size / 2.0f;              // half of main diagonal

            Vector3 a = localSpace.GlobalizePosition(new Vector3(+s.X, +s.Y, +s.Z));
            Vector3 b = localSpace.GlobalizePosition(new Vector3(+s.X, -s.Y, +s.Z));
            Vector3 c = localSpace.GlobalizePosition(new Vector3(-s.X, -s.Y, +s.Z));
            Vector3 d = localSpace.GlobalizePosition(new Vector3(-s.X, +s.Y, +s.Z));

            Vector3 e = localSpace.GlobalizePosition(new Vector3(+s.X, +s.Y, -s.Z));
            Vector3 f = localSpace.GlobalizePosition(new Vector3(+s.X, -s.Y, -s.Z));
            Vector3 g = localSpace.GlobalizePosition(new Vector3(-s.X, -s.Y, -s.Z));
            Vector3 h = localSpace.GlobalizePosition(new Vector3(-s.X, +s.Y, -s.Z));

            iDrawLine(a, b, color);
            iDrawLine(b, c, color);
            iDrawLine(c, d, color);
            iDrawLine(d, a, color);

            iDrawLine(a, e, color);
            iDrawLine(b, f, color);
            iDrawLine(c, g, color);
            iDrawLine(d, h, color);

            iDrawLine(e, f, color);
            iDrawLine(f, g, color);
            iDrawLine(g, h, color);
            iDrawLine(h, e, color);
        }
コード例 #2
0
        public void GlobalizePositionTest()
        {
            Matrix4x4        m     = Matrix4x4.CreateRotationX(-PiOver2) * Matrix4x4.CreateTranslation(10, 20, 30);
            ILocalSpaceBasis basis = Basis(m);

            var v = Vector3.Normalize(new Vector3(1, 2, 3));

            Assert.AreEqual(Vector3.Transform(v, m), basis.GlobalizePosition(v));
        }
コード例 #3
0
ファイル: Draw.cs プロジェクト: chadng/SharpSteer2
        // draw the three axes of a LocalSpace: three lines parallel to the
        // basis vectors of the space, centered at its origin, of lengths
        // given by the coordinates of "size".
        public static void DrawAxes(ILocalSpaceBasis ls, Vector3 size, Color color)
        {
            Vector3 x = new Vector3(size.X / 2, 0, 0);
            Vector3 y = new Vector3(0, size.Y / 2, 0);
            Vector3 z = new Vector3(0, 0, size.Z / 2);

            iDrawLine(ls.GlobalizePosition(x), ls.GlobalizePosition(x * -1), color);
            iDrawLine(ls.GlobalizePosition(y), ls.GlobalizePosition(y * -1), color);
            iDrawLine(ls.GlobalizePosition(z), ls.GlobalizePosition(z * -1), color);
        }
コード例 #4
0
ファイル: TerrainMap.cs プロジェクト: chadng/SharpSteer2
        // used to detect if vehicle body is on any obstacles
        public bool ScanLocalXZRectangle(ILocalSpaceBasis localSpace, float xMin, float xMax, float zMin, float zMax)
        {
            float spacing = MinSpacing() / 2;

            for (float x = xMin; x < xMax; x += spacing)
            {
                for (float z = zMin; z < zMax; z += spacing)
                {
                    Vector3 sample = new Vector3(x, 0, z);
                    Vector3 global = localSpace.GlobalizePosition(sample);
                    if (GetMapValue(global))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
コード例 #5
0
ファイル: TerrainMap.cs プロジェクト: cupsster/SharpSteer2
		// used to detect if vehicle body is on any obstacles
		public bool ScanLocalXZRectangle(ILocalSpaceBasis localSpace, float xMin, float xMax, float zMin, float zMax)
		{
			float spacing = MinSpacing() / 2;

			for (float x = xMin; x < xMax; x += spacing)
			{
				for (float z = zMin; z < zMax; z += spacing)
				{
					Vector3 sample = new Vector3(x, 0, z);
					Vector3 global = localSpace.GlobalizePosition(sample);
					if (GetMapValue(global)) return true;
				}
			}
			return false;
		}
コード例 #6
0
ファイル: Draw.cs プロジェクト: cupsster/SharpSteer2
		// draw the edges of a box with a given position, orientation, size
		// and color.  The box edges are aligned with the axes of the given
		// LocalSpace, and it is centered at the origin of that LocalSpace.
		// "size" is the main diagonal of the box.
		//
		// use gGlobalSpace to draw a box aligned with global space
		public static void DrawBoxOutline(ILocalSpaceBasis localSpace, Vector3 size, Color color)
		{
			Vector3 s = size / 2.0f;  // half of main diagonal

			Vector3 a = localSpace.GlobalizePosition(new Vector3(+s.X, +s.Y, +s.Z));
			Vector3 b = localSpace.GlobalizePosition(new Vector3(+s.X, -s.Y, +s.Z));
			Vector3 c = localSpace.GlobalizePosition(new Vector3(-s.X, -s.Y, +s.Z));
			Vector3 d = localSpace.GlobalizePosition(new Vector3(-s.X, +s.Y, +s.Z));

			Vector3 e = localSpace.GlobalizePosition(new Vector3(+s.X, +s.Y, -s.Z));
			Vector3 f = localSpace.GlobalizePosition(new Vector3(+s.X, -s.Y, -s.Z));
			Vector3 g = localSpace.GlobalizePosition(new Vector3(-s.X, -s.Y, -s.Z));
			Vector3 h = localSpace.GlobalizePosition(new Vector3(-s.X, +s.Y, -s.Z));

			iDrawLine(a, b, color);
			iDrawLine(b, c, color);
			iDrawLine(c, d, color);
			iDrawLine(d, a, color);

			iDrawLine(a, e, color);
			iDrawLine(b, f, color);
			iDrawLine(c, g, color);
			iDrawLine(d, h, color);

			iDrawLine(e, f, color);
			iDrawLine(f, g, color);
			iDrawLine(g, h, color);
			iDrawLine(h, e, color);
		}
コード例 #7
0
ファイル: Draw.cs プロジェクト: cupsster/SharpSteer2
		// draw the three axes of a LocalSpace: three lines parallel to the
		// basis vectors of the space, centered at its origin, of lengths
		// given by the coordinates of "size".
		public static void DrawAxes(ILocalSpaceBasis ls, Vector3 size, Color color)
		{
			Vector3 x = new Vector3(size.X / 2, 0, 0);
			Vector3 y = new Vector3(0, size.Y / 2, 0);
			Vector3 z = new Vector3(0, 0, size.Z / 2);

			iDrawLine(ls.GlobalizePosition(x), ls.GlobalizePosition(x * -1), color);
			iDrawLine(ls.GlobalizePosition(y), ls.GlobalizePosition(y * -1), color);
			iDrawLine(ls.GlobalizePosition(z), ls.GlobalizePosition(z * -1), color);
		}