Free cookie consent management tool by TermsFeed Policy Generator

Changeset 13478


Ignore:
Timestamp:
12/17/15 20:06:23 (8 years ago)
Author:
gkronber
Message:

#1966 fixed rotation and zooming for 3d packings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.BinPacking/PackingPlanVisualizations/3D/PackingGame.cs

    r13465 r13478  
    2121
    2222using System;
     23using System.Drawing.Printing;
    2324using SharpDX;
    2425using SharpDX.Direct3D11;
     
    198199
    199200      worldMatrix =
    200         Matrix.RotationY(MathUtil.DegreesToRadians(-currentViewAngle.X / 4)) *
    201         Matrix.RotationX(MathUtil.DegreesToRadians(currentViewAngle.Y / 4));
     201        Matrix.RotationY(MathUtil.DegreesToRadians(-currentViewAngle.X * control.Width / 4)) *
     202        Matrix.RotationX(MathUtil.DegreesToRadians(currentViewAngle.Y * control.Height / 4));
    202203      basicEffect.World = worldMatrix;
    203204
     
    231232    }
    232233
    233 
    234 
    235 
    236 
    237 
    238234    protected override void Update(GameTime gameTime) {
    239235      computeMouseHandling();
     
    255251    }
    256252    private void computeLeftMouseBtnHandling(MouseState mouseState) {
    257       //Left btn released
    258       //if (mouseState.LeftButton.Released && mouseState.LeftButton.Equals(previousMouseState.LeftButton)) {
    259       //  //Console.WriteLine("Released");
    260       //} else
    261 
    262253      //Left btn pressed
    263 
    264       if (mouseState.LeftButton.Pressed && mouseState.LeftButton.Equals(previousMouseState.LeftButton)) {
     254      if (mouseState.LeftButton.Down && (previousMouseState.LeftButton.Pressed || previousMouseState.LeftButton.Down)) {
    265255        currentViewAngle = new Vector2(
    266256          viewAngleOnBtnRelease.X + mouseState.X - mousePositionOnBtnDown.X,
    267257          viewAngleOnBtnRelease.Y + mouseState.Y - mousePositionOnBtnDown.Y);
    268 
    269258      }
    270259
    271260      //Left btn freshly pressed ==> ONLICK-EVENT
    272       else if (mouseState.LeftButton.Pressed && !previousMouseState.LeftButton.Pressed) {
    273         //Console.WriteLine("OnClick");
    274         //PackingPlan3D native = (PackingPlan3D)Window.NativeWindow;
    275         //Console.WriteLine("Window: " + Window.ClientBounds.ToString());
    276         //Console.WriteLine("native: " + native.ClientSize.ToString());
    277         //Console.WriteLine("native.parent: " + native.Parent.ClientSize.ToString());
    278         //
    279         //Console.WriteLine(native.ParentForm.ToString());
    280         //Console.WriteLine(Window.Name);
    281         //Console.WriteLine(this.IsActive);
     261      else if (mouseState.LeftButton.Pressed && !(previousMouseState.LeftButton.Pressed || previousMouseState.LeftButton.Down)) {
    282262        mousePositionOnBtnDown = new Vector2(mouseState.X, mouseState.Y);
    283263      }
     
    285265      //Left btn freshly released ==> ONRELEASE-EVENT
    286266      else if (mouseState.LeftButton.Released && !previousMouseState.LeftButton.Released) {
    287         //Console.WriteLine("OnRelease");
    288267        viewAngleOnBtnRelease = currentViewAngle;
    289268      }
    290269    }
    291270    private void computeMouseWheelHandling(MouseState mouseState) {
    292       int prev = previousMouseState.WheelDelta;
    293271      int curr = mouseState.WheelDelta;
    294       if (curr < prev && zoom > 1) {
     272      if (curr < 0 && zoom > 1) {
    295273        zoom++;
    296         //Console.WriteLine(zoom);
    297       } else if (curr > prev && zoom < 300) {
     274      } else if (curr > 0 && zoom < 300) {
    298275        zoom--;
    299         //Console.WriteLine(zoom);
    300276      }
    301277    }
Note: See TracChangeset for help on using the changeset viewer.