Ejemplo n.º 1
0
		// 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;
		}
Ejemplo n.º 2
0
		// 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);
		}
Ejemplo n.º 3
0
		// 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);
		}
Ejemplo n.º 4
0
        private void SerialNumberAnnotationUtility(ILocalSpaceBasis selected)
		{
			// display a Pedestrian's serial number as a text label near its
			// screen position when it is near the selected vehicle or mouse.
			if (selected != null)//FIXME: && IsAnnotationEnabled)
			{
				foreach (IVehicle vehicle in _crowd)
				{
				    const float NEAR_DISTANCE = 6;
				    Vector3 vp = vehicle.Position;
				    //Vector3 np = nearMouse.Position;
				    if ((Vector3.Distance(vp, selected.Position) < NEAR_DISTANCE)/* ||
						(nearMouse != null && (Vector3.Distance(vp, np) < nearDistance))*/)
				    {
				        String sn = String.Format("#{0}", vehicle.GetHashCode());
				        Color textColor = new Color((byte)(255.0f * 0.8f), (byte)(255.0f * 1), (byte)(255.0f * 0.8f));
				        Vector3 textOffset = new Vector3(0, 0.25f, 0);
				        Vector3 textPos = vehicle.Position + textOffset;
				        Drawing.Draw2dTextAt3dLocation(sn, textPos, textColor);
				    }
				}
			}
		}