I have a physical camera and a Unity3d Scene. I want to map the physical camera coordinate system to the virtual scene, 1:1.
For example, imagine the physical camera is pointed at the sky and an aircraft flies overhead. I want to have the physical aircraft appear in my virtual environment, at the correct location. I can get the ADS-B data (which describes position and altitude of the aircraft) and a generic 3D aircraft model. I can import that 3D aircraft model into my scene, but how do I know where to put it and at which height in the scene? And when I move the physical camera, I want the virtual camera to move in the same way.
Put another way, if you wanted to recreate the Earth (ignoring all textures, lighting, etc.) in Unity3D, how would you ensure that objects in the physical world appear in the same location as in your virtual Earth?
How can I do this?
CodePudding user response:
If you want a virtual camera that is just like your physical one then there's toggle in "camera" component called "physical camera". There you can set it's sensor data and all that kind of stuff. If it's not it, I don't know.
CodePudding user response:
Unity has a built-in LocationService
class to determine your location on the globe. Then there is Input.gyro
, which can be used to determine where approximately you are pointing. Use this information and the flight transponder data to compute your position relative to the aircraft. Obviously, this will be wildly inaccurate. But, as others suggested, you can gain additional accuracy by setting your virtual camera up as a Unity physical camera and matching it up with your real-world camera. From your camera footage, extract the clip space position of the aircraft using some kind of image recognition method (i.e. a ComputeShader
retrieving the location of a small dark spot) and then use Camera.ScreenPointToRay
of that position to get a vector towards where the airplane should be in the scene. Using this, correct your virtual user position in the 3D scene, such that the ray lines up with the vector from your virtual camera to the virtual aircraft.
CodePudding user response:
I think what you want to do is to do 1:1 map of real world in your unity scene. For that you will need to read this documentation. Basically 1 unit in unity is 1 meter. To make dimensions of 3D objects 1:1 to real life dimensions you will need to resize/change scale of those objects manually. Good Luck with that!