1. UAV makes panoramic photos
1.1 panoramic photo production of Dajiang UAV is completed by using one key 720 panorama in software DJI GO4
1.2 manual production 720 panorama completed
(1) The drone went up to a certain height. This height should be selected at the balance point where there is no building blocking the line of sight and the main body of the shooting can be fully displayed. Generally, 50-100m is suitable.
(2) Set the UAV's PTZ angle of view to horizontal. Control the horizontal rotation control lever to rotate 360 degrees clockwise or anticlockwise, and take a picture every 45 degrees of rotation, to ensure that 20% of the places between the two pictures are coincident, in terms of late splicing.
(3) Adjust the viewing angle of the UAV platform to 45 degrees downward, and take one picture every 45 degrees in the same way as above, at least 8 pictures.
(4) Adjust the platform to 90 ° vertical ground and take a low-level picture.
(5) Import at least 17 pictures of the same scene into panorama splicing software PTgui or panorama Studio 2 pro, both of which can be downloaded directly by Baidu.
(6) After the image is imported, fill in the focal length of the camera. The specific data can be found in the parameters of the product description. The focal length of my device is 3.7 mm (equivalent to 20 mm).
(7) Select align image. After processing, we can get a horizontal image.
Although the pictures are spliced together, the sky is incomplete due to the limitation of UAV's view angle (unable to shoot overhead).
This requires us to make up for the future.
(8) This kind of photos can be taken by ourselves or spliced directly with materials.
Because the landscape on the ground is complex and diverse, the appearance of the sky is similar all over the world.
2. Making panoramic photos with mobile phone
It is basically the same as the UAV's manual production of 720 panorama.
2, Unity3D programming
Create a sphere in U3D
Add panoramic photo (drag the picture to the ball directly)
Next, the most important part of setting up the scene is to let the panoramic picture stick on the inside of the sphere. To make the picture stick to the object, we need to use the renderer Shader. We need to create a renderer script, and then drag the picture into the script, so that we can change the rendering mode of the picture, drag the picture into the sphere, and set the rendering mode of the material, so that the picture can stick to the inside of the sphere.
Shader "Unlit/DoubleSided" { Properties { _Color("Main Color", Color) = (1,1,1,1) _MainTex("Texture", 2D) = "white" {} } SubShader { //Ambient pass Pass { Name "BASE" Tags {"LightMode" = "Always" /* Upgrade NOTE: changed from PixelOrNone to Always */} Color[_PPLAmbient] SetTexture[_BumpMap] { constantColor(.5,.5,.5) combine constant lerp(texture) previous } SetTexture[_MainTex] { constantColor[_Color] Combine texture * previous DOUBLE, texture *constant } } //Vertex lights Pass{ Name "BASE" Tags {"LightMode" = "Vertex"} Material { Diffuse[_Color] Emission[_PPLAmbient] Shininess[_Shininess] Specular[_SpecColor] } SeparateSpecular On Lighting On cull off SetTexture[_BumpMap] { constantColor(.5,.5,.5) combine constant lerp(texture) previous } SetTexture[_MainTex] { Combine texture *previous DOUBLE, texture *primary } } } FallBack "Diffuse", 1 }
Drag the Shader to the picture in Sphere
Add C script for camera control
The code is as follows:
using UnityEngine; using System.Collections; using UnityEngine.UI; public class Test01 : MonoBehaviour { public float moveSpeed = 1;//Object rotation speed public GameObject target; private Vector2 oldPosition; private Vector2 oldPosition1; private Vector2 oldPosition2; private float distance = 0; private bool flag = false; //Camera location private float x = 0f; private float y = 0f; //Sliding speed left and right public float xSpeed = 250f; public float ySpeed = 120f; //Scale limit factor public float yMinLimit = -360; public float yMaxLimit = 360; //Whether to rotate? private bool isRotate = true; //Counter private float count = 0; public static Test01 _instance; //Initialize game information settings void Start() { _instance = this; Vector3 angles = transform.eulerAngles; x = angles.y; y = angles.x; if (GetComponent<Rigidbody>()) GetComponent<Rigidbody>().freezeRotation = true; } // Update is called once per frame void Update() { if (isRotate) { target.transform.Rotate(Vector3.down, Time.deltaTime * moveSpeed, Space.World); } if (!isRotate) { count += Time.deltaTime; if (count > 5) { count = 0; isRotate = true; } } //Touch type is mobile touch if (Input.GetMouseButton(0)) { //Calculate X and Y positions based on touch points x += Input.GetAxis("Mouse X") * xSpeed * Time.deltaTime; y -= Input.GetAxis("Mouse Y") * ySpeed * Time.deltaTime; isRotate = false; } //Judge whether the mouse wheel is input float temp = Input.GetAxis("Mouse ScrollWheel"); if (temp != 0) { if (temp > 0) { // The data here is adjusted according to the model in my project, and you can modify it yourself if (distance > -15) { distance -= 0.5f; } } if (temp < 0) { // The data here is adjusted according to the model in my project, and you can modify it yourself if (distance < 20) { distance += 0.5f; } } } } //Calculate the distance and judge whether to enlarge or reduce. Zoom in returns true, zoom out returns false bool IsEnlarge(Vector2 oP1, Vector2 oP2, Vector2 nP1, Vector2 nP2) { //old distance float oldDistance = Mathf.Sqrt((oP1.x - oP2.x) * (oP1.x - oP2.x) + (oP1.y - oP2.y) * (oP1.y - oP2.y)); //new distance float newDistance = Mathf.Sqrt((nP1.x - nP2.x) * (nP1.x - nP2.x) + (nP1.y - nP2.y) * (nP1.y - nP2.y)); if (oldDistance < newDistance) { //zoom+ return true; } else { //zoom- return false; } } //Every frame, after Update void LateUpdate() { if (target) { //Reset camera position y = ClampAngle(y, yMinLimit, yMaxLimit); var rotation = Quaternion.Euler(y, x, 0); var position = rotation * (new Vector3(0.0f, 0.0f, -distance)) + target.transform.position; transform.rotation = rotation; transform.position = position; } } float ClampAngle(float angle, float min, float max) { if (angle < -360) angle += 360; if (angle > 360) angle -= 360; return Mathf.Clamp(angle, min, max); } }
Add a Target to the Target.
At this time, panoramic photos can be used like 720 cloud and other software.
3, Add a small app
The function is to display the name of the object contacted by the mouse in the panorama. When clicking the object, the attribute information of the object will pop up.
Create an empty object and add a Collider to it
Move the Edit Collider to the appropriate position, as shown in the figure:
Add code
using UnityEngine; using System.Collections; public class Cube : MonoBehaviour { // public Transform cube; bool isShowTip; public bool WindowShow = false; // // Use this for initialization void Start() { isShowTip = false; } void OnMouseEnter() { isShowTip = true; //Debug.Log (cube.name); / / you can get the name of the object } void OnMouseExit() { isShowTip = false; } void OnGUI() { if (isShowTip) { GUIStyle style1 = new GUIStyle(); style1.fontSize = 30; style1.normal.textColor = Color.red; GUI.Label(new Rect(Input.mousePosition.x, Screen.height - Input.mousePosition.y, 400, 50), "Water dispenser", style1); } if (WindowShow) GUI.Window(0, new Rect(30, 30, 200, 100), MyWindow, "Water dispenser!"); } //dialog procedure void MyWindow(int WindowID) { GUILayout.Label("Equipment for daily drinking water"); } //Mouse click event void OnMouseDown() { Debug.Log("show"); if (WindowShow) WindowShow = false; else WindowShow = true; } }
Done.
Ice city wiggler Published 4 original articles, won praise 1, visited 243 Private letter follow