- Timestamp:
- 11/15/15 13:56:30 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.BinPacking/PackingPlanVisualizations/3D/PackingGame.cs
r13032 r13161 22 22 using System; 23 23 using SharpDX; 24 using SharpDX.Toolkit; 24 using SharpDX.Direct3D11; 25 using SharpDX.Toolkit; 25 26 using SharpDX.Toolkit.Graphics; 26 27 using SharpDX.Toolkit.Input; 27 28 28 29 using ButtonStateDX = SharpDX.Toolkit.Input.ButtonState; 29 using SharpDX.Direct3D11; 30 30 31 31 32 namespace PackingPlanVisualizations { … … 33 34 34 35 35 #region Global Private Variables 36 #region Global Private Variables 36 37 private GraphicsDeviceManager graphicsDeviceManager; 37 38 private PackingPlan3D control; … … 42 43 private int selectedItemIndex = -1; 43 44 44 private BasicEffect basicEffect; 45 private BasicEffect basicEffect; 45 46 private Color backgroundColor { get; set; } 46 47 47 private CenteredContainer container; 48 private CenteredContainer container; 48 49 private MouseManager Mouse; 49 #endregion Global Private Variables 50 #endregion Global Private Variables 50 51 51 52 protected override void Dispose(bool disposeManagedResources) { … … 58 59 public PackingGame(PackingPlan3D control) 59 60 : base() { 60 61 this.control = control; 61 62 graphicsDeviceManager = new GraphicsDeviceManager(this); 62 63 graphicsDeviceManager.PreferMultiSampling = true; 63 graphicsDeviceManager.PreparingDeviceSettings += 64 (object sender, PreparingDeviceSettingsEventArgs e) => { 64 graphicsDeviceManager.PreparingDeviceSettings += 65 (object sender, PreparingDeviceSettingsEventArgs e) => { 65 66 e.GraphicsDeviceInformation.PresentationParameters.MultiSampleCount = MSAALevel.X4; 66 67 return; 67 68 }; 68 69 var controlColor = Color.White;//System.Drawing.SystemColors.Control; 69 backgroundColor = new Color (controlColor.R,controlColor.G, controlColor.B, controlColor.A);70 backgroundColor = new Color(controlColor.R, controlColor.G, controlColor.B, controlColor.A); 70 71 71 72 Mouse = new MouseManager(this); … … 135 136 //Primitive color 136 137 basicEffect.AmbientLightColor = new Vector3(0.1f, 0.1f, 0.1f); 137 basicEffect.DiffuseColor = new Vector 3(1.0f, 1.0f, 1.0f);138 basicEffect.DiffuseColor = new Vector4(1.0f, 1.0f, 1.0f, 1.0f); 138 139 basicEffect.SpecularColor = new Vector3(0.25f, 0.25f, 0.25f); 139 140 basicEffect.SpecularPower = 5.0f; … … 204 205 GraphicsDevice.Clear(backgroundColor); 205 206 206 worldMatrix = 207 worldMatrix = 207 208 Matrix.RotationY(MathUtil.DegreesToRadians(-currentViewAngle.X / 4)) * 208 209 Matrix.RotationX(MathUtil.DegreesToRadians(currentViewAngle.Y / 4)); … … 229 230 item.RenderShapeTriangles(GraphicsDevice); 230 231 } else 231 item.RenderShapeLines(GraphicsDevice, new Color(0, 0,0));232 item.RenderShapeLines(GraphicsDevice, new Color(0, 0, 0)); 232 233 } 233 234 } … … 235 236 } 236 237 237 base.Draw(gameTime); 238 base.Draw(gameTime); 238 239 } 239 240 … … 244 245 245 246 protected override void Update(GameTime gameTime) { 246 computeMouseHandling(); 247 computeMouseHandling(); 247 248 base.Update(gameTime); 248 249 } … … 263 264 private void computeLeftMouseBtnHandling(MouseState mouseState) { 264 265 //Left btn released 265 if (mouseState.Left .Equals(ButtonStateDX.Released) && mouseState.Left.Equals(previousMouseState.Left)) {266 if (mouseState.LeftButton.Released && mouseState.LeftButton.Equals(previousMouseState.LeftButton)) { 266 267 //Console.WriteLine("Released"); 267 268 } 268 269 269 270 //Left btn pressed 270 else if (mouseState.Left .Equals(ButtonStateDX.Pressed) && mouseState.Left.Equals(previousMouseState.Left)) {271 else if (mouseState.LeftButton.Pressed && mouseState.LeftButton.Equals(previousMouseState.LeftButton)) { 271 272 currentViewAngle = new Vector2( 272 273 viewAngleOnBtnRelease.X + mouseState.X - mousePositionOnBtnDown.X, … … 279 280 280 281 //Left btn freshly pressed ==> ONLICK-EVENT 281 else if (mouseState.Left .Equals(ButtonStateDX.Pressed) && !previousMouseState.Left.Equals(ButtonStateDX.Pressed)) {282 else if (mouseState.LeftButton.Pressed && !previousMouseState.LeftButton.Pressed) { 282 283 Console.WriteLine("OnClick"); 283 284 PackingPlan3D native = (PackingPlan3D)Window.NativeWindow; … … 293 294 294 295 //Left btn freshly released ==> ONRELEASE-EVENT 295 else if (mouseState.Left .Equals(ButtonStateDX.Released) && !previousMouseState.Left.Equals(ButtonStateDX.Released)) {296 else if (mouseState.LeftButton.Released && !previousMouseState.LeftButton.Released) { 296 297 Console.WriteLine("OnRelease"); 297 298 viewAngleOnBtnRelease = currentViewAngle;
Note: See TracChangeset
for help on using the changeset viewer.