Exemple #1
0
    //***********  INIT  ***********//

    void Start()
    {
        // Set the target frame rate to be 60FPS
        Application.targetFrameRate = 60;

        // Initialize the bridge between Unity and the ARKit Native functions/structures
        m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();

        // Create the configuration struct for this ARKit session
        ARKitFaceTrackingConfiguration config = new ARKitFaceTrackingConfiguration();

        config.alignment             = UnityARAlignment.UnityARAlignmentGravity;
        config.enableLightEstimation = true;

        // If the config file looks good, start the ARKIT session and add FaceAdded, FaceUpdated, and FaceRemoved as callback functions on ARKit events
        if (config.IsSupported)
        {
            m_session.RunWithConfig(config);

            UnityARSessionNativeInterface.ARFaceAnchorAddedEvent   += FaceAdded;
            UnityARSessionNativeInterface.ARFaceAnchorUpdatedEvent += FaceUpdated;
            UnityARSessionNativeInterface.ARFaceAnchorRemovedEvent += FaceRemoved;
        }

        // Fire the init/start functions necessary for Peertalk
        PTCToCBridge.CallPTConnect();

        // Instantiate the blendshape GUI style
        blendshapeGUIstyle          = new GUIStyle();
        blendshapeGUIstyle.font     = yikes;
        blendshapeGUIstyle.fontSize = 30;
    }
    // Use this for initialization
    void Start()
    {
        m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();

        Application.targetFrameRate = 60;
        ARKitFaceTrackingConfiguration config = new ARKitFaceTrackingConfiguration();

        config.alignment             = UnityARAlignment.UnityARAlignmentGravity;
        config.enableLightEstimation = true;

        if (config.IsSupported)
        {
            m_session.RunWithConfig(config);

            UnityARSessionNativeInterface.ARFaceAnchorAddedEvent   += FaceAdded;
            UnityARSessionNativeInterface.ARFaceAnchorUpdatedEvent += FaceUpdated;
            UnityARSessionNativeInterface.ARFaceAnchorRemovedEvent += FaceRemoved;
        }

        leftEyeGo = GameObject.Instantiate(eyePrefab);
        // Debug.Log(peos.leftEye.name);
        // Debug.Log(peos.leftEye.transform.position);
        // Debug.Log(leftEyeGo.transform.position);


        peos.leftEye.transform.SetParent(leftEyeGo.transform);
        rightEyeGo = GameObject.Instantiate(eyePrefab);
        peos.RightEye.transform.SetParent(rightEyeGo.transform);

        leftEyeGo.SetActive(false);
        rightEyeGo.SetActive(false);
    }
Exemple #3
0
    void Start()
    {
        UnityARSessionNativeInterface session = UnityARSessionNativeInterface.GetARSessionNativeInterface();

        Application.targetFrameRate = 60;
        ARKitFaceTrackingConfiguration config = new ARKitFaceTrackingConfiguration();

        config.alignment             = UnityARAlignment.UnityARAlignmentGravity;
        config.enableLightEstimation = true;

        if (!config.IsSupported)
        {
            return;
        }

        session.RunWithConfig(config);

        UnityARSessionNativeInterface.ARFaceAnchorAddedEvent   += FaceAdd;
        UnityARSessionNativeInterface.ARFaceAnchorUpdatedEvent += FaceUpdate;
        UnityARSessionNativeInterface.ARFaceAnchorRemovedEvent += FaceRemove;

        RightEye = Instantiate(BasePosition);
        LeftEye  = Instantiate(BasePosition);

        LeftEye.SetActive(false);
        RightEye.SetActive(false);
    }
    // Use this for initialization
    void Start()
    {
        m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();

        Application.targetFrameRate = 60;
        ARKitFaceTrackingConfiguration config = new ARKitFaceTrackingConfiguration();

        //config.alignment = UnityARAlignment.UnityARAlignmentGravity; // using gravity alignment enables orientation (3DOF) tracking of device camera. we don't need it
        config.alignment = UnityARAlignment.UnityARAlignmentCamera;

        config.enableLightEstimation = true;


        if (config.IsSupported)
        {
            m_session.RunWithConfig(config);

            UnityARSessionNativeInterface.ARFaceAnchorAddedEvent   += FaceAdded;
            UnityARSessionNativeInterface.ARFaceAnchorUpdatedEvent += FaceUpdated;
            UnityARSessionNativeInterface.ARFaceAnchorRemovedEvent += FaceRemoved;
            //UnityARSessionNativeInterface.ARFrameUpdatedEvent += FrameUpdate; //can't get the light direction estimate to work for some reason, it freezes the app
        }
        else
        {
            Debug.Log("ARKitFaceTrackingConfiguration not supported");
        }
    }
Exemple #5
0
        void Start()
        {
            // ComputeShader側に渡す各種パラメータ
            _vertexCountID    = Shader.PropertyToID("VertexCount");
            _transformID      = Shader.PropertyToID("Transform");
            _positionBufferID = Shader.PropertyToID("PositionBuffer");
            _positionMapID    = Shader.PropertyToID("PositionMap");

            // 以下はARKit周りの初期化
            _session = UnityARSessionNativeInterface.GetARSessionNativeInterface();

            Application.targetFrameRate = 60;
            var config = new ARKitFaceTrackingConfiguration();

            config.alignment             = UnityARAlignment.UnityARAlignmentGravity;
            config.enableLightEstimation = true;

            if (config.IsSupported)
            {
                _session.RunWithConfig(config);
                UnityARSessionNativeInterface.ARFaceAnchorAddedEvent   += FaceAdded;
                UnityARSessionNativeInterface.ARFaceAnchorUpdatedEvent += FaceUpdated;
                UnityARSessionNativeInterface.ARFaceAnchorRemovedEvent += FaceRemoved;
            }
        }
Exemple #6
0
    private void RunARkit(ARKitFaceTrackingConfiguration configuration)
    {
        if (configuration.IsSupported && m_currentARkitStatus == false)
        {
            onSessionIsReady?.Invoke();

            m_session.RunWithConfig(configuration);
            m_currentARkitStatus = true;
        }
    }
Exemple #7
0
        private void Start()
        {
            m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();

            Application.targetFrameRate = 60;
            ARKitFaceTrackingConfiguration config = new ARKitFaceTrackingConfiguration();

            // ARではなくてAvatarシステムとかだと非Gravityが楽
            config.alignment             = UnityARAlignment.UnityARAlignmentCamera;
            config.enableLightEstimation = true;

            if (config.IsSupported)
            {
                m_session.RunWithConfig(config);
                UnityARSessionNativeInterface.ARFaceAnchorUpdatedEvent += FaceUpdated;
            }
        }
Exemple #8
0
    public void ExampletButtonPressed(UnityARVideoFormat videoFormat)
    {
        UnityARSessionNativeInterface session = UnityARSessionNativeInterface.GetARSessionNativeInterface();

        var config = new ARKitFaceTrackingConfiguration();

        if (config.IsSupported)
        {
            config.alignment             = UnityARAlignment.UnityARAlignmentGravity;
            config.enableLightEstimation = true;
            config.videoFormat           = videoFormat.videoFormatPtr;
            Application.targetFrameRate  = videoFormat.framesPerSecond;

            UnityARSessionRunOption runOption = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking;
            session.RunWithConfigAndOptions(config, runOption);
        }
    }
    // Use this for initialization
    void Start()
    {
        m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();

        Application.targetFrameRate = 60;
        ARKitFaceTrackingConfiguration config = new ARKitFaceTrackingConfiguration();

        config.alignment             = UnityARAlignment.UnityARAlignmentGravity;
        config.enableLightEstimation = true;

        if (config.IsSupported)
        {
            m_session.RunWithConfig(config);

            UnityARSessionNativeInterface.ARFaceAnchorAddedEvent   += FaceAdded;
            UnityARSessionNativeInterface.ARFaceAnchorUpdatedEvent += FaceUpdated;
            UnityARSessionNativeInterface.ARFaceAnchorRemovedEvent += FaceRemoved;
        }
    }
Exemple #10
0
    //***********  TRACKER INIT / START / PAUSE  ***********//

    public void ARKitTrackerStart()
    {
        // Initialize the bridge between Unity and the ARKit Native functions/structures
        m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();

        // Create the configuration struct for this ARKit session
        config                       = new ARKitFaceTrackingConfiguration();
        config.alignment             = UnityARAlignment.UnityARAlignmentGravity;
        config.enableLightEstimation = true;

        // If the config file looks good, start the ARKIT session and add FaceAdded, FaceUpdated, and FaceRemoved as callback functions on ARKit events
        if (config.IsSupported)
        {
            m_session.RunWithConfig(config);

            UnityARSessionNativeInterface.ARFaceAnchorAddedEvent   += FaceAdded;
            UnityARSessionNativeInterface.ARFaceAnchorUpdatedEvent += FaceUpdated;
            UnityARSessionNativeInterface.ARFaceAnchorRemovedEvent += FaceRemoved;
        }
    }
Exemple #11
0
        // Use this for initialization
        private void Start()
        {
            m_Session = UnityARSessionNativeInterface.GetARSessionNativeInterface();

            Application.targetFrameRate = 60;
            var config = new ARKitFaceTrackingConfiguration
            {
                alignment = UnityARAlignment.UnityARAlignmentGravity, enableLightEstimation = false
            };

            if (config.IsSupported != null)
            {
                m_Session.RunWithConfig(config);

                UnityARSessionNativeInterface.ARFaceAnchorAddedEvent   += FaceAdded;
                UnityARSessionNativeInterface.ARFaceAnchorUpdatedEvent += FaceUpdated;
                UnityARSessionNativeInterface.ARFaceAnchorRemovedEvent += FaceRemoved;
            }

            ForceUpdateValue();
        }
    // Use this for initialization
    void Start()
    {
        // Set up Facetracking configurations
        m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();

        Application.targetFrameRate = 60;
        ARKitFaceTrackingConfiguration config = new ARKitFaceTrackingConfiguration();

        config.alignment             = UnityARAlignment.UnityARAlignmentGravity;
        config.enableLightEstimation = true;

        if (config.IsSupported && meshFilter != null)
        {
            m_session.RunWithConfig(config);

            /* This code subscribes our methods FaceAdded, FaceUpdated, & FaceRemoved to
             * ARKit's Events, meaning our functions will be called when these events occur. */
            UnityARSessionNativeInterface.ARFaceAnchorAddedEvent   += FaceAdded;
            UnityARSessionNativeInterface.ARFaceAnchorUpdatedEvent += FaceUpdated;
            UnityARSessionNativeInterface.ARFaceAnchorRemovedEvent += FaceRemoved;
        }
    }
Exemple #13
0
        void Awake()
        {
            m_Camera = Camera.main;
#if UNITY_IOS
            var config = new ARKitFaceTrackingConfiguration();
            if (config.IsSupported)
            {
                m_MainGUI.enabled = false;
                m_FaceLostGUI.enabled = false;
                m_NotSupportedGUI.enabled = false;
            }
            else
            {
#endif
                m_MainGUI.enabled = false;
                m_FaceLostGUI.enabled = false;
                m_NotSupportedGUI.enabled = true;
                enabled = false;
#if UNITY_IOS
            }
#endif
        }
    private void Start()
    {
        m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();

        Application.targetFrameRate = 60;
        ARKitFaceTrackingConfiguration config = new ARKitFaceTrackingConfiguration();

        config.alignment             = UnityARAlignment.UnityARAlignmentGravity;
        config.enableLightEstimation = true;

        if (config.IsSupported)
        {
            m_session.RunWithConfig(config);

            UnityARSessionNativeInterface.ARFaceAnchorAddedEvent   += FaceAdded;
            UnityARSessionNativeInterface.ARFaceAnchorUpdatedEvent += FaceUpdated;
            UnityARSessionNativeInterface.ARFaceAnchorRemovedEvent += FaceRemoved;
        }

        defaultRotation = headJoint.localRotation;
        StartCoroutine(DisactiveAnimator());
    }
Exemple #15
0
    void Start()
    {
        m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();

        Application.targetFrameRate = 60;
        ARKitFaceTrackingConfiguration config = new ARKitFaceTrackingConfiguration();

        config.alignment             = UnityARAlignment.UnityARAlignmentGravity;
        config.enableLightEstimation = true;

        if (config.IsSupported)
        {
            m_session.RunWithConfig(config);
            UnityARSessionNativeInterface.ARFaceAnchorAddedEvent   += FaceAdded;
            UnityARSessionNativeInterface.ARFaceAnchorUpdatedEvent += FaceUpdated;
            UnityARSessionNativeInterface.ARFaceAnchorRemovedEvent += FaceRemoved;
        }

        if (ExpresionConfigurations == null || ExpresionConfigurations.Length == 0)
        {
            Debug.Log("You must set at least one expression to use the ExpressionManager.cs");
        }
        IsConfigured = true;

        CreateDebugOverlays();

        CleanUp();

        if (headPrefab != null)
        {
            headGameObject = Instantiate(headPrefab) as GameObject;
        }
        if (eyePrefab != null)
        {
            eyeLeft  = Instantiate(eyePrefab) as GameObject;
            eyeRight = Instantiate(eyePrefab) as GameObject;
        }
    }
Exemple #16
0
    public void Run(MonoBehaviour behaviour)
    {
        this.behaviour = behaviour;
        var config = new ARKitFaceTrackingConfiguration();

        if (!config.IsSupported)
        {
            throw new NotSupportedException();
        }

        config.enableLightEstimation = true;
        UnityARSessionNativeInterface.GetARSessionNativeInterface().RunWithConfigAndOptions(config, UnityARSessionRunOption.ARSessionRunOptionResetTracking);
        faceDataAdapter.Run(this);
        faceVideo.Run(this);
        stop        = false;
        FaceProcess = new RenderTexture(1024, 1024, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear);
        //后处理图片

        ResultTexture = new RenderTexture(FaceProcess.descriptor)
        {
            name = "result.texture",
        };
    }
Exemple #17
0
    // Use this for initialization
    void Start()
    {
        _faceMat = _meshRenderer.sharedMaterial;

        _faceMatrix = Matrix4x4.identity;

        m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();

        Application.targetFrameRate = 60;
        ARKitFaceTrackingConfiguration config = new ARKitFaceTrackingConfiguration();

        config.alignment             = UnityARAlignment.UnityARAlignmentGravity;
        config.enableLightEstimation = true;

        if (config.IsSupported && meshFilter != null)
        {
            m_session.RunWithConfig(config);

            UnityARSessionNativeInterface.ARFaceAnchorAddedEvent   += FaceAdded;
            UnityARSessionNativeInterface.ARFaceAnchorUpdatedEvent += FaceUpdated;
            UnityARSessionNativeInterface.ARFaceAnchorRemovedEvent += FaceRemoved;
        }
    }
Exemple #18
0
    void Start()
    {
        m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();

        Application.targetFrameRate = 100;
        ARKitFaceTrackingConfiguration config = new ARKitFaceTrackingConfiguration();

        config.alignment             = UnityARAlignment.UnityARAlignmentGravity;
        config.enableLightEstimation = true;

        if (config.IsSupported)
        {
            m_session.RunWithConfig(config);

            UnityARSessionNativeInterface.ARFaceAnchorAddedEvent   += FaceAdded;
            UnityARSessionNativeInterface.ARFaceAnchorUpdatedEvent += FaceUpdated;
            UnityARSessionNativeInterface.ARFaceAnchorRemovedEvent += FaceRemoved;
        }
        defaultRotation = headJoint.localRotation;

#if UNITY_EDITOR
        locator.gameObject.SetActive(true);
#endif
    }
    // Use this for initialization
    void Start()
    {
        isPlaying = false;
        isSmiling = false;

        m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();

        Application.targetFrameRate = 60;
        ARKitFaceTrackingConfiguration config = new ARKitFaceTrackingConfiguration();

        config.alignment             = UnityARAlignment.UnityARAlignmentGravity;
        config.enableLightEstimation = true;

        if (config.IsSupported)
        {
            m_session.RunWithConfig(config);

            UnityARSessionNativeInterface.ARFaceAnchorAddedEvent   += FaceAdded;
            UnityARSessionNativeInterface.ARFaceAnchorUpdatedEvent += FaceUpdated;
            UnityARSessionNativeInterface.ARFaceAnchorRemovedEvent += FaceRemoved;
        }
        initializeCallouts();
        anim = GetComponent <Animator>();
    }
Exemple #20
0
    public void RunSpecificConfiguration(ConfigurationType type)
    {
        switch (type)
        {
        case ConfigurationType.FaceTracking:
            ARKitFaceTrackingConfiguration faceTrackingConfig = new ARKitFaceTrackingConfiguration();
            RunARkit(faceTrackingConfig);
            break;

        case ConfigurationType.ObjectScanning:
            ARKitObjectScanningSessionConfiguration objectScanningConfig = new ARKitObjectScanningSessionConfiguration();
            RunARkit(objectScanningConfig);
            break;

        case ConfigurationType.WorldTracking:
            ARKitWorldTrackingSessionConfiguration worldTrackingConfig = new ARKitWorldTrackingSessionConfiguration();
            RunARkit(worldTrackingConfig);
            break;

        default:
            Debug.Log("your config type is wrong!");
            break;
        }
    }
Exemple #21
0
    void InitializeARSession()
    {
        Session = UnityARSessionNativeInterface.GetARSessionNativeInterface();
        ARKitFaceTrackingConfiguration configuration = new ARKitFaceTrackingConfiguration();

        configuration.alignment             = UnityARAlignment.UnityARAlignmentGravity;
        configuration.enableLightEstimation = true;
        //オプションを追加
        var options = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking;

        if (configuration.IsSupported)
        {
            UnityARSessionNativeInterface.ARFaceAnchorAddedEvent   += FaceAdd;
            UnityARSessionNativeInterface.ARFaceAnchorUpdatedEvent += FaceUpdate;
            UnityARSessionNativeInterface.ARFaceAnchorRemovedEvent += FaceRemoved;
        }
        else
        {
            // 利用できない場合の処理
        }

        //オプションをセット
        Session.RunWithConfigAndOptions(configuration, options);
    }