Example #1
0
    /// <summary>
    /// <see cref="Info"/>를 바탕으로 Unity 공간에 3D 오브젝트를 생성하고 GameObj 멤버에 그 참조를 할당하는 코루틴.
    /// </summary>
    private IEnumerator CreateObject()
    {
        // 초기 포지션 설정
        Vector3 unityPosition = GpsCalulator.CoordinateDifference(ClientInfoObj.StartingLatitude, ClientInfoObj.StartingLongitude, ClientInfoObj.StartingAltitude,
                                                                  Info.GpsInfo[0], Info.GpsInfo[1], Info.GpsInfo[2]);

        GameObj      = createObject(Info.typeName, unityPosition);
        GameObj.name = Info.typeName;
        // 타입 지정
        ObjectType = ArObjectType.Ar3dObject;
        // 3D object의 DataContainer에 값 패싱
        GameObj.AddComponent <DataContainer>().AdNum = Info.ObjectNumber;
        GameObj.GetComponent <DataContainer>().CreatedCameraPosition =
            new Vector3(ClientInfoObj.MainCamera.transform.position.x, ClientInfoObj.MainCamera.transform.position.y, ClientInfoObj.MainCamera.transform.position.z);
        GameObj.GetComponent <DataContainer>().ObjectType = ArObjectType.Ar3dObject;

        // GPS 정보를 사용하기 위해 GPS 초기화가 안된 경우 대기.
        if (Application.platform == RuntimePlatform.Android)
        {
            yield return(new WaitUntil(() => ClientInfoObj.OriginalValuesAreSet));
        }

        unityPosition.y = 0; // 고도 사용 안함.

        GameObj.transform.position    = unityPosition;
        GameObj.transform.eulerAngles = new Vector3(0, Info.Bearing, 0);
        GameObj.transform.RotateAround(ClientInfoObj.MainCamera.transform.position, new Vector3(0.0f, 1.0f, 0.0f), -ClientInfoObj.CorrectedBearingOffset); // 카메라 포지션 기준 회전
    }
Example #2
0
    /// <summary>
    /// <see cref="Info"/>를 바탕으로 Unity 공간에 Plane 오브젝트를 생성하고 GameObj 멤버에 그 참조를 할당하는 코루틴.
    /// </summary>
    private IEnumerator CreateObject()
    {
        ObjectType   = ArObjectType.AdPlane; // 타입 지정
        GameObj      = GameObject.CreatePrimitive(PrimitiveType.Plane);
        GameObj.name = Info.Name;
        // Plane object의 DataContainer에 값 패싱
        GameObj.AddComponent <DataContainer>().BannerUrl             = Info.BannerUrl; // URL 정보를 담을 DataContainer Component추가
        GameObj.GetComponent <DataContainer>().AdNum                 = Info.AdNumber;
        GameObj.GetComponent <DataContainer>().CreatedCameraPosition =
            new Vector3(ClientInfoObj.MainCamera.transform.position.x, ClientInfoObj.MainCamera.transform.position.y, ClientInfoObj.MainCamera.transform.position.z);
        GameObj.GetComponent <DataContainer>().ObjectType = ArObjectType.AdPlane;

        // GPS 정보를 사용하기 위해 GPS 초기화가 안된 경우 대기.
        if (Application.platform == RuntimePlatform.Android)
        {
            yield return(new WaitUntil(() => ClientInfoObj.OriginalValuesAreSet));
        }

        // 초기 포지션 설정
        Vector3 unityPosition = GpsCalulator.CoordinateDifference(ClientInfoObj.StartingLatitude, ClientInfoObj.StartingLongitude, ClientInfoObj.StartingAltitude,
                                                                  Info.GpsInfo[0], Info.GpsInfo[1], Info.GpsInfo[2]);

        unityPosition.y = 0; // 고도 사용 안함.

        GameObj.transform.localScale  = new Vector3(Info.Width, Info.Height, Info.Height);
        GameObj.transform.position    = unityPosition;
        GameObj.transform.eulerAngles = new Vector3(90.0f, Info.Bearing - 90.0f, 90.0f);
        GameObj.transform.RotateAround(ClientInfoObj.MainCamera.transform.position, new Vector3(0.0f, 1.0f, 0.0f), ClientInfoObj.CorrectedBearingOffset); // 카메라 포지션 기준 회전
        // GameOBJ.transform.rotation = Quaternion.Euler(90.0f, -90.0f, 90.0f);
        // 모든 plane은 new Vector3(90.0f, -90.0f, 90.0f); 만큼 회전해야함
    }
Example #3
0
    /// <summary>
    /// <see cref="_clientInfo"/>의 GPS값을 카메라 위치에 적용한다.
    /// </summary>
    private void UpdateCameraPosition()
    {
        // 지구 상의 방위와 유니티 상의 좌표 매칭:
        //        z:
        //        +
        //        북
        // x: -서    동+ :x
        //        남
        //        -
        //        :z
        // y: 위+
        //    아래-

        // 앱을 켠 순간의 GPS 좌표 (_clientInfo.StartingXXX)에 대응하는 유니티 좌표와
        // 현재 GPS 좌표 (_clientInfo.CurrentXXX)에 대응하는 유니티 좌표의 차를 구한다.
        Vector3 coordinateDifferenceFromStart = GpsCalulator.CoordinateDifference(
            _clientInfo.StartingLatitude, _clientInfo.StartingLongitude, _clientInfo.StartingAltitude,
            _clientInfo.CurrentLatitude, _clientInfo.CurrentLongitude, _clientInfo.StartingAltitude);

        // GPS 고도는 무시
        coordinateDifferenceFromStart.y = 0.0f;

        // 카메라를 유니티 상의 현재 사용자 위치로 옮기기
        _clientInfo.MainCamera.transform.position = coordinateDifferenceFromStart;
    }
Example #4
0
    public void onClickLightBtn()
    {
        Vector3 unityPosition = GpsCalulator.CoordinateDifference(_clientInfo.StartingLatitude, _clientInfo.StartingLongitude, _clientInfo.StartingAltitude, _clientInfo.CurrentLatitude, _clientInfo.CurrentLongitude, 0);

        //Vector3 unityPosition = GpsCalulator.CoordinateDifference(_clientInfo.StartingLatitude, _clientInfo.StartingLongitude, _clientInfo.StartingAltitude, 37.31263f, 126.8481f, 0);
        createObject("light", unityPosition);
        //createObject("horse", 40, -1, 0);
    }