A winding is an arbitrary convex polygon defined by an array of points.
Esempio n. 1
0
        public idWinding Reverse()
        {
            idWinding w = new idWinding(_pointCount);

            for (int i = 0; i < _pointCount; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    w[i, j] = this[i, j];
                }
            }

            return(w);
        }
Esempio n. 2
0
		private void ParseInterAreaPortals(idLexer lexer)
		{
			lexer.ExpectTokenString("{");

			_portalAreaCount = lexer.ParseInt();

			if(_portalAreaCount < 0)
			{
				lexer.Error("ParseInterAreaPortals: bad portalAreaCount");
			}

			_portalAreas = new PortalArea[_portalAreaCount];
			_areaScreenRect = new idScreenRect[_portalAreaCount];

			for(int i = 0; i < _portalAreaCount; i++)
			{
				_portalAreas[i] = new PortalArea();
				_areaScreenRect[i] = new idScreenRect();
			}

			// set the doubly linked lists
			SetupAreaReferences();

			_interAreaPortalCount = lexer.ParseInt();

			if(_interAreaPortalCount < 0)
			{
				lexer.Error("ParseInterAreaPortals: bad interAreaPortalCount");
			}

			_doublePortals = new DoublePortal[_interAreaPortalCount];

			for(int i = 0; i < _interAreaPortalCount; i++)
			{
				_doublePortals[i] = new DoublePortal();

				int pointCount = lexer.ParseInt();
				int a1 = lexer.ParseInt();
				int a2 = lexer.ParseInt();

				idWinding w = new idWinding(pointCount);

				for(int j = 0; j < pointCount; j++)
				{
					float[] tmp = lexer.Parse1DMatrix(3);

					w[j,0] = tmp[0];
					w[j,1] = tmp[1];
					w[j,2] = tmp[2];

					// no texture coordinates
					w[j,3] = 0;
					w[j,4] = 0;
				}

				// add the portal to a1
				Portal p = new Portal();
				p.IntoArea = a2;
				p.DoublePortal = _doublePortals[i];
				p.Winding = w;
				p.Plane = w.GetPlane();
				p.Next = _portalAreas[a1].Portals;

				_portalAreas[a1].Portals = p;
				_doublePortals[i].Portals[0] = p;

				// reverse it for a2
				p = new Portal();
				p.IntoArea = a1;
				p.DoublePortal = _doublePortals[i];
				p.Winding = w.Reverse();
				p.Plane = w.GetPlane();
				p.Next = _portalAreas[a2].Portals;

				_portalAreas[a2].Portals = p;
				_doublePortals[i].Portals[1] = p;
			}

			lexer.ExpectTokenString("}");
		}
Esempio n. 3
0
		private idScreenRect ScreenRectangleFromWinding(idWinding winding, ViewEntity space)
		{
			idScreenRect rect = new idScreenRect();
			Vector3 v, ndc;

			View viewDef = idE.RenderSystem.ViewDefinition;

			for(int i = 0; i < winding.PointCount; i++)
			{
				idHelper.LocalPointToGlobal(space.ModelMatrix, winding[i], out v);
				idHelper.GlobalToNormalizedDeviceCoordinates(v, out ndc);

				float windowX = 0.5f * (1.0f + ndc.X) * (viewDef.ViewPort.X2 - viewDef.ViewPort.X1);
				float windowY = 0.5f * (1.0f + ndc.Y) * (viewDef.ViewPort.Y2 - viewDef.ViewPort.Y1);

				rect.AddPoint(windowX, windowY);
			}

			rect.Expand();
		
			return rect;
		}
Esempio n. 4
0
		public idWinding Reverse()
		{
			idWinding w = new idWinding(_pointCount);

			for(int i = 0; i < _pointCount; i++)
			{
				for(int j = 0; j < 5; j++)
				{
					w[i, j] = this[i, j];
				}
			}

			return w;
		}