protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.Black); GraphicsDevice.Clear(ClearOptions.DepthBuffer, Color.Black, 1f, 1); GraphicsDevice.BlendState = BlendState.Opaque; GraphicsDevice.SamplerStates[0] = ss_point_clamp; GraphicsDevice.DepthStencilState = ds_standard_less; if (WireframeOnOrOff) { GraphicsDevice.RasterizerState = rs_nocullwireframe; } else { GraphicsDevice.RasterizerState = rs_cull_cw_solid; } // set model world var modelWorld = Matrix.Identity; //modelWorld = Matrix.CreateRotationY(1.5f); //modelWorld.Translation = new Vector3(5f, -0f, 0f); // set sphere orientation var sphereOrientation = Matrix.Identity * lightTransform; sphereOrientation.Translation = new Vector3(0, -50f, 0f); // light pos var lightpos = Vector3.Transform(initialLightPosition, lightTransform); // set light to shader riggedEffect.Parameters["WorldLightPosition"].SetValue(lightpos); // set view to shader riggedEffect.Parameters["View"].SetValue(cam.View); // set camera world position to shader riggedEffect.Parameters["CameraPosition"].SetValue(cam.Position); // cam.Position // cam.View.Translation // remake the line lineToLight = new LinePCT(.1f, Color.White, sphereOrientation.Translation, lightpos); //_______________________________ // draw a line to the light source. //_______________________________ riggedEffect.CurrentTechnique = riggedEffect.Techniques["ColorDraw"]; riggedEffect.Parameters["World"].SetValue(Matrix.Identity); riggedEffect.Parameters["TextureA"].SetValue(defaultTexture); lineToLight.Draw(GraphicsDevice, riggedEffect); //_______________________________ // draw sphere. //_______________________________ // move the spheres down a bit first riggedEffect.Parameters["World"].SetValue(sphereOrientation); riggedEffect.CurrentTechnique = riggedEffect.Techniques["ColorTextureLightingDraw"]; littleSphere.Draw(GraphicsDevice, riggedEffect); bigShere.Draw(GraphicsDevice, riggedEffect); // draw sphere normals riggedEffect.CurrentTechnique = riggedEffect.Techniques["ColorTextureLightingNormalsDraw"]; GraphicsDevice.RasterizerState = rs_nocullsolid; if (ShowNormals) { primitiveNormalArrows.Draw(GraphicsDevice, riggedEffect); } if (WireframeOnOrOff) { GraphicsDevice.RasterizerState = rs_nocullwireframe; } else { GraphicsDevice.RasterizerState = rs_cull_cw_solid; } //_______________________________ // model and normals //_______________________________ // draw a little sphere in the model just make sure the model isnt backface. var m = Matrix.Identity; m.Translation = new Vector3(0, 20, 0); riggedEffect.Parameters["World"].SetValue(m); littleSphere.Draw(GraphicsDevice, riggedEffect); // draw models. if (model != null) { riggedEffect.CurrentTechnique = riggedEffect.Techniques["RiggedModelDraw"]; modelWorld = Matrix.Identity; riggedEffect.Parameters["World"].SetValue(modelWorld); model.effect = riggedEffect; model.Draw(GraphicsDevice, modelWorld); } // draw models normals. riggedEffect.CurrentTechnique = riggedEffect.Techniques["RiggedModelNormalDraw"]; GraphicsDevice.RasterizerState = rs_nocullsolid; if (ShowNormals) { modelVisualNormals.Draw(GraphicsDevice, riggedEffect); } DrawSpriteBatches(gameTime); base.Draw(gameTime); }