views:

493

answers:

1

Hello!

Plattform:

  • .NET 3.5 with C#
  • WPF
  • 3DTools

I'm using 3DTools from the Codeplex site (3D Tools) for rotating and panning of 3D Models. This works fine. The Trackball class also contains a method for zooming models with the mouse wheel. However, this method always scales the model with Point(0,0,0) as the center of the zooming. But I'd like to zoom to the coordinates of the mouse pointer (like Google Maps, here you do not zoom to the center of the map but to the mouse pointer coordinates).

I tried different things solving this issue:

  • set CenterX/Y/Z of the ScaleTransform3D object of the Trackball class to the mouse pointer coordinates -> it didn't work
  • pan the model after zooming -> didn't work too; because the coordinates of the mouse pointer do not change, thus I can not calculate the panning distance, e.g.
    • MousePointer Coordinates before zooming -> 334, 210
    • call Zoom(-e.Delta) from the Trackball class
    • MousePointer Coordinates after zooming -> 334, 210
    • if the MousePointer Coordinates would change, e.g. 330, 205, I could pan the model 4 points left and 5 points up (my program has also a 2D mode and there the coordinates change)
  • move the camera position -> didn't work; based on the current camera position and the MouseWheelEventArgs.Delta I calculated the new camera position

Has somebody a clue how this problem can be solved?

A: 

The 3DTools project doesn't work well on .NET 3.5, because it's meant to run on WPF of .NET 3.0 release.

The mission (hence functionality) of the 3D Tools is to make coding 2D controls on 3D easier on WPF of .NET 3.0. If you have .NET 3.5, you already have support for 2D on 3D programming and also WPF XAML support.

Although .NET 3.5 is basically .NET 3.0 SP1 + LINQ, the WPF subsystem on .NET 3.0 SP1 has quite large differences such as above, compared to WPF of .NET 3.0 release.

Visit this page on MSDN Library:

http://msdn.microsoft.com/en-us/library/bb613588(v=VS.90).aspx

Also the mouse tracking isn't not well supported on the WPF of .NET 3.0 SP1. I suggest you to rewrite the mouse tracking code and recompile it under .NET 3.5 environment (target the project to .NET 3.5).

eriawan