public override void LoadContent() { //_sphereMesh = _content.Load<Model>("Meshes/Sphere"); _planetShadowMask = ServiceLocator.Instance.GetService<ISpriteManagerService>().CreateSpriteComponent("planetshadowmask"); _projectionMatrix = Matrix.CreateOrthographic(_device.Viewport.Width, _device.Viewport.Height, 1.0f, 10000.0f); _sphereModel = _content.Load<Model>("Meshes/uvsphere_high_lod"); _sphereModelLowPoly = _content.Load<Model>("Meshes/uvsphere"); _sunEffect = new BasicEffect(_device); //var sunEffect = (BasicEffect)_sphereModel.Meshes[0].Effects[0]; _sunEffect.World = Matrix.Identity; _sunEffect.Projection = _projectionMatrix; _sunEffect.Texture = _content.Load<Texture2D>("Textures/spaceobjects/sun-white"); _sunEffect.TextureEnabled = true; _sunEffect.AmbientLightColor = Vector3.Zero; _sunEffect.EmissiveColor = Vector3.One; _sunEffect.SpecularPower = 0; _sunEffect.DiffuseColor = Vector3.Zero; _sunEffect.PreferPerPixelLighting = true; _planetEffect = new BasicEffect(_device); _planetEffect.Texture = _content.Load<Texture2D>("Textures/spaceobjects/rock1"); _planetEffect.LightingEnabled = true; _planetEffect.TextureEnabled = true; _planetEffect.AmbientLightColor = new Vector3(0.1f); _planetEffect.EmissiveColor = Vector3.Zero; _planetEffect.SpecularPower = 0.1f; _planetEffect.DiffuseColor = Vector3.One; _planetEffect.Projection = _projectionMatrix; _planetEffect.PreferPerPixelLighting = true; _haloModel = _content.Load<Model>("Meshes/halo"); _haloEffect = (BasicEffect)_haloModel.Meshes[0].Effects[0]; _haloEffect.Texture = _content.Load<Texture2D>("Textures/spaceobjects/halo"); _haloEffect.TextureEnabled = true; _haloEffect.PreferPerPixelLighting = true; _haloEffect.SpecularPower = 0; _haloEffect.AmbientLightColor = Vector3.Zero; _haloEffect.EmissiveColor = Vector3.One; _haloEffect.DiffuseColor = Vector3.Zero; _haloEffect.Projection = _projectionMatrix; _starGlowEffect = new BasicEffect(_device); _starGlowEffect.Texture = _content.Load<Texture2D>("Textures/spaceobjects/starglow"); _starGlowEffect.TextureEnabled = true; _starGlowEffect.PreferPerPixelLighting = true; _starGlowEffect.SpecularPower = 0; _starGlowEffect.AmbientLightColor = Vector3.Zero; _starGlowEffect.EmissiveColor = Vector3.One; _starGlowEffect.DiffuseColor = Vector3.Zero; _starGlowEffect.Projection = _projectionMatrix; }
public void Draw(SpriteComponent sprite, ref Matrix transform, Color[] colors, Vector3[] normals) { Vertex3CTN vtx = new Vertex3CTN(); if (colors == null) throw new ArgumentException(nameof(colors)); if(normals == null) throw new ArgumentException(nameof(normals)); var tex = sprite.Texture; Vector2 texCoordLT = tex.GetUV(sprite.TextureRect.Left, sprite.TextureRect.Top); Vector2 texCoordBR = tex.GetUV(sprite.TextureRect.Right, sprite.TextureRect.Bottom); vtx.Position = Vector3.Zero; vtx.TextureCoords = texCoordLT; vtx.Color = colors[0]; vtx.Normal = normals[0]; _quadVertices[0] = vtx; vtx.Position = new Vector3(0, sprite.TextureRect.Height, 0); vtx.TextureCoords = new Vector2(texCoordLT.X, texCoordBR.Y); vtx.Color = colors[1]; vtx.Normal = normals[1]; _quadVertices[1] = vtx; vtx.Position = new Vector3(sprite.TextureRect.Width, 0, 0); vtx.TextureCoords = new Vector2(texCoordBR.X, texCoordLT.Y); vtx.Color = colors[2]; vtx.Normal = normals[2]; _quadVertices[2] = vtx; vtx.Position = new Vector3(sprite.TextureRect.Width, sprite.TextureRect.Height, 0); vtx.TextureCoords = texCoordBR; vtx.Color = colors[3]; vtx.Normal = normals[3]; _quadVertices[3] = vtx; DrawVertices(tex, _quadVertices, _quadIndices, ref transform); }
public void Draw(SpriteComponent sprite, ref Matrix transform, Color? color=null, Vector3? normal=null) { Vertex3CTN vtx; vtx.Color = color ?? Color.White; vtx.Normal = normal ?? Vector3.Forward; var tex = sprite.Texture; Vector2 texCoordLT = tex.GetUV(sprite.TextureRect.Left, sprite.TextureRect.Top); Vector2 texCoordBR = tex.GetUV(sprite.TextureRect.Right, sprite.TextureRect.Bottom); vtx.Position = Vector3.Zero; vtx.TextureCoords = texCoordLT; _quadVertices[0] = vtx; vtx.Position = new Vector3(0, sprite.TextureRect.Height, 0); vtx.TextureCoords = new Vector2(texCoordLT.X, texCoordBR.Y); _quadVertices[1] = vtx; vtx.Position = new Vector3(sprite.TextureRect.Width, 0, 0); vtx.TextureCoords = new Vector2(texCoordBR.X, texCoordLT.Y); _quadVertices[2] = vtx; vtx.Position = new Vector3(sprite.TextureRect.Width, sprite.TextureRect.Height, 0); vtx.TextureCoords = texCoordBR; _quadVertices[3] = vtx; DrawVertices(tex, _quadVertices, _quadIndices, ref transform); }