当前位置: 首页>>代码示例>>C#>>正文


C# Bounds.GetPointDistance方法代码示例

本文整理汇总了C#中Bounds.GetPointDistance方法的典型用法代码示例。如果您正苦于以下问题:C# Bounds.GetPointDistance方法的具体用法?C# Bounds.GetPointDistance怎么用?C# Bounds.GetPointDistance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Bounds的用法示例。


在下文中一共展示了Bounds.GetPointDistance方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DrawGrid

		public void DrawGrid( Camera camera )
		{
			//Update renderVertices buffer
			if( renderVertices.Count == 0 )
			{
				renderVertices.Capacity = ( mapSize.X + 1 ) * ( mapSize.Y + 1 );

				if( renderFreeIndices.Capacity < renderVertices.Capacity * 6 )
					renderFreeIndices.Capacity = renderVertices.Capacity * 6;
				if( renderBusyIndices.Capacity < renderVertices.Capacity * 6 )
					renderBusyIndices.Capacity = renderVertices.Capacity * 6;

				for( int y = 0; y < mapSize.Y + 1; y++ )
				{
					for( int x = 0; x < mapSize.X + 1; x++ )
					{
						Vec2 p = mapMotionPosition + new Vec2( x, y ) * GridCellSize;
						renderVertices.Add( new Vec3( p.X, p.Y, GetMotionMapHeight( p ) ) );
					}
				}
			}

			renderFreeIndices.Clear();
			renderBusyIndices.Clear();

			{
				const int tileSize = 10;

				//set color for lines
				camera.DebugGeometry.Color = new ColorValue( 1, 1, 0, .7f );

				//tiles loop
				for( int tileY = 0; tileY < mapSize.Y; tileY += tileSize )
				{
					for( int tileX = 0; tileX < mapSize.X; tileX += tileSize )
					{
						//get tile bounds
						Rect bounds2 = mapMotionPosition + new Rect(
							new Vec2( tileX * GridCellSize, tileY * GridCellSize ),
							new Vec2( ( tileX + tileSize ) * GridCellSize, ( tileY + tileSize ) * GridCellSize ) );

						Bounds worldBounds = Map.Instance.SceneGraph.GetOctreeBoundsWithBoundsOfObjectsOutsideOctree();
						Bounds bounds = new Bounds(
							bounds2.Minimum.X, bounds2.Minimum.Y, worldBounds.Minimum.Z,
							bounds2.Maximum.X, bounds2.Maximum.Y, worldBounds.Maximum.Z );

						//check tile visibility
						if( !camera.IsIntersectsFast( bounds ) )
							continue;

						//check by distance
						{
							float distance = bounds.GetPointDistance( camera.Position );
							if( distance > drawGridDistance )
								continue;
						}

						//loop in tile
						for( int y = tileY; y < tileY + tileSize && y < mapSize.Y; y++ )
						{
							for( int x = tileX; x < tileX + tileSize && x < mapSize.X; x++ )
							{
								int p0 = ( mapSize.X + 1 ) * y + x;
								int p1 = p0 + 1;
								int p2 = p0 + mapSize.X + 1;
								int p3 = p2 + 1;

								//draw lines
								Vec3 offset = new Vec3( 0, 0, .4f );

								//camera.DebugGeometry.Color = new ColorValue( 1, 1, 0 );
								camera.DebugGeometry.AddLine( renderVertices[ p0 ] + offset, renderVertices[ p1 ] + offset );
								camera.DebugGeometry.AddLine( renderVertices[ p0 ] + offset, renderVertices[ p2 ] + offset );

								//add grid buffers
								List<int> list = IsFreeInMapMotion( new Vec2I( x, y ) ) ? renderFreeIndices : renderBusyIndices;
								list.Add( p0 );
								list.Add( p1 );
								list.Add( p2 );

								list.Add( p2 );
								list.Add( p1 );
								list.Add( p3 );
							}
						}
					}
				}
			}

			//draw grids
			camera.DebugGeometry.Color = new ColorValue( 0, 1, 0, .3f );
			camera.DebugGeometry.AddVertexIndexBuffer( renderVertices, renderFreeIndices,
				Mat4.FromTranslate( new Vec3( 0, 0, .2f ) ), false, true );

			camera.DebugGeometry.Color = new ColorValue( 1, 0, 0, .3f );
			camera.DebugGeometry.AddVertexIndexBuffer( renderVertices, renderBusyIndices,
				Mat4.FromTranslate( new Vec3( 0, 0, .2f ) ), false, true );
		}
开发者ID:whztt07,项目名称:SDK,代码行数:98,代码来源:GridBasedNavigationSystem.cs


注:本文中的Bounds.GetPointDistance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。