Camera for "drivers view" on vehicle model
#1
During the last days, I've tried to use several options, but I'm still not sure which could be best ...

Main problem: Vehicle model is driving, realized by updating the center positions for model parts (some BoxVisual3D and TubeVisual3D objects.

Vehicle direction is simply done with the Transform property, by using RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0.0, 0.0, 1.0), 0.0), new Point3D(0.0, 0.0, 0.0)) ...

Maybe better options are possible, but anyway, it works. :-)

But I still don't know which camera option could be the best idea to realize some kind of "drivers view" ...

In theory, FirstPersonCamera should be first choice option, isn't it?

Its position can easily be updated, most important. :-)

But how can I adapt its direction related to the vehicle?

While XYZ dimensions in Viewport3D are different from real-life (geodetic) XYZ dimensions, the Heading property is unfortunately not usable to do this ...

Are there any other ideas or options to realize such kind of "drivers view"?

Thanks a lot in advance!

Best regards,
Hagen


Attached Files Thumbnail(s)
   
#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
#3
(02-21-2017, 10:41 AM)abenedik Wrote: ... 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.

Dear Andrej,
Thank you for your perfect support!

As often in life, someone can try to research tons of details without fundamental understanding of the basics. :-(

At the moment, I feel a little bit like this ...

But thanks to your help, I can start to do my work in a general right way!

Very happy & best regards,
Hagen
  


Forum Jump:


Users browsing this thread:
1 Guest(s)