• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# BoundingSphere类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中BoundingSphere的典型用法代码示例。如果您正苦于以下问题:C# BoundingSphere类的具体用法?C# BoundingSphere怎么用?C# BoundingSphere使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BoundingSphere类属于命名空间,在下文中一共展示了BoundingSphere类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Update

        public void Update(GameTime gameTime)
        {
            if (timer > 0)
            {
                timer -= gameTime.ElapsedGameTime.TotalSeconds;
                scale += 0.12f;
                alpha -= 0.016f;
            }
            else
                isActive = false;

            BoundingSphere bombSphere = new BoundingSphere(position, explosionModel.Meshes[0].BoundingSphere.Radius * scale);
            for (int i = 0; i < GamePlay.asteroidList.Length; i++)
            {
                if (GamePlay.asteroidList[i].isActive)
                {
                    BoundingSphere asteroidSphere = new BoundingSphere(GamePlay.asteroidList[i].position,
                        GamePlay.asteroidModel.Meshes[0].BoundingSphere.Radius * 0.95f);
                    if (asteroidSphere.Intersects(bombSphere))
                    {
                        //destroy asteroid
                        MainClass.soundBank.PlayCue("explosion2");
                        GamePlay.asteroidList[i].isActive = false;
                        GamePlay.playerList[index].score += GameConstants.KillBonus;
                        return; //exit the loop
                    }
                }
            }
        }
开发者ID:hassanselim0,项目名称:Asteroids-Game,代码行数:29,代码来源:Bomb.cs


示例2: CollideSphere

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="center">center position of the sphere</param>
        /// <param name="radius">radius of the sphere</param>
        public CollideSphere(Vector3 center, float radius)
            : base()
        {
            localCenter = center;

            boundingSphere = new BoundingSphere(localCenter, radius);
        }
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:12,代码来源:CollideSphere.cs


示例3: Planet

        public Planet(Vector3 Position, float Scale, float ParentMass, Vector3 OrbitalPlaneNormal)
            : base()
        {
            Body.CreateUVSphere(32, 32, out ModelVertices, out ModelIndices);
            effect = Manager.TexturedEffect;

            NoiseMap = Manager.WrappedNoiseTextures[MyGame.random.Next(Manager.WrappedNoiseTextures.Length)];
            Color[] StaticNoise = Manager.GenerateStaticNoise(5, 5);
            for (int i = 0; i < StaticNoise.Length; i++)
            {
                StaticNoise[i] = Color.Lerp(planetColors[MyGame.random.Next(planetColors.Length)]
                    , StaticNoise[i]
                    , 0.1f * (float)MyGame.random.NextDouble());
            }
            ColorMap = new Texture2D(MyGame.graphics.GraphicsDevice, 5, 5);
            ColorMap.SetData<Color>(StaticNoise);

            RotationAxis = Manager.GetRandomNormal();
            RotationTime = (float)MyGame.random.NextDouble();
            Bounds = new BoundingSphere(Position, 2.0f * Scale);
            this.Transforms = new ScalePositionRotation(
                Scale
                , Position
                , Matrix.CreateFromAxisAngle(RotationAxis, RotationTime));
            Mass = 10.0f * (float)(4.0 / 3.0 * Math.PI * Math.Pow(Transforms.Scale, 3.0));

            this.Velocity = Body.GetRandomInitialOrbitVelocity(Position, OrbitalPlaneNormal, ParentMass, Mass);
        }
开发者ID:kaysoky,项目名称:AstronomicalSimulator,代码行数:28,代码来源:Planet.cs


示例4: GameObject

 public GameObject()
 {
     Model = null;
     Position = Vector3.Zero;
     Rotation = Vector3.Zero;
     BoundingSphere = new BoundingSphere();
 }
开发者ID:ChrisLau90,项目名称:Programming-for-3D-Assignment,代码行数:7,代码来源:GameObject.cs


示例5: Character

        public Character(string textureName, Vector2 position, ContentManager content, int frameCount)
        {
            mContent = content;
            mTextureName = textureName;
            mPosition = position;
            mAge = age.BABY;
            mStates = states.SPAWNING;
            mSpeed = new Vector2(1.0f, 0.25f);
            //mSpeed = new Vector2(0, 0);

            mSprite = new AnimatedSprite();
            //mSprite.Load(mContent, "AnimatedSprites/" + mTextureName, frameCount, 30, 149, 139, false);
            mSprite.Load(mContent, "AnimatedSprites/" + mTextureName, frameCount, 0.125f, 128, 128, false);

            bSphere = new BoundingSphere(new Vector3(position.X + mSprite.getWidth() / 2, position.Y + mSprite.getHeight() / 2, 0), mSprite.getWidth() / 2);
            distance = 10000;
            destination = Vector2.Zero;
            timeEating = 2.0f;

            timeOnFire = 0.5f;

            respawnRate = 3.0f;
            remove = false;
            multipleOfTwo = false;
            hacktex = Class1.CreateCircle((int)mSprite.getWidth() / 2, Color.Yellow);

            timespawning = 2.0f;
        }
开发者ID:grodranlorth,项目名称:tctk,代码行数:28,代码来源:Character.cs


示例6: GetAllBroadcastersInMyRange

        protected override void GetAllBroadcastersInMyRange(ref HashSet<MyDataBroadcaster> relayedBroadcasters, long localPlayerId, HashSet<long> gridsQueued)
        {
            var sphere = new BoundingSphere(Parent.PositionComp.GetPosition(), 0.5f);

            MyRadioBroadcasters.GetAllBroadcastersInSphere(sphere, m_broadcastersInRange);

            foreach (var broadcaster in m_broadcastersInRange)
            {
                if (relayedBroadcasters.Contains(broadcaster))
                    continue;

                relayedBroadcasters.Add(broadcaster);

                if (!CanIUseIt(broadcaster, localPlayerId))
                    continue;

                if (broadcaster.Parent is IMyComponentOwner<MyDataReceiver>)
                {
                    MyDataReceiver radioReceiver;
                    if ((broadcaster.Parent as IMyComponentOwner<MyDataReceiver>).GetComponent(out radioReceiver))
                    {
                        radioReceiver.UpdateBroadcastersInRange(relayedBroadcasters, localPlayerId, gridsQueued);
                    }
                }
            }
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:26,代码来源:MyRadioReceiver.cs


示例7: GetBoundingSphere

        public BoundingSphere GetBoundingSphere(Vector3 aLowest, Vector3 aHighest, Vector3 aTranslation, Vector3 aTile)
        {
            Vector3 temporaryRadius = new Vector3((aHighest.X - aLowest.X) / 2, (aHighest.Y - aLowest.Y) / 2, (aHighest.Z - aLowest.Z) / 2) * aTile;
            BoundingSphere temporarySphere = new BoundingSphere(aTranslation, (temporaryRadius.X + temporaryRadius.Y + temporaryRadius.Z) / 3);

            return temporarySphere;
        }
开发者ID:JonathanMcCaffrey,项目名称:tank-gauntlet,代码行数:7,代码来源:UtilityManager.cs


示例8: Initialize

 public override void Initialize()
 {
     PourcentageVie = 1;
     SphereCollision = new BoundingSphere(Position, RAYON_COLLISION);
     CompteurCollision = 0;
     base.Initialize();
 }
开发者ID:HazWard,项目名称:Tank3D,代码行数:7,代码来源:AI.cs


示例9: Intersect

 public static bool Intersect(Triangle triangle, BoundingSphere sphere, out object intersection)
 {
     intersection = null;
     return Common.Intersection.Intersect(sphere, triangle.A.Position, out intersection) ||
         Common.Intersection.Intersect(sphere, triangle.B.Position, out intersection) ||
         Common.Intersection.Intersect(sphere, triangle.C.Position, out intersection);
 }
开发者ID:ChristianMarchiori,项目名称:DeadMeetsLead,代码行数:7,代码来源:Triangle.cs


示例10: Draw

        public override void Draw(GraphicsDevice device, Camera cam)
        {
            if (filter == null)
            {
                return;
            }

            Mesh mesh = filter.meshToRender;
            BoundingSphere sphere = new BoundingSphere(transform.TransformPoint(filter.boundingSphere.Center), filter.boundingSphere.Radius * Math.Max(transform.lossyScale.x, Math.Max(transform.lossyScale.y, transform.lossyScale.z)));
            bool cull = cam.DoFrustumCulling(ref sphere);
            if (cull)
            {
            #if DEBUG
                if (Camera.logRenderCalls)
                {
                    Debug.LogFormat("VP cull mesh {0} with center {1} radius {2} cam {3} at {4}", gameObject, sphere.Center, sphere.Radius, cam.gameObject, cam.transform.position);
                }
            #endif
                return;
            }

            if (filter.CanBatch())
            {
                cam.BatchRender(filter.meshToRender, sharedMaterials, transform);
            }
        }
开发者ID:iamjianxin,项目名称:FFWD,代码行数:26,代码来源:MeshRenderer.cs


示例11: ComputeBounds

        public unsafe static BoundingBox ComputeBounds(this VertexBufferBinding vertexBufferBinding, ref Matrix matrix, out BoundingSphere boundingSphere)
        {
            var positionOffset = vertexBufferBinding.Declaration
                .EnumerateWithOffsets()
                .First(x => x.VertexElement.SemanticAsText == "POSITION")
                .Offset;

            var boundingBox = BoundingBox.Empty;
            boundingSphere = new BoundingSphere();

            var vertexStride = vertexBufferBinding.Declaration.VertexStride;
            fixed (byte* bufferStart = &vertexBufferBinding.Buffer.GetSerializationData().Content[vertexBufferBinding.Offset])
            {
                // Calculates bounding box and bounding sphere center
                byte* buffer = bufferStart + positionOffset;
                for (int i = 0; i < vertexBufferBinding.Count; ++i)
                {
                    var position = (Vector3*)buffer;
                    Vector3 transformedPosition;

                    Vector3.TransformCoordinate(ref *position, ref matrix, out transformedPosition);

                    // Prepass calculate the center of the sphere
                    Vector3.Add(ref transformedPosition, ref boundingSphere.Center, out boundingSphere.Center);
                    
                    BoundingBox.Merge(ref boundingBox, ref transformedPosition, out boundingBox);
                    
                    buffer += vertexStride;
                }

                //This is the center of our sphere.
                boundingSphere.Center /= (float)vertexBufferBinding.Count;

                // Calculates bounding sphere center
                buffer = bufferStart + positionOffset;
                for (int i = 0; i < vertexBufferBinding.Count; ++i)
                {
                    var position = (Vector3*)buffer;
                    Vector3 transformedPosition;

                    Vector3.TransformCoordinate(ref *position, ref matrix, out transformedPosition);


                    //We are doing a relative distance comparasin to find the maximum distance
                    //from the center of our sphere.
                    float distance;
                    Vector3.DistanceSquared(ref boundingSphere.Center, ref transformedPosition, out distance);

                    if (distance > boundingSphere.Radius)
                        boundingSphere.Radius = distance;

                    buffer += vertexStride;
                }

                //Find the real distance from the DistanceSquared.
                boundingSphere.Radius = (float)Math.Sqrt(boundingSphere.Radius);
            }

            return boundingBox;
        }
开发者ID:Powerino73,项目名称:paradox,代码行数:60,代码来源:BoundingExtensions.cs


示例12: RayInterSection_OutsideSpherePointingAway_NoIntersection

 public void RayInterSection_OutsideSpherePointingAway_NoIntersection()
 {
     var sphere = new BoundingSphere(new Point3D(0.2, 0.3, 0), 1.0);
     var ray = new Ray3D(sphere.Center + new Vector3D(0.2, 0.3, sphere.Radius), new Vector3D(1, 0.1, 0.1));
     Point3D[] result;
     Assert.IsFalse(sphere.RayIntersection(ray, out result));
 }
开发者ID:ORRNY66,项目名称:helix-toolkit,代码行数:7,代码来源:BoundingSphereTests.cs


示例13: Draw

        public void Draw(ref BoundingSphere sphere, BasicEffect effect, ref Color vertexColor)
        {
            graphicsDevice.SetVertexBuffer(vertexBuffer);

            Matrix scale;
            Matrix.CreateScale(sphere.Radius, out scale);
            Matrix translation;
            Matrix.CreateTranslation(ref sphere.Center, out translation);
            Matrix transform;
            Matrix.Multiply(ref scale, ref translation, out transform);

            effect.World = transform;
            effect.DiffuseColor = vertexColor.ToVector3();

            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                //render each circle individually
                graphicsDevice.DrawPrimitives(
                        PrimitiveType.LineStrip,
                        0,
                        sphereResolution);
                graphicsDevice.DrawPrimitives(
                        PrimitiveType.LineStrip,
                        sphereResolution + 1,
                        sphereResolution);
                graphicsDevice.DrawPrimitives(
                        PrimitiveType.LineStrip,
                        (sphereResolution + 1) * 2,
                        sphereResolution);
            }
        }
开发者ID:willcraftia,项目名称:WindowsGame,代码行数:32,代码来源:BoundingSphereDrawer.cs


示例14: Render

        public static void Render(Primitive prim, RenderContext context, Color color)
        {
            if (prim.PrimType == Forever.Physics.Collide.CollideType.Sphere)
              {
            Sphere sphere = (Sphere)prim;
            BoundingSphere bs = new BoundingSphere(prim.Body.Position, sphere.Radius);
            BoundingSphereRenderer.Render(bs, context, color);
              }
              else if (prim.PrimType == Forever.Physics.Collide.CollideType.Box)
              {
            Box b = (Box)prim;
            Matrix world = prim.Body.World;
            BoundingBoxRenderer.Render(
              BoundingBox.CreateFromPoints(b.LocalVerts()),
              context.GraphicsDevice,
              world * b.OffsetMatrix,
              context.Camera.View,
              context.Camera.Projection,
              color
            );
              }else if(prim.PrimType == Forever.Physics.Collide.CollideType.Plane){

              Render((Forever.Physics.Collide.Plane)prim, context, color);
              }
              else
              {
            throw new Exception("I don't know how to draw that!");
              }
        }
开发者ID:DigitalLibrarian,项目名称:xna-forever,代码行数:29,代码来源:PrimitiveRenderer.cs


示例15: RayPointingAwayFromBoundingSphereShouldBeIntersected

 public void RayPointingAwayFromBoundingSphereShouldBeIntersected()
 {
     var boundingSphere = new BoundingSphere(new Vector(0, 0, 0), 1);
     var ray = new Ray(new Vector(0, -10, 0), new Vector(0, -1, 0));
     var result = ray.Intersects(boundingSphere);
     Assert.That(result, Is.Null);
 }
开发者ID:petriw,项目名称:Balder,代码行数:7,代码来源:RayTests.cs


示例16: checkedFaces

        /// <summary>
        /// Returns the raw number of triangles actually checked for collision 
        /// (all triangles in all nodes that are reached)
        /// </summary>
        /// <param name="b"></param>
        /// <param name="result"></param>
        public void checkedFaces(BoundingSphere b, LinkedList<Face> result)
        {
            LinkedList<BspNode> toProcess = new LinkedList<BspNode>();
            toProcess.AddLast(mRoot);

            while (toProcess.Count > 0)
            {
                BspNode curNode = toProcess.First.Value;
                toProcess.RemoveFirst();

                if (curNode.separatingPlane.Normal.X == 0.0f &&
                    curNode.separatingPlane.Normal.Y == 0.0f &&
                    curNode.separatingPlane.Normal.Z == 0.0f &&
                    curNode.separatingPlane.D == 0.0f)
                {
                    foreach (Face f in curNode.faces)
                        result.AddLast(f);

                }

                else
                {
                    PlaneIntersectionType side = curNode.separatingPlane.Intersects(b);

                    if (side == PlaneIntersectionType.Back) toProcess.AddLast(curNode.neg);
                    else if (side == PlaneIntersectionType.Front) toProcess.AddLast(curNode.pos);
                    else
                    {
                        toProcess.AddLast(curNode.pos);
                        toProcess.AddLast(curNode.neg);
                    }
                }
            }
        }
开发者ID:xboxlife,项目名称:xna-bounce,代码行数:40,代码来源:BspTree.cs


示例17: RayPointingThroughBoundingSphereFromRightShouldBeIntersected

 public void RayPointingThroughBoundingSphereFromRightShouldBeIntersected()
 {
     var boundingSphere = new BoundingSphere(new Vector(0, 0, 0), 1);
     var ray = new Ray(new Vector(10, 0, 0), new Vector(-1, 0, 0));
     var result = ray.Intersects(boundingSphere);
     Assert.That(result, Is.Not.Null);
 }
开发者ID:petriw,项目名称:Balder,代码行数:7,代码来源:RayTests.cs


示例18: DrawSphereSpikes

        public static void DrawSphereSpikes(BoundingSphere sphere, GraphicsDevice device, BasicEffect basicEffect, Matrix worldMatrix, Matrix viewMatrix, Matrix projectionMatrix)
        {
            Vector3 up = sphere.Center + sphere.Radius * Vector3.Up;
            Vector3 down = sphere.Center + sphere.Radius * Vector3.Down;
            Vector3 right = sphere.Center + sphere.Radius * Vector3.Right;
            Vector3 left = sphere.Center + sphere.Radius * Vector3.Left;
            Vector3 forward = sphere.Center + sphere.Radius * Vector3.Forward;
            Vector3 back = sphere.Center + sphere.Radius * Vector3.Backward;

            VertexPositionColor[] sphereLineVertices = new VertexPositionColor[6];
            sphereLineVertices[0] = new VertexPositionColor(up, Color.White);
            sphereLineVertices[1] = new VertexPositionColor(down, Color.White);
            sphereLineVertices[2] = new VertexPositionColor(left, Color.White);
            sphereLineVertices[3] = new VertexPositionColor(right, Color.White);
            sphereLineVertices[4] = new VertexPositionColor(forward, Color.White);
            sphereLineVertices[5] = new VertexPositionColor(back, Color.White);

            basicEffect.World = worldMatrix;
            basicEffect.View = viewMatrix;
            basicEffect.Projection = projectionMatrix;
            basicEffect.VertexColorEnabled = true;
            foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
            {
                pass.Apply();
               // device.VertexDeclaration = new VertexDeclaration(device, VertexPositionColor.VertexElements);
                device.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.LineList, sphereLineVertices, 0, 3);
            }
        }
开发者ID:vvolkgang,项目名称:WarZ,代码行数:28,代码来源:XNAUtils.cs


示例19: Intersect

 public List<Actor> Intersect(BoundingSphere sphere)
 {
     UpdateDirty();
     var result = new List<Actor>();
     Root.Intersect(ref sphere, result);
     return result;
 }
开发者ID:Ramzawulf,项目名称:unityassets,代码行数:7,代码来源:OCTree.cs


示例20: Render

        public static void Render(BoundingSphere sphere,
                                  GraphicsDevice graphicsDevice,
                                  Matrix view,
                                  Matrix projection,
                                  Color color,
                                  Guid id)
        {
            var subscription = Subscriptions[id];

            graphicsDevice.SetVertexBuffer(subscription.VertexBuffer);
            subscription.BasicEffect.World = Matrix.CreateScale(sphere.Radius)*
                                                   Matrix.CreateTranslation(sphere.Center);
            subscription.BasicEffect.View = view;
            subscription.BasicEffect.Projection = projection;
            subscription.BasicEffect.DiffuseColor = color.ToVector3();

            foreach (var pass in subscription.BasicEffect.CurrentTechnique.Passes)
            {
                pass.Apply();
                graphicsDevice.DrawPrimitives(PrimitiveType.LineStrip, 0, SphereResolution);
                graphicsDevice.DrawPrimitives(PrimitiveType.LineStrip,
                                              SphereResolution + 1,
                                              SphereResolution);
                graphicsDevice.DrawPrimitives(PrimitiveType.LineStrip,
                                              (SphereResolution + 1)*2,
                                              SphereResolution);
            }
        }
开发者ID:naighes,项目名称:AsteroidChallenge,代码行数:28,代码来源:BoundingSphereRenderer.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# BoundingSphereD类代码示例发布时间:2022-05-24
下一篇:
C# BoundingRectangle类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap