Exemplo n.º 1
0
        protected override void LoadContent()
        {
            Window.Title = "Planet Sample";
            Renderer.CurrentCamera.Position = new Vector3(0, 0, 750);

            Sphere planet = new Sphere("Earth", 100, 100, 200);

            planet.Material = ContentManager.Load <Material>("Materials//PlanetMaterial.tem");

            planet.Material.AddLogic(new PlanetLogic());
            planet.Rotation = Quaternion.FromAngleAxis(MathHelper.ToRadians(-90.0f), Vector3.UnitX);
            planet.SceneHints.RenderBucketType = RenderBucketType.Transparent;
            planet.ComputeTangentBasis();
            planet.SetModelBound(new BoundingSphere());
            material = planet.Material;

            Node orbit = new Node("Orbit");

            orbit.AddChild(planet);
            orbit.AddController(new RotateController(Vector3.UnitY, .75f));
            RootNode.AddChild(orbit);
            orbit.Rotation = Quaternion.FromAngleAxis(MathHelper.DegreesToRadians * 45, Vector3.UnitY);

            DirectionalLight dl = new DirectionalLight();

            dl.Direction = new Vector3(-.755f, -.755f, -.755f);
            planet.AddLight(dl);

            //TODO: The planet only renders properly if it's centered at the origin
            //orbit.Translation = new Vector3(0, -500, 0);
            Box sky = new Box("Space", Vector3.Zero, 100, 100, 100);

            sky.SceneHints.RenderBucketType = RenderBucketType.PreBucket;
            sky.Material = ContentManager.Load <Material>("Materials//SpaceSkybox.tem");

            RootNode.AddChild(sky);
        }