Camera for "drivers view" on vehicle model - Printable Version
+- AB4D Forum (https://forum.ab4d.com)
+-- Forum: Products Forums (https://forum.ab4d.com/forumdisplay.php?fid=4)
+--- Forum: Ab3d.DXEngine (https://forum.ab4d.com/forumdisplay.php?fid=11)
+--- Thread: Camera for "drivers view" on vehicle model (/showthread.php?tid=4002)
Camera for "drivers view" on vehicle model - HFP - 02-21-2017
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!
RE: Camera for "drivers view" on vehicle model - abenedik - 02-21-2017
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:
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).
RE: Camera for "drivers view" on vehicle model - HFP - 02-21-2017
(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.
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,