/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); var device = graphics.GraphicsDevice; //Sphere sp = new Sphere(3, GraphicsDevice); // Copy any parent transforms. //Matrix[] transforms = new Matrix[myModel.Bones.Count]; //myModel.CopyAbsoluteBoneTransformsTo(transforms); //var cam = new Camera(); //graphics.GraphicsDevice.DrawUserPrimitives(PrimitiveType.LineStrip, ; //sp.Draw(cam); BoundingSphereRenderer.InitializeGraphics(device, 100); var look = Matrix.CreateLookAt(cameraPosition, Vector3.Zero, Vector3.Up); var projection = Matrix.CreatePerspectiveFieldOfView( MathHelper.ToRadians(45.0f), aspectRatio, 1.0f, 10000.0f); BoundingSphereRenderer.Render(new BoundingSphere(center, 2), device, look, projection, Color.Red, Color.Blue, Color.Green); // TODO: Add your drawing code here base.Draw(gameTime); }
private void DrawBoundingElements() { foreach (Tank tank in tankController.TanksInGame) { foreach (BoundingSphere boundingSphere in tank.BoundingSpheres) { BoundingSphereRenderer.Render(boundingSphere, GraphicsDevice, camera.View, projection, Color.Red); } } BoundingSphereRenderer.Render(tankController.MissleInGame.BoundingSphere, GraphicsDevice, camera.View, projection, Color.Red); BoundingFrustumRenderer.Render(camera.Frustum, GraphicsDevice, camera.View, projection, Color.Red); }
//draw the vehicle virtual public void draw(ChaseCamera cameraPosition, Viewport currentViewPort, GameTime gameTime) { //update smoke particles smoke.SetCamera(cameraPosition.view, cameraPosition.projection); smoke.Draw(gameTime); if (drawSpheres) { BoundingSphereRenderer.Render(waypointSpheres[point], graphics.GraphicsDevice, cameraPosition.view, cameraPosition.projection, Color.Red); } graphics.GraphicsDevice.Viewport = currentViewPort; graphics.GraphicsDevice.RenderState.DepthBufferWriteEnable = true; // Copy any parent transforms. Matrix[] transforms = new Matrix[carModel.Bones.Count]; carModel.CopyAbsoluteBoneTransformsTo(transforms); foreach (ModelMesh mesh in carModel.Meshes) { foreach (BasicEffect effect in mesh.Effects) { effect.Begin(); effect.EnableDefaultLighting(); float direction = speed / Math.Abs(speed); /*Vector3 pointToRotateAround = rotationMatrix.Translation + * rotationMatrix.Right * (position - previousPosition); * * transforms[mesh.ParentBone.Index].Translation -= pointToRotateAround; * transforms[mesh.ParentBone.Index] *= transformationMatrix; * transforms[mesh.ParentBone.Index].Translation += pointToRotateAround;*/ effect.World = transforms[mesh.ParentBone.Index] /* Matrix.CreateRotationY((direction > 0 || direction < 0 ? direction : 1) * currentRotation / 100)*/ * Matrix.CreateRotationY(carGlobalRotation) * transformationMatrix; effect.View = cameraPosition.view; effect.Projection = cameraPosition.projection; effect.End(); } mesh.Draw(); } //BoundingSphereRenderer.Render(collisionSphere, graphics.GraphicsDevice, cameraPosition.view, cameraPosition.projection, Color.Blue); }