protected override void Update(GameTime gameTime) { base.Update(gameTime); MouseState state = Mouse.GetState(); // Calculate our cursors position on the plane in 3D space CursorPosition = Utilitys.CalcPosOnPlane(GraphicsDevice, Camera, state.X, state.Y); if (InputHandler.IsActionPressed("bsIncrease")) { BrushSize += 1; } if (InputHandler.IsActionPressed("bsDecrease")) { if (BrushSize >= MinBrushSize) { BrushSize -= 1; } } if (InputHandler.IsActionPressed("Sculpting")) { BrushMode = BrushMode.Sculpting; } if (InputHandler.IsActionPressed("PaintLayer1")) { BrushMode = BrushMode.Paint; CurrentLayer = 0; } if (InputHandler.IsActionPressed("PaintLayer2")) { BrushMode = BrushMode.Paint; CurrentLayer = 1; } if (InputHandler.IsActionPressed("PaintLayer3")) { BrushMode = BrushMode.Paint; CurrentLayer = 2; } if (InputHandler.IsActionPressed("PaintLayer4")) { BrushMode = BrushMode.Paint; CurrentLayer = 3; } #region Sculpting Brush Mode if (BrushMode == BrushMode.Sculpting) { if (state.LeftButton == ButtonState.Pressed) { if (HeightAdjustThread.ThreadState == ThreadState.Stopped) { CanAlterHeight = true; } if (CanAlterHeight && HeightAdjustThread.ThreadState != ThreadState.Running) { CanAlterHeight = false; HeightAdjustThread = new Thread(HeightAdjustWorkerThread); HeightAdjustThread.IsBackground = true; HeightAdjustThread.Start(Direction.Up); } } if (state.RightButton == ButtonState.Pressed) { if (HeightAdjustThread.ThreadState == ThreadState.Stopped) { CanAlterHeight = true; } if (CanAlterHeight && HeightAdjustThread.ThreadState != ThreadState.Running) { CanAlterHeight = false; HeightAdjustThread = new Thread(HeightAdjustWorkerThread); HeightAdjustThread.IsBackground = true; HeightAdjustThread.Start(Direction.Down); } } } #endregion #region Painting Mode if (BrushMode == BrushMode.Paint) { if (state.LeftButton == ButtonState.Pressed) { PaintLayer(CurrentLayer, 100); } } #endregion // Update our Shader Var's Effect.Parameters["World"].SetValue(Matrix.Identity); Effect.Parameters["View"].SetValue(Camera.View); Effect.Parameters["Projection"].SetValue(Camera.Projection); Effect.Parameters["AmbientLightColor"].SetValue(Color.White.ToVector4()); Effect.Parameters["AmbientLightIntensity"].SetValue(0.1f); Effect.Parameters["DiffuseLightDirection"].SetValue(new Vector3(1, 1, 1)); Effect.Parameters["DiffuseLightColor"].SetValue(Color.Gray.ToVector4()); Effect.Parameters["DiffuseLightIntensity"].SetValue(0.9f); Effect.Parameters["CursorPosition"].SetValue(CursorPosition); Effect.Parameters["CursorSize"].SetValue(BrushSize); // Send our Textures to our GPU if (Layer1 != null) { Effect.Parameters["TextureLayer1"].SetValue(Layer1); } if (Layer2 != null) { Effect.Parameters["TextureLayer2"].SetValue(Layer2); } if (Layer3 != null) { Effect.Parameters["TextureLayer3"].SetValue(Layer3); } if (Layer4 != null) { Effect.Parameters["TextureLayer4"].SetValue(Layer4); } if (PaintMask1 != null) { Effect.Parameters["PaintMask"].SetValue(PaintMask1); } }