public override void LoadContent() { // Load mesh mesh = new SpherePrimitive(1.0f, 50); // Load effects earthVertexShader = VertexShader.FromStream(GraphicsDeviceManager.Current.GraphicsDevice, Application.GetResourceStream(new Uri(@"/SLARToolKit3DSample;component/Shaders/EarthVS.vs", UriKind.Relative)).Stream); earthPixelShader = PixelShader.FromStream(GraphicsDeviceManager.Current.GraphicsDevice, Application.GetResourceStream(new Uri(@"/SLARToolKit3DSample;component/Shaders/EarthPS.ps", UriKind.Relative)).Stream); atmosphereVertexShader = VertexShader.FromStream(GraphicsDeviceManager.Current.GraphicsDevice, Application.GetResourceStream(new Uri(@"/SLARToolKit3DSample;component/Shaders/AtmosphereVS.vs", UriKind.Relative)).Stream); cloudsPixelShader = PixelShader.FromStream(GraphicsDeviceManager.Current.GraphicsDevice, Application.GetResourceStream(new Uri(@"/SLARToolKit3DSample;component/Shaders/CloudsPS.ps", UriKind.Relative)).Stream); lowerAtmospherePixelShader = PixelShader.FromStream(GraphicsDeviceManager.Current.GraphicsDevice, Application.GetResourceStream(new Uri(@"/SLARToolKit3DSample;component/Shaders/AtmosphereLowerPS.ps", UriKind.Relative)).Stream); upperAtmospherePixelShader = PixelShader.FromStream(GraphicsDeviceManager.Current.GraphicsDevice, Application.GetResourceStream(new Uri(@"/SLARToolKit3DSample;component/Shaders/AtmosphereUpperPS.ps", UriKind.Relative)).Stream); upperAtmosphereVertexShader = VertexShader.FromStream(GraphicsDeviceManager.Current.GraphicsDevice, Application.GetResourceStream(new Uri(@"/SLARToolKit3DSample;component/Shaders/AtmosphereUpperVS.vs", UriKind.Relative)).Stream); // Load textures atmosphereTexture = ContentManager.LoadBitmapAndMipFromResource("Textures/Earth/EarthAtmosphere.png"); cloudTexture = ContentManager.LoadBitmapAndMipFromResource("Textures/Earth/EarthClouds.png"); dayTexture = ContentManager.LoadBitmapAndMipFromResource("Textures/Earth/EarthDay.jpg"); maskTexture = ContentManager.LoadBitmapAndMipFromResource("Textures/Earth/EarthMask.png"); nightTexture = ContentManager.LoadBitmapAndMipFromResource("Textures/Earth/EarthNight.png"); nightLightsTexture = ContentManager.LoadBitmapAndMipFromResource("Textures/Earth/EarthNightLights.png"); normalTexture = ContentManager.LoadBitmapAndMipFromResource("Textures/Earth/EarthNormal.jpg"); // Set initial state depthState = new DepthStencilState { DepthBufferEnable = true, DepthBufferWriteEnable = true, DepthBufferFunction = CompareFunction.LessEqual }; cloudBlendState = new BlendState() { ColorSourceBlend = Blend.SourceAlpha, AlphaSourceBlend = Blend.SourceAlpha, ColorDestinationBlend = Blend.One, AlphaDestinationBlend = Blend.One }; atmosphereBlendState = new BlendState() { ColorSourceBlend = Blend.SourceAlpha, AlphaSourceBlend = Blend.SourceAlpha, ColorDestinationBlend = Blend.One, AlphaDestinationBlend = Blend.One }; // Load Moon data Moon.LoadContent(); }
public override void LoadContent() { // Load mesh mesh = new SpherePrimitive(0.2f, 50); // Load effects moonVertexShader = VertexShader.FromStream(GraphicsDeviceManager.Current.GraphicsDevice, Application.GetResourceStream(new Uri(@"/SLARToolKit3DSample;component/Shaders/MoonVS.vs", UriKind.Relative)).Stream); moonPixelShader = PixelShader.FromStream(GraphicsDeviceManager.Current.GraphicsDevice, Application.GetResourceStream(new Uri(@"/SLARToolKit3DSample;component/Shaders/MoonPS.ps", UriKind.Relative)).Stream); // Load textures moonTexture = ContentManager.LoadBitmapAndMipFromResource("Textures/Moon/moon.jpg"); moonNormalTexture = ContentManager.LoadBitmapAndMipFromResource("Textures/Moon/moon_normal.jpg"); // Set initial state depthState = new DepthStencilState { DepthBufferEnable = true, DepthBufferWriteEnable = true, DepthBufferFunction = CompareFunction.LessEqual }; }
/// <summary> /// Initializes the 3D scene : loads the shaders and initializes the visuals. /// </summary> public void Initialize() { //try //{ Helper3D.Check3DAvailability(); GraphicsDevice graphicsDevice = Helper3D.GraphicsDevice; Stream shaderStream = Application.GetResourceStream(new Uri(@"Perspective.Wpf3DX;component/Wpf3DX/Shaders/Perspective.VertexShader", UriKind.Relative)).Stream; _vertexShader = VertexShader.FromStream(graphicsDevice, shaderStream); shaderStream = Application.GetResourceStream(new Uri(@"Perspective.Wpf3DX;component/Wpf3DX/Shaders/Perspective.PixelShader", UriKind.Relative)).Stream; _pixelShader = PixelShader.FromStream(graphicsDevice, shaderStream); InvalidateLights(); _camera.InvalidateView(); foreach (var visual in _models) { visual.Initialize(this, Matrix.Identity); } //} //catch (Exception e) //{ // MessageBox.Show(e.Message, e.GetType().ToString(), MessageBoxButton.OK); //} }
public override void LoadContent() { // Load mesh mesh = new SpherePrimitive(1.5f, 50); // Load effects sunVertexShader = VertexShader.FromStream(GraphicsDeviceManager.Current.GraphicsDevice, Application.GetResourceStream(new Uri(@"/SLARToolKit3DSample;component/Shaders/SunVS.vs", UriKind.Relative)).Stream); sunPixelShader = PixelShader.FromStream(GraphicsDeviceManager.Current.GraphicsDevice, Application.GetResourceStream(new Uri(@"/SLARToolKit3DSample;component/Shaders/SunPS.ps", UriKind.Relative)).Stream); refractionPixelShader = PixelShader.FromStream(GraphicsDeviceManager.Current.GraphicsDevice, Application.GetResourceStream(new Uri(@"/SLARToolKit3DSample;component/Shaders/RefractionPS.ps", UriKind.Relative)).Stream); // Load textures sunTexture = ContentManager.LoadBitmapAndMipFromResource("Textures/Sun/Sun.jpg"); gradientTexture = ContentManager.LoadBitmapAndMipFromResource("Textures/Sun/FireGradient.png"); turbulence1Texture = ContentManager.LoadBitmapAndMipFromResource("Textures/Sun/Turbulence1.png"); turbulence2Texture = ContentManager.LoadBitmapAndMipFromResource("Textures/Sun/Turbulence2.png"); depthState = new DepthStencilState { DepthBufferEnable = true, DepthBufferWriteEnable = true, DepthBufferFunction = CompareFunction.LessEqual }; }