Exemple #1
0
        private void CalculateWorlds()
        {
            groundWorld = Matrix.CreateWorld(Vector3.Zero, Vector3.UnitX,
                                             Vector3.Up) * Matrix.CreateScale(50.0f, 1.0f, 50.0f);

            playerPosition.Radius = player.Meshes[0].BoundingSphere.Radius;
            Matrix.CreateWorld(ref playerPosition.Center, ref unitX, ref up, out playerWorld);

            int     currentModel = 0;
            int     objectIndex  = 0;
            Vector3 position     = new Vector3();

            for (float x = -100.0f; x <= 100.0f; x += 20.0f)
            {
                for (float z = 0.0f; z <= 100.0f; z += 20.0f)
                {
                    position.X = x;
                    position.Z = z;
                    var shape = new ShapeInfo {
                        ModelIndex = currentModel
                    };
                    shape.Sphere.Center.X = x;
                    shape.Sphere.Center.Z = z;
                    shape.Sphere.Center.Y = models[currentModel].
                                            Meshes[0].BoundingSphere.Center.Y;
                    shape.Sphere.Radius = models[currentModel].Meshes[0].BoundingSphere.Radius;

                    Matrix.CreateWorld(ref position, ref unitX,
                                       ref up, out shape.World);
                    shapes[objectIndex] = shape;
                    objectIndex++;
                }
                currentModel++;
                if (currentModel >= models.Length)
                {
                    currentModel = 0;
                }
            }
        }
        private void CalculateWorlds()
        {
            groundWorld = Matrix.CreateWorld(Vector3.Zero, Vector3.UnitX,
               Vector3.Up) * Matrix.CreateScale(50.0f, 1.0f, 50.0f);

            playerPosition.Radius = player.Meshes[0].BoundingSphere.Radius;
            Matrix.CreateWorld(ref playerPosition.Center, ref unitX, ref up, out playerWorld);

            int currentModel = 0;
            int objectIndex = 0;
            Vector3 position = new Vector3();
            for (float x = -100.0f; x <= 100.0f; x += 20.0f)
            {
                for (float z = 0.0f; z <= 100.0f; z += 20.0f)
                {
                    position.X = x;
                    position.Z = z;
                    var shape = new ShapeInfo { ModelIndex = currentModel };
                    shape.Sphere.Center.X = x;
                    shape.Sphere.Center.Z = z;
                    shape.Sphere.Center.Y = models[currentModel].
                                                Meshes[0].BoundingSphere.Center.Y;
                    shape.Sphere.Radius = models[currentModel].Meshes[0].BoundingSphere.Radius;

                    Matrix.CreateWorld(ref position, ref unitX,
                        ref up, out shape.World);
                    shapes[objectIndex] = shape;
                    objectIndex++;
                }
                currentModel++;
                if (currentModel >= models.Length)
                    currentModel = 0;
            }
        }