Camera for "drivers view" on vehicle model
#2
I see that the problem is that DXEngine (and WPF 3D) is using Y as up axis, but your data is using Z as up axis.

This is quite common problem.

FirstPersonCamera, TargetPositionCamera and other cameras do not work well when Y axis is not pointed up.

The exception to this is FreeCamera. This camera uses CameraPosition and TargetPosition instead of angles (Heading, Attitude) and is therefore independent to any axis.

In your case you could probably use similar rotate transform as you use for your car and rotate TargetPosition around CameraPosition.


However, in case when your data have different coordinate axis as WPF 3D and DXEngine, it is best practice to design your low level objects to create the 3D objects in the WPF 3D coordinate system but they can expose the public properties (for example CarPosition) in the coordinate system that is suitable for the application and its data. So your application will work with your objects (like CarVisual3D) in the coordinate system of your data, but the low level objects (for example CarVisual3D) will know that it is rendered in a different coordinate system and will adjust the data accordingly - hiding the specifics of the platform from the application.

This can be achieved with manually swapping Z and Y values.
Another way to do that is to use transformation matrix that will convert the data from one coordinate system to another. You can see an example for that in the Cameras/CustomUpAxisSample from Ab3d.PowerToys samples - there the following root ModelVisual3D element is used:

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>

This sample also shows you how to adjust the CameraAxisPanel control to show Z axis as up axis (see code behind of the sample where CustomizeAxes method is called).
Andrej Benedik
  


Messages In This Thread
RE: Camera for "drivers view" on vehicle model - by abenedik - 02-21-2017, 10:41 AM

Forum Jump:


Users browsing this thread:
1 Guest(s)