Пример #1
0
 /// <summary>
 /// The Unity Awake() method.
 /// </summary>
 public void Awake()
 {
     // Enable ARCore to target 60fps camera capture frame rate on supported devices.
     // Note, Application.targetFrameRate is ignored when QualitySettings.vSyncCount != 0.
     Application.targetFrameRate = 60;
     AH_PlaneFindingMode         = DetectedPlaneFindingMode.Horizontal;//수평면만 감지하도록 설정
 }
Пример #2
0
 /// <summary>
 /// ValueType copy from another SessionConfig object into this one.
 /// </summary>
 /// <param name="other">The SessionConfig to copy from.</param>
 public void CopyFrom(ARCoreSessionConfig other)
 {
     MatchCameraFramerate   = other.MatchCameraFramerate;
     PlaneFindingMode       = other.PlaneFindingMode;
     EnableLightEstimation  = other.EnableLightEstimation;
     EnableCloudAnchor      = other.EnableCloudAnchor;
     AugmentedImageDatabase = other.AugmentedImageDatabase;
 }
 /// <summary>
 /// ValueType copy from another SessionConfig object into this one.
 /// </summary>
 /// <param name="other">The SessionConfig to copy from.</param>
 public void CopyFrom(ARCoreSessionConfig other)
 {
     MatchCameraFramerate   = other.MatchCameraFramerate;
     PlaneFindingMode       = other.PlaneFindingMode;
     LightEstimationMode    = other.LightEstimationMode;
     CloudAnchorMode        = other.CloudAnchorMode;
     AugmentedImageDatabase = other.AugmentedImageDatabase;
     CameraFocusMode        = other.CameraFocusMode;
     AugmentedFaceMode      = other.AugmentedFaceMode;
 }
        public static ApiPlaneFindingMode ToApiPlaneFindingMode(this DetectedPlaneFindingMode mode)
        {
            switch (mode)
            {
            case DetectedPlaneFindingMode.Disabled:
                return(ApiPlaneFindingMode.Disabled);

            case DetectedPlaneFindingMode.Horizontal:
                return(ApiPlaneFindingMode.Horizontal);

            case DetectedPlaneFindingMode.Vertical:
                return(ApiPlaneFindingMode.Vertical);

            case DetectedPlaneFindingMode.HorizontalAndVertical:
                return(ApiPlaneFindingMode.HorizontalAndVertical);

            default:
                Debug.LogErrorFormat("Unexpected DetectedPlaneFindingMode {0}", mode);
                return(ApiPlaneFindingMode.Disabled);
            }
        }
Пример #5
0
    /// <summary>
    /// The Unity Update() method.
    /// </summary>
    public void Update()
    {
        _UpdateApplicationLifecycle();

        // If the player has not touched the screen, we are done with this update.
        Touch touch;

        if (Input.touchCount < 1 || (touch = Input.GetTouch(0)).phase != TouchPhase.Began)
        {
            return;
        }

        // Should not handle input if the player is pointing on UI.
        if (EventSystem.current.IsPointerOverGameObject(touch.fingerId))
        {
            return;
        }

        // Raycast against the location the player touched to search for planes.
        TrackableHit      hit;
        TrackableHitFlags raycastFilter = TrackableHitFlags.PlaneWithinPolygon |
                                          TrackableHitFlags.FeaturePointWithSurfaceNormal;

        //Ray를 쏴서 감지된 평면에 닿으면 정해진 오브젝트 설치
        if (Frame.Raycast(touch.position.x, touch.position.y, raycastFilter, out hit))
        {
            // Use hit pose and camera pose to check if hittest is from the
            // back of the plane, if it is, no need to create the anchor.
            if ((hit.Trackable is DetectedPlane) &&
                Vector3.Dot(FirstPersonCamera.transform.position - hit.Pose.position,
                            hit.Pose.rotation * Vector3.up) < 0)
            {
                Debug.Log("Hit at back of the current DetectedPlane");
            }
            else
            {
                // Choose the Andy model for the Trackable that got hit.
                GameObject prefab;
                if (hit.Trackable is FeaturePoint)
                {
                    prefab = AndyPointPrefab;
                }
                else if (hit.Trackable is DetectedPlane)
                {
                    DetectedPlane detectedPlane = hit.Trackable as DetectedPlane;
                    if (detectedPlane.PlaneType == DetectedPlaneType.Vertical)
                    {
                        prefab = AndyVerticalPlanePrefab;
                    }
                    else
                    {
                        //Ray가 맞은 곳이 감지된 평면이고 그게 수평면이면 정해진것을 설치
                        prefab = AndyHorizontalPlanePrefab;
                    }
                }
                else
                {
                    prefab = AndyHorizontalPlanePrefab;
                }

                var andyObject = Instantiate(prefab, hit.Pose.position, hit.Pose.rotation); // 설치Instantiate Andy model at the hit pose.
                AH_PlaneFindingMode = DetectedPlaneFindingMode.Disabled;

                // Compensate for the hitPose rotation facing away from the raycast (i.e.
                // camera).
                andyObject.transform.Rotate(0, k_ModelRotation, 0, Space.Self);

                // Create an anchor to allow ARCore to track the hitpoint as understanding of
                // the physical world evolves.
                var anchor = hit.Trackable.CreateAnchor(hit.Pose);

                // Make Andy model a child of the anchor.
                andyObject.transform.parent = anchor.transform;
            }
        }
    }