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


C# Bounds.Expand方法代码示例

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


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

示例1: AKGetFreeRandomSpawnPoint

		public static SpawnPoint AKGetFreeRandomSpawnPoint(FactionType faction)
		{
            foreach (SpawnPoint sp in instances)
            {
                //if (sp.faction != faction)
                //    continue;

                bool busy = false;
                {
                    Bounds volume = new Bounds(sp.Position);
                    volume.Expand(new Vec3(1, 1, 2));

                    Body[] result = PhysicsWorld.Instance.VolumeCast(volume,
                        (int)ContactGroup.CastOnlyContact);

                    foreach (Body body in result)
                    {
                        if (body.Static)
                            continue;

                        foreach (Shape shape in body.Shapes)
                        {
                            if (PhysicsWorld.Instance.IsContactGroupsContactable(shape.ContactGroup,
                                (int)ContactGroup.Dynamic))
                            {
                                busy = true;
                                break;
                            }
                        }
                        if (busy)
                            break;
                    }
                }

                if (!busy)
                    return sp;
            }

            return null;
		}
开发者ID:AKNightHawk,项目名称:AssaultKnights2,代码行数:40,代码来源:AKSpawnPointold.cs

示例2: FindFreePositionForUnit

		Vec3 FindFreePositionForUnit( Unit unit, Vec3 center )
		{
			Vec3 volumeSize = unit.MapBounds.GetSize() + new Vec3( 2, 2, 0 );
			for( float zOffset = 0; true; zOffset += .3f )
			{
				for( float radius = 3; radius < 8; radius += .6f )
				{
					for( float angle = 0; angle < MathFunctions.PI * 2; angle += MathFunctions.PI / 32 )
					{
						Vec3 pos = center + new Vec3( MathFunctions.Cos( angle ), MathFunctions.Sin( angle ), 0 ) * radius + new Vec3( 0, 0, zOffset );
						Bounds volume = new Bounds( pos );
						volume.Expand( volumeSize * .5f );
						Body[] bodies = PhysicsWorld.Instance.VolumeCast( volume, (int)ContactGroup.CastOnlyContact );
						if( bodies.Length == 0 )
							return pos;
					}
				}
			}
		}
开发者ID:whztt07,项目名称:NeoAxisCommunity,代码行数:19,代码来源:SelectiveSpawnPoint.cs

示例3: OnCalculateMapBounds

        protected override void OnCalculateMapBounds( ref Bounds bounds )
        {
            base.OnCalculateMapBounds( ref bounds );

            Bounds b = new Bounds( Position );
            b.Expand( new Vec3( .5f, .5f, .1f ) );
            bounds.Add( b );
        }
开发者ID:whztt07,项目名称:SDK,代码行数:8,代码来源:JigsawPuzzlePiece.cs

示例4: AquireNewTarget

        private Unit AquireNewTarget()
        {
            Unit TempTarget = null;
            Bounds volume = new Bounds(this.Position);
            volume.Expand(new Vec3(Type.RadarRange, Type.RadarRange, Type.RadarRange));

            Body[] result = PhysicsWorld.Instance.VolumeCast(volume,
                (int)ContactGroup.CastOnlyDynamic);

            foreach (Body body in result)
            {
                MapObject obj = MapSystemWorld.GetMapObjectByBody(body);
                if (obj != null)
                {
                    Unit unit = obj as Unit;

                    if (unit != null)
                    {
                        float Angletounit = CalculateAngleTo(unit);
                        //0.8f in radian is 45 Degrees and the absoulote value whould give the missile a window of 90' 
                        if (Angletounit > 0.8f)
                            continue;

                        if (TempTarget == null)
                        {
                            TempTarget = unit;
                        }
                        else
                        {
                            float PreTargetDistance = (TempTarget.Position - Position).LengthFast();
                            float newTargetDistance = (unit.Position - Position).LengthFast();

                            float DifDis = PreTargetDistance - newTargetDistance;
                            float DiftAngle = CalculateAngleTo(TempTarget) - Angletounit;

                            if (DifDis > 0 && DiftAngle > 0)
                            {
                               TempTarget = unit;
                            }
                        }
                    }
                }
            }

            return TempTarget;
        }
开发者ID:AKNightHawk,项目名称:AssaultKnights2,代码行数:46,代码来源:Missile2.cs

示例5: AquireNewTarget

        private Unit AquireNewTarget()
        {
            // NH & KEEN - reset the targetted bodypart
            targetBody = null;
            targetShape = null;

            Unit TempTarget = null;
            Bounds volume = new Bounds(this.Position);
            volume.Expand(new Vec3(Type.RadarRange, Type.RadarRange, Type.RadarRange));

            Body[] result = PhysicsWorld.Instance.VolumeCast(volume,
                (int)ContactGroup.CastOnlyDynamic);

            foreach (Body body in result)
            {
                MapObject obj = MapSystemWorld.GetMapObjectByBody(body);
                if (obj != null)
                {
                    Unit unit = obj as Unit;

                    if (unit != null)
                    {
                        float Angletounit = CalculateAngleToTarget(unit);
                        //0.8f in radian is 45 Degrees and the absoulote value whould give the missile a window of 90'

                        float targettingAngle = Type.HomingAngle / 2;

                        if (Angletounit > targettingAngle)
                            continue;

                        if (TempTarget == null)
                        {
                            TempTarget = unit;
                        }
                        else
                        {
                            float PreTargetDistance = (TempTarget.Position - Position).Length();
                            float newTargetDistance = (unit.Position - Position).Length();

                            float DifDis = PreTargetDistance - newTargetDistance;
                            float DiftAngle = CalculateAngleToTarget(TempTarget) - Angletounit;

                            if (DifDis > 0 && DiftAngle > 0)
                            {
                                TempTarget = unit;
                            }
                        }
                    }
                }
            }

            // NH & KEEN - if our target is a unit, select a random bodypart to target, otherwise check if there is a physics body to follow
            if (TempTarget != null)
            {
                AKunit targetUnit = TempTarget as AKunit;

                if (targetUnit != null)
                {
                    if (targetUnit.PhysicsModel != null && targetUnit.PhysicsModel.Bodies.Length != 0)
                    {
                        string targetBodyName = targetUnit.Type.BodyParts[World.Instance.Random.Next(0, targetUnit.Type.BodyParts.Count)].PhysicsShape;

                        FindTargetShape(targetUnit, targetBodyName, out targetBody, out targetShape);
                    }
                }
                else
                {
                    if (TempTarget.PhysicsModel != null && TempTarget.PhysicsModel.Bodies.Length != 0)
                    {
                        targetBody = TempTarget.PhysicsModel.Bodies[0];
                    }
                }
            }

            return TempTarget;
        }
开发者ID:AKNightHawk,项目名称:AssaultKnights2,代码行数:76,代码来源:Missile2.cs

示例6: FindFirstFreeSpawner

        public Spawner FindFirstFreeSpawner()
        {
            float blockedCheckRadius = 3;
            foreach (Spawner s in attachedSpawners)
            {
                bool busy = false;
                {
                    Bounds volume = new Bounds(s.Position);
                    volume.Expand(new Vec3(
                        blockedCheckRadius, blockedCheckRadius, blockedCheckRadius * 2));

                    Body[] result = PhysicsWorld.Instance.VolumeCast(volume,
                        (int)ContactGroup.CastOnlyContact);

                    foreach (Body body in result)
                    {
                        if (body.Static)
                            continue;

                        foreach (Shape shape in body.Shapes)
                        {
                            if (PhysicsWorld.Instance.IsContactGroupsContactable(shape.ContactGroup,
                                (int)ContactGroup.Dynamic))
                            {
                                busy = true;
                                break;
                            }
                        }
                        if (busy)
                            break;
                    }
                }

                if (!busy)
                    return s;
            }

            return null;
        }
开发者ID:AKNightHawk,项目名称:AssaultKnights2,代码行数:39,代码来源:Hangar.cs

示例7: CreateEnemy

        bool CreateEnemy()
        {
            //Get need enemy type
            string typeName = GetCreateEnemyTypeName();

            //Get point
            MapObject point = null;
            int safeCounter = 1;
            while( point == null )
            {
                point = enemySpawnPoints[ World.Instance.Random.Next( enemySpawnPoints.Count ) ];
                safeCounter++;
                if( safeCounter > 1000 )
                    break;
            }

            if( point == null )
                return false;

            //check for free position
            bool freePoint;
            {
                Bounds volume = new Bounds( point.Position );
                volume.Expand( new Vec3( 2, 2, 2 ) );
                Body[] bodies = PhysicsWorld.Instance.VolumeCast( volume,
                    (int)ContactGroup.CastOnlyDynamic );

                freePoint = bodies.Length == 0;
            }
            if( !freePoint )
                return false;

            //Create object
            MapObject newObj = (MapObject)Entities.Instance.Create( typeName, Map.Instance );
            newObj.Position = point.Position + new Vec3( 0, 0, 1 );
            if( typeName == "Robot" )
                newObj.Position += new Vec3( 0, 0, 1 );
            newObj.PostCreate();

            if( newObj is Unit )
                ( (Unit)newObj ).ViewRadius = 300;
            newObj.Destroying += EnemyUnitDestroying;
            newObj.Tick += EnemyUnitTick;

            return true;
        }
开发者ID:DarrenHassan,项目名称:GDM4242-GroupD,代码行数:46,代码来源:TurretDemoGameWindow.cs

示例8: GetFreeRandomSpawnPoint

        public static SpawnPoint GetFreeRandomSpawnPoint()
        {
            for( int n = 0; n < 10; n++ )
            {
                SpawnPoint spawnPoint = GetRandomSpawnPoint();

                if( spawnPoint == null )
                {
                    if( !noSpawnPointLogInformed )
                    {
                        Log.Warning( "No spawn points." );
                        noSpawnPointLogInformed = true;
                    }
                    return null;
                }

                bool busy = false;
                {
                    Bounds volume = new Bounds( spawnPoint.Position );
                    volume.Expand( new Vec3( 1, 1, 2 ) );

                    Body[] result = PhysicsWorld.Instance.VolumeCast( volume,
                        (int)ContactGroup.CastOnlyContact );

                    foreach( Body body in result )
                    {
                        if( body.Static )
                            continue;

                        foreach( Shape shape in body.Shapes )
                        {
                            if( PhysicsWorld.Instance.IsContactGroupsContactable( shape.ContactGroup,
                                (int)ContactGroup.Dynamic ) )
                            {
                                busy = true;
                                break;
                            }
                        }
                        if( busy )
                            break;
                    }
                }

                if( !busy )
                    return spawnPoint;
            }
            return null;
        }
开发者ID:CITS4242B2010,项目名称:project2010,代码行数:48,代码来源:SpawnPoint.cs

示例9: GetBounds

        protected override Bounds GetBounds()
        {
            Bounds bounds = new Bounds( data.Position );
            bounds.Expand( data.AttenuationFar * 1.1f );
            return bounds;

            //if( !float.IsPositiveInfinity( data.AttenuationRange ) )
            //{
            //   Bounds bounds = new Bounds( data.Position );
            //   bounds.Expand( data.AttenuationRange );
            //   return bounds;
            //}
            //else
            //{
            //   return new Bounds(
            //      new Vec3( float.MinValue, float.MinValue, float.MinValue ),
            //      new Vec3( float.MaxValue, float.MaxValue, float.MaxValue ) );
            //}
        }
开发者ID:whztt07,项目名称:SDK,代码行数:19,代码来源:MyLight.cs

示例10: OnRender

        protected override void OnRender( Camera camera )
        {
            base.OnRender( camera );

            if( sceneNode != null )
                sceneNode.Visible = Visible && camera != reflectionCamera;

            //update material
            if( material != null )
                material.UpdateDynamicGpuParameters();

            //update visible flag of the reflection render texture
            Camera defaultCamera = RendererWorld.Instance.DefaultCamera;
            if( reflectionRenderTexture != null && camera == defaultCamera )
            {
                Bounds bounds = new Bounds( Position );
                bounds.Expand( new Vec3( Size.X, Size.Y, 1 ) * .5f );

                Frustum frustum = FrustumUtils.GetFrustumByCamera( defaultCamera,
                    Map.Instance.NearFarClipDistance.Maximum );

                //frustum test mode
                if( EngineDebugSettings.FrustumTest && camera.AllowFrustumTestMode )
                {
                    frustum.HalfWidth *= .5f;
                    frustum.HalfHeight *= .5f;
                }

                bool inFrustum = frustum.IsIntersects( bounds ) && frustum.Origin.Z > Position.Z;

                reflectionRenderTexture.AutoUpdate = inFrustum && Visible;
            }

            if( EntitySystemWorld.Instance.IsEditor() )
            {
                //render volume
                if( physicsHeight != 0 && Type.PhysicsDensity != 0 )
                {
                    Bounds bounds = new Bounds( Position - new Vec3( 0, 0, physicsHeight / 2 ) );
                    bounds.Expand( new Vec3( Size.X, Size.Y, physicsHeight ) / 2 );

                    camera.DebugGeometry.Color = new ColorValue( 0, 0, 1 );
                    camera.DebugGeometry.AddBounds( bounds );
                }
            }
        }
开发者ID:CITS4242B2010,项目名称:project2010,代码行数:46,代码来源:WaterPlane.cs

示例11: OnPreRenderTargetUpdate

            protected override void OnPreRenderTargetUpdate( RenderTargetEvent evt )
            {
                base.OnPreRenderTargetUpdate( evt );

                Camera camera = owner.reflectionCamera;
                Camera defaultCamera = RendererWorld.Instance.DefaultCamera;

                camera.NearClipDistance = defaultCamera.NearClipDistance;
                camera.FarClipDistance = defaultCamera.FarClipDistance;
                camera.AspectRatio = defaultCamera.AspectRatio;
                camera.Fov = defaultCamera.Fov;
                camera.Position = defaultCamera.Position;
                camera.FixedUp = defaultCamera.FixedUp;
                camera.Direction = defaultCamera.Direction;

                Plane reflectionPlane = new Plane( Vec3.ZAxis, owner.Position.Z );
                camera.DisableReflection();
                camera.EnableReflection( reflectionPlane );

                //set clip planes
                {
                    Plane clipPlane = new Plane( Vec3.ZAxis, owner.Position.Z );
                    Plane[] clipPlanes = new Plane[ 5 ];
                    clipPlanes[ 0 ] = clipPlane;

                    Vec3 reflectedCameraPosition = camera.GetReflectionMatrix() * camera.Position;

                    Bounds bounds = new Bounds( owner.Position );
                    bounds.Expand( new Vec3( owner.Size.X, owner.Size.Y, 0 ) * .5f );
                    Vec3 p0 = new Vec3( bounds.Minimum.X, bounds.Minimum.Y, owner.Position.Z );
                    Vec3 p1 = new Vec3( bounds.Maximum.X, bounds.Minimum.Y, owner.Position.Z );
                    Vec3 p2 = new Vec3( bounds.Maximum.X, bounds.Maximum.Y, owner.Position.Z );
                    Vec3 p3 = new Vec3( bounds.Minimum.X, bounds.Maximum.Y, owner.Position.Z );
                    clipPlanes[ 1 ] = Plane.FromPoints( reflectedCameraPosition, p0, p1 );
                    clipPlanes[ 2 ] = Plane.FromPoints( reflectedCameraPosition, p1, p2 );
                    clipPlanes[ 3 ] = Plane.FromPoints( reflectedCameraPosition, p2, p3 );
                    clipPlanes[ 4 ] = Plane.FromPoints( reflectedCameraPosition, p3, p0 );

                    camera.SetClipPlanesForAllGeometry( clipPlanes );
                }

                //set reflection level settings
                if( DecorativeObjectManager.Instance != null )
                    saveDrawDecorativeObjects = DecorativeObjectManager.Instance.Visible;

                camera.DrawStaticGeometry = true;
                camera.DrawModels = true;
                camera.DrawEffects = true;

                if( (int)owner.ReflectionLevel < (int)ReflectionLevels.OnlyStaticGeometry )
                    camera.DrawStaticGeometry = false;
                if( (int)owner.ReflectionLevel < (int)ReflectionLevels.OnlyModels )
                    camera.DrawModels = false;
                if( (int)owner.ReflectionLevel < (int)ReflectionLevels.ReflectAll )
                {
                    camera.DrawEffects = false;
                    if( DecorativeObjectManager.Instance != null )
                        DecorativeObjectManager.Instance.Visible = false;
                }

                //activate simple rendering mode for terrains
                foreach( HeightmapTerrain terrain in HeightmapTerrain.Instances )
                {
                    saveHeightmapTerrainsSimpleRenderingState.Add( terrain, terrain.SimpleRendering );
                    terrain.SimpleRendering = true;
                }
            }
开发者ID:CITS4242B2010,项目名称:project2010,代码行数:67,代码来源:WaterPlane.cs

示例12: OnRender

		protected override void OnRender( Camera camera )
		{
			base.OnRender( camera );

			if( !camera.IsForShadowMapGeneration() && MapEditorInterface.Instance != null &&
				MapEditorInterface.Instance.IsEntitySelected( this ) )
			{
				//render volume
				if( physicsHeight != 0 && Type.PhysicsDensity != 0 )
				{
					Bounds bounds = new Bounds( Position - new Vec3( 0, 0, physicsHeight / 2 ) );
					bounds.Expand( new Vec3( Size.X, Size.Y, physicsHeight ) / 2 );

					camera.DebugGeometry.Color = new ColorValue( 0, 0, 1 );
					camera.DebugGeometry.AddBounds( bounds );
				}
			}
		}
开发者ID:whztt07,项目名称:NeoAxisCommunity,代码行数:18,代码来源:WaterPlane.cs

示例13: ViewportPreUpdate

		void ViewportPreUpdate( Viewport viewport )
		{
			Camera camera = viewport.ViewportCamera;

			if( camera.Purpose == Camera.Purposes.MainCamera )
			{
				bool needUpdate;
				{
					if( Visible )
					{
						Bounds bounds = new Bounds( Position );
						bounds.Expand( new Vec3( Size.X, Size.Y, 1 ) * .5f );

						Frustum frustum = FrustumUtils.GetFrustumByCamera( camera );

						//frustum test mode
						if( EngineDebugSettings.FrustumTest && camera.AllowFrustumTestMode )
						{
							frustum.HalfWidth *= .5f;
							frustum.HalfHeight *= .5f;
						}

						needUpdate = frustum.IsIntersects( bounds ) && frustum.Origin.Z > Position.Z;
					}
					else
						needUpdate = false;
				}

				if( needUpdate )
				{
					ReflectionTextureItem item = null;
					if( !IsFixedPipelineFallback() && ReflectionLevel != ReflectionLevels.None &&
						RenderSystem.Instance.Capabilities.HardwareRenderToTexture )
					{
						item = GetReflectionTextureItemByViewport( viewport );
						if( item == null )
							item = CreateReflectionTextureItem( viewport );
					}

					if( item != null )
						UpdateReflectionTexture( item );

					//update material
					if( material != null )
					{
						material.UpdateDynamicGpuParameters();
						if( item != null )
							material.UpdateReflectionMap( item.reflectionTexture.Name );
					}
				}

				if( sceneNode != null )
					sceneNode.Visible = Visible;
			}
		}
开发者ID:whztt07,项目名称:NeoAxisCommunity,代码行数:55,代码来源:WaterPlane.cs

示例14: UpdateReflectionTexture

		void UpdateReflectionTexture( ReflectionTextureItem item )
		{
			//changing during update
			bool saveDrawDecorativeObjects = false;
			Dictionary<HeightmapTerrain, bool> saveHeightmapTerrainsSimpleRenderingState =
				new Dictionary<HeightmapTerrain, bool>();

			//configure camera and entities
			{
				Camera camera = item.reflectionCamera;
				Camera mainCamera = item.mainCamera;

				camera.NearClipDistance = mainCamera.NearClipDistance;
				camera.FarClipDistance = mainCamera.FarClipDistance;
				camera.AspectRatio = mainCamera.AspectRatio;
				camera.Fov = mainCamera.Fov;
				camera.Position = mainCamera.Position;
				camera.FixedUp = mainCamera.FixedUp;
				camera.Direction = mainCamera.Direction;

				Plane reflectionPlane = new Plane( Vec3.ZAxis, Position.Z );
				camera.DisableReflection();
				camera.EnableReflection( reflectionPlane );

				//set clip planes
				{
					Plane clipPlane = new Plane( Vec3.ZAxis, Position.Z );
					Plane[] clipPlanes = new Plane[ 5 ];
					clipPlanes[ 0 ] = clipPlane;

					Vec3 reflectedCameraPosition = camera.GetReflectionMatrix() * camera.Position;

					Bounds bounds = new Bounds( Position );
					bounds.Expand( new Vec3( Size.X, Size.Y, 0 ) * .5f );
					Vec3 p0 = new Vec3( bounds.Minimum.X, bounds.Minimum.Y, Position.Z );
					Vec3 p1 = new Vec3( bounds.Maximum.X, bounds.Minimum.Y, Position.Z );
					Vec3 p2 = new Vec3( bounds.Maximum.X, bounds.Maximum.Y, Position.Z );
					Vec3 p3 = new Vec3( bounds.Minimum.X, bounds.Maximum.Y, Position.Z );
					clipPlanes[ 1 ] = Plane.FromPoints( reflectedCameraPosition, p0, p1 );
					clipPlanes[ 2 ] = Plane.FromPoints( reflectedCameraPosition, p1, p2 );
					clipPlanes[ 3 ] = Plane.FromPoints( reflectedCameraPosition, p2, p3 );
					clipPlanes[ 4 ] = Plane.FromPoints( reflectedCameraPosition, p3, p0 );

					camera.SetClipPlanesForAllGeometry( clipPlanes );
				}

				//set reflection level settings
				if( DecorativeObjectManager.Instance != null )
					saveDrawDecorativeObjects = DecorativeObjectManager.Instance.Visible;

				camera.DrawStaticGeometry = true;
				camera.DrawModels = true;
				camera.DrawEffects = true;

				if( (int)ReflectionLevel < (int)ReflectionLevels.OnlyStaticGeometry )
					camera.DrawStaticGeometry = false;
				if( (int)ReflectionLevel < (int)ReflectionLevels.OnlyModels )
					camera.DrawModels = false;
				if( (int)ReflectionLevel < (int)ReflectionLevels.ReflectAll )
				{
					camera.DrawEffects = false;
					if( DecorativeObjectManager.Instance != null )
						DecorativeObjectManager.Instance.Visible = false;
				}

				//activate simple rendering mode for terrains
				foreach( HeightmapTerrain terrain in HeightmapTerrain.Instances )
				{
					saveHeightmapTerrainsSimpleRenderingState.Add( terrain, terrain.SimpleRendering );
					terrain.SimpleRendering = true;
				}
			}

			//get clip volumes
			List<Box> clipVolumes = new List<Box>();
			foreach( WaterPlaneClipVolume volume in WaterPlaneClipVolume.Instances )
			{
				if( volume.Editor_IsExcludedFromWorld() )
					continue;
				clipVolumes.Add( volume.GetBox() );
			}

			//bind clip volumes
			if( clipVolumes.Count != 0 )
				RenderingLowLevelMethodsImpl.PushClipVolumes( clipVolumes.ToArray() );

			//render
			item.reflectionRenderTexture.Update( false );

			//unbind clip volumes
			if( clipVolumes.Count != 0 )
				RenderingLowLevelMethodsImpl.PopClipVolumes();

			//restore entity settings
			{
				//RenderSystem.Instance.ResetScissorTest();

				//restore simple rendering mode state for terrains
				foreach( HeightmapTerrain terrain in HeightmapTerrain.Instances )
				{
//.........这里部分代码省略.........
开发者ID:whztt07,项目名称:NeoAxisCommunity,代码行数:101,代码来源:WaterPlane.cs


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