title: How to zoom to a model in a helix-toolkit sharpdx viewport?
body: <p>Following setup: I have an application with two viewports. When choosing an element on the main viewport, a copy of the model geometry is supposed to be displayed enlarged in the second viewport.</p>
  
  <p>I uploaded a screenshot for some visual aid :-) <a href="http://imgur.com/ILG8Ylk" rel="nofollow">http://imgur.com/ILG8Ylk</a></p>
  
  <p>My take on this (among others) is to use the ZoomExtents method:</p>
  
  <p><em>MainViewModel.cs</em></p>
  
  <pre><code>    public void SetDetailedModelGeometry(MeshGeometryModel3D geometry)
      {
  
          MyDetailedModel = new Element3DCollection();
          MyModelViewportDetailed.Reset();
  
          if (geometry != null)
          {
              var bounds = geometry.Bounds;
  
              //var rec = new Rect3D(bounds.Minimum.X, bounds.Minimum.Y, bounds.Minimum.Z, bounds.Maximum.X,bounds.Maximum.Y,bounds.Maximum.Z);
  
              this.MyDetailedModel.Add(geometry);
              MyDetailedModel[0].Attach(MyModelViewportDetailed.RenderHost);
  
              this.OnPropertyChanged("MyDetailedModel");
  
              MyModelViewportDetailed.ZoomExtents();
              //MyModelViewportDetailed.ZoomExtents(rec);
  
          }
  
      }
  </code></pre>
  
  <p>I guess both overloads should fit the scene nicely to the bound model, but I always end up with a very zoomed out view and most of the models are not centered in the viewport.</p>
  
  <p>I tried to hack a solution by translating the model into the origin and by applying a zoom-force, the result is better but still kind of meh.</p>
  
  <pre><code>    public void SetDetailedModelGeometry(MeshGeometryModel3D geometry)
      {
  
          MyDetailedModel = new Element3DCollection();
          MyModelViewportDetailed.Reset();
  
          if (geometry != null)
          {
  
              var bounds = geometry.Bounds;
              var rec = new Rect3D( bounds.Minimum.X, bounds.Minimum.Y, bounds.Minimum.Z,  bounds.Maximum.X, bounds.Maximum.Y, bounds.Maximum.Z);
              // move model 
  
              var delta = new Point3D(Math.Abs(bounds.Maximum.X - bounds.Minimum.X), Math.Abs(bounds.Maximum.Y - bounds.Minimum.Y), Math.Abs(bounds.Maximum.Z - bounds.Minimum.Z));
              var center = new Point3D(bounds.Minimum.X+delta.X, bounds.Minimum.Y+delta.Y, bounds.Minimum.Z+delta.Z);
  
              TransformDetailed = new TranslateTransform3D(-center.X,-center.Y,-center.Z);
              geometry.Transform = TransformDetailed;
  
              // notice property change
              this.MyDetailedModel.Add(geometry);
              MyDetailedModel[0].Attach(MyModelViewportDetailed.RenderHost);
  
              this.OnPropertyChanged("MyDetailedModel");
  
              MyModelViewportDetailed.ZoomExtents();
              MyModelViewportDetailed.CameraController.AddZoomForce(-1.0);
  
  
          }
  </code></pre>
  
  <p>Does somebody have a clue why the zoomExtends() method is not working for me?
  And if not, maybe has suggestions for a more sophisticated hack xD.</p>
  
  <p>I'm quite the junior developer, so I'm open for any comments for improvements, thanks.</p>