Example #1
0
        private static void CreateEarthAndMoonScene(float speed, float orbitDistanceMultiplier, float planetScaleMultiplier, Renderer renderer)
        {
            // Create and setup material
            SimpleMaterial baseMaterial = new SimpleMaterial
            {
                VertexShaderPath       = "Shaders.fx",
                VertexShaderEntryPoint = "VS",
                VertexShaderProfile    = "vs_5_0",
                PixelShaderPath        = "Shaders.fx",
                PixelShaderEntryPoint  = "PS",
                PixelShaderProfile     = "ps_5_0",
            };

            baseMaterial.Initialize(renderer.device);
            baseMaterial.pixelShaderData.LightPos      = new Vector4(5, 3, 5, 1);
            baseMaterial.pixelShaderData.EmissionColor = new Vector4(0.1f, 0.1f, 0.1f, 1);


            // Load model
            ModelLoader modelLoader = new ModelLoader(renderer.device);
            Model       sphere      = modelLoader.LoadRelative("Assets\\Planets\\sphere.obj");

            // Create scene objects
            var earth = CreatePlanet(0f * speed, 0f * orbitDistanceMultiplier, 1f * planetScaleMultiplier, baseMaterial, new Vector4(0.2f, 0.2f, 0.8f, 1), sphere);

            CreatePlanet(1 / 0.1f * speed, 1f * orbitDistanceMultiplier, 0.4f, baseMaterial, new Vector4(0.4f, 0.4f, 0.4f, 1), sphere, earth.transform);
        }
Example #2
0
        private static void CreateSolarSystemScene(float speed, float orbitDistanceMultiplier, float planetScaleMultiplier, Renderer renderer)
        {
            // Create and setup material
            SimpleMaterial baseMaterial = new SimpleMaterial
            {
                VertexShaderPath       = "Shaders.fx",
                VertexShaderEntryPoint = "VS",
                VertexShaderProfile    = "vs_5_0",
                PixelShaderPath        = "Shaders.fx",
                PixelShaderEntryPoint  = "PS",
                PixelShaderProfile     = "ps_5_0",
            };

            baseMaterial.Initialize(renderer.device);
            baseMaterial.pixelShaderData.LightPos      = new Vector4(0, 0, 0, 1);
            baseMaterial.pixelShaderData.EmissionColor = new Vector4(0.1f, 0.1f, 0.1f, 1);


            // Load model
            ModelLoader modelLoader = new ModelLoader(renderer.device);
            Model       sphere      = modelLoader.LoadRelative("Assets\\Planets\\sphere.obj");

            // Create scene objects

            // Sun
            SceneObject sunObject = new SceneObject();

            sunObject.model = sphere;
            SimpleMaterial sunMaterial = baseMaterial.CreateInstanceTyped();

            sunMaterial.pixelShaderData.DiffuseColor  = new Vector4(0.92f, 0.72f, 0.2f, 1);
            sunMaterial.pixelShaderData.EmissionColor = new Vector4(0.92f, 0.8f, 0.2f, 1);
            sunObject.material = sunMaterial;

            // Mercury
            CreatePlanet(4f * speed, 0.36f * orbitDistanceMultiplier, 0.38f * planetScaleMultiplier, baseMaterial, new Vector4(0.7f, 0.6f, 0.5f, 1), sphere);

            // Venus
            CreatePlanet(1.3f * speed, 0.67f * orbitDistanceMultiplier, 0.95f * planetScaleMultiplier, baseMaterial, new Vector4(0.96f, 0.48f, 0.04f, 1), sphere);

            // Earth + Moon
            var earth = CreatePlanet(1f * speed, 0.93f * orbitDistanceMultiplier, 1f * planetScaleMultiplier, baseMaterial, new Vector4(0.2f, 0.2f, 0.8f, 1), sphere);

            CreatePlanet(1 / 0.1f * speed, 1f * orbitDistanceMultiplier, 0.8f * planetScaleMultiplier, baseMaterial, new Vector4(0.4f, 0.4f, 0.4f, 1), sphere, earth.transform);

            // Mars
            CreatePlanet(0.45f * speed, 1.41f * orbitDistanceMultiplier, 0.53f * planetScaleMultiplier, baseMaterial, new Vector4(0.73f, 0.13f, 0.04f, 1), sphere);

            // Jupiter
            CreatePlanet(1 / 11.9f * speed, 2.6f * orbitDistanceMultiplier, 11.12f * planetScaleMultiplier, baseMaterial, new Vector4(0.77f, 0.66f, 0.45f, 1), sphere);

            // Saturn
            CreatePlanet(1 / 29.5f * speed, 3.7f * orbitDistanceMultiplier, 9.45f * planetScaleMultiplier, baseMaterial, new Vector4(0.68f, 0.54f, 0.36f, 1), sphere);

            // Uranus
            CreatePlanet(1 / 84f * speed, 4.4f * orbitDistanceMultiplier, 4.00f * planetScaleMultiplier, baseMaterial, new Vector4(0.55f, 0.83f, 0.97f, 1), sphere);

            // Neptune
            CreatePlanet(1 / 165f * speed, 5.2f * orbitDistanceMultiplier, 3.88f * planetScaleMultiplier, baseMaterial, new Vector4(0.38f, 0.50f, 0.83f, 1), sphere);
        }