public void Draw(Camera camera) { Matrix[] transforms = new Matrix[model.Bones.Count]; model.CopyAbsoluteBoneTransformsTo(transforms); foreach (ModelMesh mesh in model.Meshes) { foreach (BasicEffect b in mesh.Effects) { b.EnableDefaultLighting(); b.Projection = camera.projection; b.View = camera.view; b.World = getMyWorld() * mesh.ParentBone.Transform; } mesh.Draw(); } }
public void DrawParticles(Camera camera) { graphicsDevice.SetVertexBuffer(particleVertexBuffer); if (endOfLiveParticlesIndex - endOfDeadParticlesIndex > 0) { for (int i = endOfDeadParticlesIndex; i < endOfLiveParticlesIndex; i++) { particleEffect.Parameters["WorldViewProjection"].SetValue(camera.view*camera.projection); particleEffect.Parameters["particleColor"].SetValue(vertexColorArray[i].ToVector4()); //draw particles foreach (EffectPass pass in particleEffect.CurrentTechnique.Passes) { pass.Apply(); graphicsDevice.DrawUserPrimitives<VertexPositionTexture>(PrimitiveType.TriangleStrip, verts, i * 4 , 2); } } } }
public void Draw(Camera camera) { Matrix[] transforms = new Matrix[model.Bones.Count]; model.CopyAbsoluteBoneTransformsTo(transforms); foreach (ModelMesh mesh in model.Meshes) { foreach (BasicEffect b in mesh.Effects) { b.EnableDefaultLighting(); //b.PreferPerPixelLighting = true; // Activate this and whole model goes WHITE color! b.Projection = camera.projection; b.View = camera.view; b.World = getWorld() * mesh.ParentBone.Transform; b.LightingEnabled = true; // turn on the lighting subsystem. b.DirectionalLight0.DiffuseColor = new Vector3(1f, 1f, 1f); // color of light b.DirectionalLight0.Direction = new Vector3(1, 1, 1); // coming along the x-axis b.DirectionalLight0.SpecularColor = new Vector3(1, 1, 1); // with white highlights.. Change RGB values to change highlight color for a model. //Lasitha - We can add up to 3 Directional lights. Use that lighting as you want in other classes you make .. like b.DirectionalLight1.Diffusecolor = blah blah b.AmbientLightColor = new Vector3(10f, 10f, 10f); b.DiffuseColor = new Vector3(10f, 10f, 10f); b.EmissiveColor = new Vector3(1, 1, 1); b.SpecularColor = Vector3.One; } mesh.Draw(); } }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here //camera = new Camera(this, new Vector3(0, 0, 10), new Vector3(0, 0, 0), Vector3.Up); camera = new Camera(this, new Vector3(0, 0, 20), new Vector3(0, 0, 0), Vector3.Up); Components.Add(camera); device = graphics.GraphicsDevice; base.Initialize(); }