Solar Wind 3D Sample

This sample for Silverilght 5 uses the new 3D features to draw the Earth with day and night transitions, atmosphere layers, and population density overlays. It demonstrates advanced concepts like mipmaps, texture blending, multiple drawing passes, sampler states...

C# (10.4 MB)
 
 
 
 
 
4.4 Star
(8)
9,131 times
Add to favorites
9/12/2011
E-mail Twitter del.icio.us Digg Facebook
// ===================================================================================
//  Copyright (c) Microsoft Corporation.  All rights reserved.
//  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
//  OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
//  LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
//  FITNESS FOR A PARTICULAR PURPOSE.
// ===================================================================================
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace SolarWind
{
    /// <summary>
    /// Current frame scene time. May pass faster or slower than realtime.
    /// </summary>
    public class SceneTime
    {
        public TimeSpan DeltaTime { get; set; }
        public TimeSpan TotalTime { get; set; }

        public SceneTime()
        {
            DeltaTime = TimeSpan.FromSeconds(0.0);
            TotalTime = TimeSpan.FromSeconds(0.0);
        }

        public SceneTime(DrawEventArgs args)
        {
            DeltaTime = args.DeltaTime;
            TotalTime = args.TotalTime;
        }
    }

    /// <summary>
    /// Represents the 3D scene. Manages the camera (view / projection)
    /// transforms as well as draws scene models.
    /// </summary>
    public class Scene
    {
        // The camera to use in the scene
        Camera camera = new Camera();

        // The earth model
        Earth earth = new Earth();

        public Scene()
        {
        }

        public Camera Camera
        {
            get
            {
                return camera;
            }
        }

        public Earth Earth
        {
            get
            {
                return earth;
            }
        }        

        /// <summary>
        /// Loads content and resources
        /// </summary>
        public void LoadContent()
        {
            earth.LoadContent();
        }

        /// <summary>
        /// Called every frame to draw the scene
        /// </summary>
        /// <param name="graphicsDevice">The device to draw with</param>
        /// <param name="time">The time values for the scene</param>
        public void Draw(GraphicsDevice graphicsDevice, SceneTime time)
        {
            // clear the existing render target
            graphicsDevice.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.Transparent, 1.0f, 0);

            // draw the earth
            earth.Draw(graphicsDevice, time, camera);
        }
    }
}