Esempio n. 1
0
        void GenerateObjects(Random rnd)
        {
            UInt16 Id = 0;

            float RndDeg()
            {
                return(MathHelper.ToRadians(rnd.Next(0, 360)));
            }

            int count = rnd.Next(30, 30);

            for (int i = 0; i < count; i++)
            {
                Vector3 location = new Vector3
                                   (
                    rnd.Next(-500, 500),
                    rnd.Next(-200, 200),
                    rnd.Next(-500, 500)
                                   );
                Quat rotation = Quat.CreateFromYawPitchRoll
                                (
                    RndDeg(),
                    RndDeg(),
                    RndDeg()
                                );
                float scale;
                if (rnd.Next(5) == 0)
                {
                    scale = 10 + (float)(rnd.NextDouble() * 20);
                }
                else
                {
                    scale = 1 + (float)(rnd.NextDouble() * 4);
                }
                int ObjectType = rnd.Next(2, 5);

                Objects.Add(Guid.NewGuid(), new SpaceObject()
                {
                    CollisionMesh = (ListOf_CollisionMesh)ObjectType,
                    Location      = location,
                    Rotation      = rotation,
                    Scale         = new Vector3(scale),
                    // Scale = new Vector3(1),
                    Id = Id++
                });
            }

            Objects.Add(Guid.NewGuid(), new SpaceObject()
            {
                CollisionMesh = ListOf_CollisionMesh.XQ6,
                Location      = new Vector3(0, 0, 1000),
                Rotation      = Quat.CreateFromYawPitchRoll(0, 0, MathHelper.ToRadians(45)),
                Scale         = Vector3.One,
                Id            = Id++
            });
        }