コード例 #1
0
ファイル: CreateMap.cs プロジェクト: yhtingg/NaviNUS
    // Update is called once per frame
    void Update()
    {
        if (!mARInit && LibPlacenote.Instance.Initialized())
        {
            Debug.Log("Ready To Start!");
            mARInit = true;

            return;
        }

        if (shouldRecordWaypoints)
        {
            Transform player = Camera.main.transform;
            //create waypoints if there are none around
            Collider[] hitColliders = Physics.OverlapSphere(player.position, 1f);
            int        i            = 0;
            while (i < hitColliders.Length)
            {
                if (hitColliders[i].CompareTag("waypoint"))
                {
                    return;
                }
                i++;
            }
            Vector3 pos = player.position;
            Debug.Log(player.position);
            pos.y = -.5f;
            shapeManager.AddShape(pos, Quaternion.Euler(Vector3.zero), false);
        }
    }
コード例 #2
0
    // Update is called once per frame
    void Update()
    {
        if (!ARSessionReady)
        {
            return;
        }

        if (shouldRecordWaypoints)
        {
            Transform player = Camera.main.transform;
            //create waypoints if there are none around
            Collider[] hitColliders = Physics.OverlapSphere(player.position, 1f);
            int        i            = 0;
            while (i < hitColliders.Length)
            {
                if (hitColliders[i].CompareTag("waypoint"))
                {
                    return;
                }
                i++;
            }
            Vector3 pos = player.position;
            //Debug.Log(player.position);
            pos.y = -.5f;

            if (!hasSetStartingPoint)
            {
                //set start point
                hasSetStartingPoint = true;
                mShapeManager.AddShape(pos, Quaternion.Euler(Vector3.zero), true, false);
            }
            else
            {
                //set waypoints
                mShapeManager.AddShape(pos, Quaternion.Euler(Vector3.zero), false, false);
            }
        }
    }
コード例 #3
0
    // Update is called once per frame
    void Update()
    {
        if (mFrameUpdated)
        {
            mFrameUpdated = false;
            if (mImage == null)
            {
                InitARFrameBuffer();
            }

            if (mARCamera.trackingState == ARTrackingState.ARTrackingStateNotAvailable)
            {
                // ARKit pose is not yet initialized
                return;
            }
            else if (!mARKitInit && LibPlacenote.Instance.Initialized())
            {
                mARKitInit = true;
                Debug.Log("ARKit + placenote Initialized");
                StartSavingMap();
            }

            Matrix4x4 matrix = mSession.GetCameraPose();

            Vector3    arkitPosition = PNUtility.MatrixOps.GetPosition(matrix);
            Quaternion arkitQuat     = PNUtility.MatrixOps.GetRotation(matrix);

            LibPlacenote.Instance.SendARFrame(mImage, arkitPosition, arkitQuat, mARCamera.videoParams.screenOrientation);

            if (shouldRecordWaypoints)
            {
                Transform player = Camera.main.transform;
                //create waypoints if there are none around
                Collider[] hitColliders = Physics.OverlapSphere(player.position, 1f);
                int        i            = 0;
                while (i < hitColliders.Length)   // a loop to check if there's any waypoint around in the radius of 1 meter, if there is return, doing nothing
                {
                    if (hitColliders[i].CompareTag("waypoint"))
                    {
                        return;
                    }
                    i++;
                }
                Vector3 pos = player.position; //if there are no way point add shape
                Debug.Log(player.position);
                pos.y = -.5f;
                shapeManager.AddShape(pos, Quaternion.Euler(Vector3.zero), false);
            }
        }
    }