01-08-2016, 04:08 PM
WPF is using standard right handed coordinate system where X is to the right, Y up and Z "away from the screen".
Also the Ab3d.PowerToys camera work well when Y axis is pointing up. The cameras (expect FreeCamera) do not work well in any other coordinate system.
Therefore I would advise you to preserve the Y up axis and convert the coordinates of objects before you apply them to WPF 3D objects. For example if one object is at (100, 200, 300) in your coordinates, you need to show it at (100, 300, -200) coordinates in WPF.
Another solution is to define a ModelVisual3D with a MatrixTransform3D that transform coordinate system from your coordinate system to WPF coordinate system. It can be defined with the following XAML:
Then you can add 3D objects into this ModelVisual3D and use coordinates in your coordinate system.
But you cannot use this ModelVisual3D for HeightMapVisual3D because HeightMapVisual3D already uses Y axis as up axis. But this should not be a problem because HeightMapVisual3D already have the planar X and Y coordinates in the HeightData array and Height value that is pointing up.
If you are using CameraAxisPanel to show coordinate axes, you can change the axes direction there - see CameraPanelsSample.xaml.
For the next version of Ab3d.PowerToys (v7.4) I have prepared a simple on how to do that (without HeightMap).
You can try it with downloading the following two files:
CustomUpAxisSample.xaml (Size: 4.6 KB / Downloads: 6)
CustomUpAxisSample.xaml.cs (Size: 1.26 KB / Downloads: 4)
Add them to the samples solution to the Cameras folder. Then open the Samples.xml on the root folder and add the following under Cameras:
<Sample Page="Cameras/CustomUpAxisSample.xaml" Title="Custom Up axis" Description="" />
Also the Ab3d.PowerToys camera work well when Y axis is pointing up. The cameras (expect FreeCamera) do not work well in any other coordinate system.
Therefore I would advise you to preserve the Y up axis and convert the coordinates of objects before you apply them to WPF 3D objects. For example if one object is at (100, 200, 300) in your coordinates, you need to show it at (100, 300, -200) coordinates in WPF.
Another solution is to define a ModelVisual3D with a MatrixTransform3D that transform coordinate system from your coordinate system to WPF coordinate system. It can be defined with the following XAML:
Code:
<ModelVisual3D x:Name="ZUpRootVisual">
<ModelVisual3D.Transform>
<!-- The transformation defines the new axis - defined in matrix columns in upper left 3x3 part of the matrix:
x axis - 1st column (use x value): 1 0 0
y axis - 2nd column (use z value): 0 0 1
z axis - 3rd column (use negative y value): 0 -1 0 -->
<MatrixTransform3D Matrix="1 0 0 0
0 0 -1 0
0 1 0 0
0 0 0 1" />
</ModelVisual3D.Transform>
<!-- All 3D models inside this Visual3D will have changed coordinate system with Z up and Y into the screen -->
</ModelVisual3D>Then you can add 3D objects into this ModelVisual3D and use coordinates in your coordinate system.
But you cannot use this ModelVisual3D for HeightMapVisual3D because HeightMapVisual3D already uses Y axis as up axis. But this should not be a problem because HeightMapVisual3D already have the planar X and Y coordinates in the HeightData array and Height value that is pointing up.
If you are using CameraAxisPanel to show coordinate axes, you can change the axes direction there - see CameraPanelsSample.xaml.
For the next version of Ab3d.PowerToys (v7.4) I have prepared a simple on how to do that (without HeightMap).
You can try it with downloading the following two files:
CustomUpAxisSample.xaml (Size: 4.6 KB / Downloads: 6)
CustomUpAxisSample.xaml.cs (Size: 1.26 KB / Downloads: 4)
Add them to the samples solution to the Cameras folder. Then open the Samples.xml on the root folder and add the following under Cameras:
<Sample Page="Cameras/CustomUpAxisSample.xaml" Title="Custom Up axis" Description="" />
Andrej Benedik

