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


C# BoundingSphere.Transform方法代码示例

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


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

示例1: VertexInsideBoundingSphereCheck

        public void VertexInsideBoundingSphereCheck()
        {
            var transform = Matrix.CreateScale(3.0f)*Matrix.CreateRotationY(MathHelper.PiOver4);
            var sphere = new BoundingSphere(Vector3.Zero, 1.0f);
            var transformedSphere = sphere.Transform(transform);

            var triangleOut = new Triangle(new Vector3(2.1f, 2.1f, 0.0f),
                                           new Vector3(2.1f, 0.0f, 0.0f),
                                           new Vector3(4.2f, 2.1f, 0.0f),
                                           String.Empty);
            Assert.False(triangleOut.HasAtLeastOnPointInsideBoundingSphere(sphere));

            var transformedTriangleOut = new Triangle(Vector3.Transform(triangleOut.Point0, transform),
                                                      Vector3.Transform(triangleOut.Point1, transform),
                                                      Vector3.Transform(triangleOut.Point2, transform),
                                                      String.Empty);
            Assert.False(transformedTriangleOut.HasAtLeastOnPointInsideBoundingSphere(transformedSphere));

            var triangleIn = new Triangle(new Vector3(2.1f, 2.1f, 0.0f),
                                          new Vector3(0.9f, 0.0f, 0.0f), // It's in!
                                          new Vector3(4.2f, 2.1f, 0.0f),
                                          String.Empty);
            Assert.True(triangleIn.HasAtLeastOnPointInsideBoundingSphere(sphere));

            var transformedTriangleIn = new Triangle(Vector3.Transform(triangleIn.Point0, transform),
                                                     Vector3.Transform(triangleIn.Point1, transform),
                                                     Vector3.Transform(triangleIn.Point2, transform),
                                                     String.Empty);
            Assert.True(transformedTriangleIn.HasAtLeastOnPointInsideBoundingSphere(transformedSphere));
        }
开发者ID:naighes,项目名称:AsteroidChallenge,代码行数:30,代码来源:TriangleExtensionsTests.cs

示例2: TransformingWithOnlyTranslationShouldPositionSphereCorrectly

 public void TransformingWithOnlyTranslationShouldPositionSphereCorrectly()
 {
     var boundingSphere = new BoundingSphere(Vector.Zero, 1);
     var position = new Vector(10, 5, 3);
     var matrix = Matrix.CreateTranslation(position);
     var transformedBoundingSphere = boundingSphere.Transform(matrix);
     Assert.That(transformedBoundingSphere.Center, Is.EqualTo(position));
 }
开发者ID:Conn,项目名称:Balder,代码行数:8,代码来源:BoundingSphereTests.cs

示例3: TransormingWith90DegreesRotationAroundYAndTranslationShouldPositionSphereCorrectly

 public void TransormingWith90DegreesRotationAroundYAndTranslationShouldPositionSphereCorrectly()
 {
     var boundingSphere = new BoundingSphere(Vector.Zero, 1);
     var position = new Vector(10, 5, 3);
     var translationMatrix = Matrix.CreateTranslation(position);
     var rotationMatrix = Matrix.CreateRotationY(90f);
     var matrix = translationMatrix * rotationMatrix;
     var transformedBoundingSphere = boundingSphere.Transform(matrix);
     var expectedPosition = position*rotationMatrix;
     Assert.That(transformedBoundingSphere.Center, Is.EqualTo(expectedPosition));
 }
开发者ID:Conn,项目名称:Balder,代码行数:11,代码来源:BoundingSphereTests.cs

示例4: GetGlobalBoundingSphere

 public static BoundingSphere GetGlobalBoundingSphere( Model model )
 {
     Matrix[] absoluteBoneTransforms = new Matrix[model.Bones.Count];
     model.CopyAbsoluteBoneTransformsTo( absoluteBoneTransforms );
     BoundingSphere globalBoundingSphere = new BoundingSphere();
     foreach( ModelMesh mesh in model.Meshes) {
         CustomMeshData meshData = mesh.Tag as CustomMeshData;
         BoundingSphere meshBoundingSphere = new BoundingSphere();
         if ( meshData != null ) {
             meshBoundingSphere = meshData.BoundingSphere;
         } else {
             meshBoundingSphere = mesh.BoundingSphere;
         }
         meshBoundingSphere = meshBoundingSphere.Transform( absoluteBoneTransforms[mesh.ParentBone.Index] );
         globalBoundingSphere = BoundingSphere.CreateMerged( globalBoundingSphere, meshBoundingSphere );
     }
     return globalBoundingSphere;
 }
开发者ID:tgorkin,项目名称:XEngine,代码行数:18,代码来源:ModelUtils.cs

示例5: GetBoundingSphere

 public BoundingSphere GetBoundingSphere()
 {
     BoundingSphere sphere = new BoundingSphere(new Vector3(0.0f, 0.0f, 0.0f), 1.0f);
     sphere = sphere.Transform(GetWorld());
     return sphere;
 }
开发者ID:Ryuzaki,项目名称:RVTN,代码行数:6,代码来源:Sprite3D.cs

示例6: Update

        internal void Update(TransformComponent transformComponent, ref Matrix worldMatrix)
        {
            if (!Enabled || model == null)
                return;

            // Check if scaling is negative
            var up = Vector3.Cross(worldMatrix.Right, worldMatrix.Forward);
            bool isScalingNegative = Vector3.Dot(worldMatrix.Up, up) < 0.0f;

            // Make sure skeleton is up to date
            CheckSkeleton();
            if (skeleton != null)
            {
                // Update model view hierarchy node matrices
                skeleton.NodeTransformations[0].LocalMatrix = worldMatrix;
                skeleton.NodeTransformations[0].IsScalingNegative = isScalingNegative;
                skeleton.UpdateMatrices();
            }

            // Update the bounding sphere / bounding box in world space
            BoundingSphere = BoundingSphere.Empty;
            BoundingBox = BoundingBox.Empty;
            bool modelHasBoundingBox = false;

            for (int meshIndex = 0; meshIndex < Model.Meshes.Count; meshIndex++)
            {
                var mesh = Model.Meshes[meshIndex];
                var meshInfo = meshInfos[meshIndex];
                meshInfo.BoundingSphere = BoundingSphere.Empty;
                meshInfo.BoundingBox = BoundingBox.Empty;

                if (mesh.Skinning != null && skeleton != null)
                {
                    bool meshHasBoundingBox = false;
                    var bones = mesh.Skinning.Bones;

                    // For skinned meshes, bounding box is union of the bounding boxes of the unskinned mesh, transformed by each affecting bone.
                    for (int boneIndex = 0; boneIndex < bones.Length; boneIndex++)
                    {
                        var nodeIndex = bones[boneIndex].NodeIndex;
                        Matrix.Multiply(ref bones[boneIndex].LinkToMeshMatrix, ref skeleton.NodeTransformations[nodeIndex].WorldMatrix, out meshInfos[meshIndex].BlendMatrices[boneIndex]);

                        BoundingBox skinnedBoundingBox;
                        BoundingBox.Transform(ref mesh.BoundingBox, ref meshInfos[meshIndex].BlendMatrices[boneIndex], out skinnedBoundingBox);
                        BoundingSphere skinnedBoundingSphere;
                        BoundingSphere.Transform(ref mesh.BoundingSphere, ref meshInfos[meshIndex].BlendMatrices[boneIndex], out skinnedBoundingSphere);

                        if (meshHasBoundingBox)
                        {
                            BoundingBox.Merge(ref meshInfo.BoundingBox, ref skinnedBoundingBox, out meshInfo.BoundingBox);
                            BoundingSphere.Merge(ref meshInfo.BoundingSphere, ref skinnedBoundingSphere, out meshInfo.BoundingSphere);
                        }
                        else
                        {
                            meshHasBoundingBox = true;
                            meshInfo.BoundingSphere = skinnedBoundingSphere;
                            meshInfo.BoundingBox = skinnedBoundingBox;
                        }
                    }
                }
                else
                {
                    // If there is a skeleton, use the corresponding node's transform. Otherwise, fall back to the model transform.
                    var transform = skeleton != null ? skeleton.NodeTransformations[mesh.NodeIndex].WorldMatrix : worldMatrix;
                    BoundingBox.Transform(ref mesh.BoundingBox, ref transform, out meshInfo.BoundingBox);
                    BoundingSphere.Transform(ref mesh.BoundingSphere, ref transform, out meshInfo.BoundingSphere);
                }

                if (modelHasBoundingBox)
                {
                    BoundingBox.Merge(ref BoundingBox, ref meshInfo.BoundingBox, out BoundingBox);
                    BoundingSphere.Merge(ref BoundingSphere, ref meshInfo.BoundingSphere, out BoundingSphere);
                }
                else
                {
                    BoundingBox = meshInfo.BoundingBox;
                    BoundingSphere = meshInfo.BoundingSphere;
                    modelHasBoundingBox = true;
                }
            }
        }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:81,代码来源:ModelComponent.cs

示例7: UpdateBoundingSpheres

 public void UpdateBoundingSpheres()
 {
     Matrix[] worldTransforms = updatedModel.getWorldTransforms();
     for (int index = 0; index < skinnedSpheres.Length; index++)
     {
         SkinnedSphere source = skinnedSpheres[index];
         Vector3 center = new Vector3(source.Offset, 0, 0);
         BoundingSphere sphere = new BoundingSphere(center, source.Radius);
         int boneIndex = skinningData.BoneIndices[source.BoneName];
         boundingSpheres[index] = sphere.Transform(worldTransforms[boneIndex]);
     }
 }
开发者ID:DuxClarus,项目名称:Uat-Portfolio,代码行数:12,代码来源:ModelObject.cs

示例8: TransformSphere

 private void TransformSphere()
 {
     _transformed = BoundingSphere;
     _transformed = _transformed.Transform(_worldTransform);
 }
开发者ID:DavidBasarab,项目名称:KidsSpace,代码行数:5,代码来源:BoundingSphereTransformer.cs

示例9: Update

        protected override void Update(GameTime gameTime)
        {
            BoundingSphere sphere;
            model.Meshes[0].MeshParts[0].Effect = effect[ExcNum];
            for (int i = 0; i < NR_MODELS; i++)
            {

                sphere = new BoundingSphere();
                sphere = BoundingSphere.CreateMerged(sphere, model2[i].Meshes[0].BoundingSphere);

                InViewFrustum[i] = camera.InView(sphere.Transform(World2n[i]));
            }
            float timeStep = (float)gameTime.ElapsedGameTime.TotalSeconds * 60.0f;

            //Keyboard usage
            KeyboardState KeyState = Keyboard.GetState();

            //Change Rotation using  the 'left' and 'right' keys
            if (KeyState.IsKeyDown(Keys.Z))
            {
                rotationAmount = rotationAmount + timeStep / 100;
            }

            if (KeyState.IsKeyDown(Keys.G))
            {
                if (!Gpressed) { postGray = !postGray; }
                Gpressed = true;
            }
            if (KeyState.IsKeyUp(Keys.G)) { Gpressed = false; }

            if (KeyState.IsKeyDown(Keys.B))
            {
                if (!Bpressed) { postBlur = !postBlur; }
                Bpressed = true;
            }
            if (KeyState.IsKeyUp(Keys.B)) { Bpressed = false; }

            if (KeyState.IsKeyDown(Keys.X))
            {
                rotationAmount = rotationAmount - timeStep / 100;
            }

            if (KeyState.IsKeyDown(Keys.Space))
            {
                if (!SpacePressed) { ExcNum = (ExcNum + 1) % (maxExc + 1); }
                SpacePressed = true;
            }
            if (KeyState.IsKeyUp(Keys.Space)) { SpacePressed = false; }

            // Update Excersize
            model.Meshes[0].MeshParts[0].Effect = effect[ExcNum];
            // Update the window title
            Window.Title = "XNA Renderer | FPS: " + frameRateCounter.FrameRate;

            base.Update(gameTime);
        }
开发者ID:kriepy,项目名称:Graphics,代码行数:56,代码来源:Game1.cs

示例10: drawPlayer

        public void drawPlayer()
        {
            GraphicsDevice.RenderState.CullMode = CullMode.None;

            //Matrix newViewMatrix = Matrix.CreateLookAt(new Vector3(camX, 300.0f, 0.0f), new Vector3(camX, 0.0f, -1000.0f), new Vector3(0.0f, 1.0f, 0.0f));

            foreach (ModelMesh mesh in model.Meshes)
            {

                foreach (BasicEffect effect in mesh.Effects)
                {

                    effect.EnableDefaultLighting();
                    effect.Projection = projMatrix;
                    effect.View = viewMatrix;
                    effect.World = transforms[mesh.ParentBone.Index] * Matrix.CreateRotationY(MathHelper.ToRadians(rotation))
                                       * Matrix.CreateScale(100.0f) * Matrix.CreateTranslation(new Vector3(camX, 0.0f, -250.0f));
                    effect.Texture = carTexture;
                }
                playerSphere = mesh.BoundingSphere;
                playerSphere.Transform(transforms[mesh.ParentBone.Index]);
                playerSphere.Center = new Vector3(camX, 0.0f, -250.0f);
                playerSphere.Radius = (mesh.BoundingSphere.Radius * 250.0f);

                //Console.WriteLine(boundingSphere.Radius.ToString());
                //Render(boundingSphere, GraphicsDevice, viewMatrix, projMatrix, Color.SaddleBrown);
                mesh.Draw();
            }
        }
开发者ID:Jesse0Michael,项目名称:LifeWithoutTaxes2,代码行数:29,代码来源:sGameThree.cs

示例11: UpdateBoundingSpheres

        /// <summary>
        /// Updates the boundingSpheres array to match the current animation state.
        /// </summary>
        void UpdateBoundingSpheres()
        {
            // Look up the current world space bone positions.
            Matrix[] worldTransforms = animationPlayer.GetWorldTransforms();

            for (int i = 0; i < skinnedSpheres.Length; i++)
            {
                // Convert the SkinnedSphere description to a BoundingSphere.
                SkinnedSphere source = skinnedSpheres[i];
                Vector3 center = new Vector3(source.Offset, 0, 0);
                BoundingSphere sphere = new BoundingSphere(center, source.Radius);

                // Transform the BoundingSphere by its parent bone matrix,
                // and store the result into the boundingSpheres array.
                int boneIndex = skinningData.BoneIndices[source.BoneName];

                boundingSpheres[i] = sphere.Transform(worldTransforms[boneIndex]);
            }
        }
开发者ID:MayoTomale,项目名称:BNO055-project-moving-InMoov-hobot-hand-and-XNA-demo,代码行数:22,代码来源:SkinningSample.cs

示例12: UpdateBoundingVolume

 public virtual void UpdateBoundingVolume()
 {
     if (Model != null)
     {
         BoundingSphere = new BoundingSphere();
         foreach (var mesh in Model.Meshes)
         {
             BoundingSphere = BoundingSphere.CreateMerged(mesh.BoundingSphere.Transform(mesh.ParentBone.Transform), BoundingSphere);
         }
         BoundingSphere = BoundingSphere.Transform(Matrix.CreateScale(Scale) * Matrix.CreateTranslation(Position));
     }
 }
开发者ID:MintL,项目名称:datx02-rally,代码行数:12,代码来源:GameObject.cs

示例13: CollidesWith

        public bool CollidesWith(Model modelo1, Matrix mundo1, Model modelo2, Matrix mundo2)
        {
            // Loop through each ModelMesh in both objects and compare
            // all bounding spheres for collisions
            float aspectRatio = (float)device.Viewport.Width / device.Viewport.Height;
            foreach (ModelMesh myModelMeshes in modelo1.Meshes)
            {
                foreach (ModelMesh hisModelMeshes in modelo2.Meshes)
                {
                    BoundingSphere esfera1, esfera2;
                    //radio*155
                    Vector3 centro2 = hisModelMeshes.BoundingSphere.Center;
                    centro2.X -= 360;
                    esfera1= new BoundingSphere(myModelMeshes.BoundingSphere.Center,(myModelMeshes.BoundingSphere.Radius*300));
                    esfera2= new BoundingSphere(centro2,(hisModelMeshes.BoundingSphere.Radius*25));

                    BoundingSphereRenderer.Render(esfera1.Transform(mundo1), device, Matrix.CreateLookAt(cameraPosition, lookAt, Vector3.Up), Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f), aspectRatio, 1.0f, 100000.0f), Color.Blue);
                    BoundingSphereRenderer.Render(esfera2.Transform(mundo2), device, Matrix.CreateLookAt(cameraPosition, lookAt, Vector3.Up), Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f), aspectRatio, 1.0f, 100000.0f), Color.Red);

                    //BoundingBox caja =new BoundingBox(new Vector3(30f,99f,110f),posicionBlanco);

                    //BoundingBoxRenderer.Render(caja, device, Matrix.CreateLookAt(cameraPosition, lookAt, Vector3.Up), Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f), aspectRatio, 1.0f, 100000.0f), Color.Blue);

                    if (esfera1.Transform(
                        mundo1).Intersects(
                        esfera2.Transform(mundo2)))
                        return true;
                    /*if (myModelMeshes.BoundingSphere.Transform(
                        mundo1).Intersects(
                        hisModelMeshes.BoundingSphere.Transform(mundo2)))
                        return true;*/
                }
            }
            return false;
        }
开发者ID:AgusRumayor,项目名称:C-,代码行数:35,代码来源:Game1.cs

示例14: LoadModelBoundingSphere

        /// <summary>
        /// Loads the bounding sphere of the model into it's tag.
        /// </summary>
        private void LoadModelBoundingSphere()
        {
            completeBoundingSphere = new BoundingSphere();

            foreach (ModelMesh mesh in model.Meshes)
            {
                BoundingSphere origMeshSphere = mesh.BoundingSphere;
                BoundingSphere transMeshSphere = XNAUtils.TransformBoundingSphere(origMeshSphere,
                    originalTransforms[mesh.ParentBone.Index]);
                completeBoundingSphere =
                    BoundingSphere.CreateMerged(completeBoundingSphere, transMeshSphere);
            }

            model.Tag = completeBoundingSphere.Transform(Matrix.CreateScale(0.5f));
        }
开发者ID:bradleat,项目名称:trafps,代码行数:18,代码来源:DrawableModel.cs

示例15: SpheresIntersect

 private bool SpheresIntersect(Vector3 p1, BoundingSphere s1, Vector3 p2, BoundingSphere s2)
 {
     var shere1 = s1.Transform(Matrix.CreateTranslation(p1));
     var shere2 = s2.Transform(Matrix.CreateTranslation(p2));
     return shere1.Intersects(shere2);
 }
开发者ID:ChaosSlave51,项目名称:StarMelee,代码行数:6,代码来源:CollisionHelper.cs


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