コード例 #1
0
 private static void onAnchorUpdated(InsightARAnchorData anchor, IntPtr pHandler)
 {
     if (anchor.type == InsightARAnchorType.Plane)
     {
         InsightARPlaneAnchor arPlaneAnchor = InsightARUtility.GetPlaneAnchorFromAnchorData(anchor);
         listAnchorsToUpdate.Add(arPlaneAnchor);
     }
 }
コード例 #2
0
        private InsightARPlaneAnchor DuplicatePlane(InsightARPlaneAnchor anchor)
        {
            InsightARPlaneAnchor temp = new InsightARPlaneAnchor()
            {
                identifier = anchor.identifier,
                rotation   = anchor.rotation,
                center     = anchor.center,
                extent     = anchor.extent,
                isValid    = anchor.isValid
            };

            return(temp);
        }
コード例 #3
0
        public static InsightARPlaneAnchor GetPlaneAnchorFromAnchorData(InsightARAnchorData anchor)
        {
            InsightARPlaneAnchor arPlaneAnchor = new InsightARPlaneAnchor();

            arPlaneAnchor.identifier = string.Copy(anchor.identifier);
                        #if UNITY_ANDROID
            if (InsightARNative.isUseHWAR())
            {
                float[]   tran = new float[] { anchor.center.x, anchor.center.y, anchor.center.z };
                float[]   quat = new float[] { anchor.rotation.x, anchor.rotation.y, anchor.rotation.z, anchor.rotation.w };
                Matrix4x4 glWorld_T_glLocal = Matrix4x4.TRS(
                    new Vector3(tran [0], tran [1], tran [2]),
                    new Quaternion(quat [0], quat [1], quat [2], quat [3]), Vector3.one
                    );
                Matrix4x4 unityWorld_T_glWorld    = Matrix4x4.Scale(new Vector3(1, 1, -1));
                Matrix4x4 unityWorld_T_unityLocal = unityWorld_T_glWorld * glWorld_T_glLocal * unityWorld_T_glWorld.inverse;
                arPlaneAnchor.center = unityWorld_T_unityLocal.GetColumn(3);

                arPlaneAnchor.rotation = Quaternion.LookRotation(unityWorld_T_unityLocal.GetColumn(2), unityWorld_T_unityLocal.GetColumn(1));
                arPlaneAnchor.extent   = new Vector3(anchor.extent.x, 1.0f, anchor.extent.z);
            }
            else
                        #endif
            {
                Matrix4x4 matrix = new Matrix4x4();
                matrix.SetColumn(0, new Vector4(anchor.transform.column0.x, anchor.transform.column0.y, anchor.transform.column0.z, anchor.transform.column0.w));
                matrix.SetColumn(1, new Vector4(anchor.transform.column1.x, anchor.transform.column1.y, anchor.transform.column1.z, anchor.transform.column1.w));
                matrix.SetColumn(2, new Vector4(anchor.transform.column2.x, anchor.transform.column2.y, anchor.transform.column2.z, anchor.transform.column2.w));
                matrix.SetColumn(3, new Vector4(anchor.transform.column3.x, anchor.transform.column3.y, anchor.transform.column3.z, anchor.transform.column3.w));
                arPlaneAnchor.rotation = GetRotation(matrix);
                arPlaneAnchor.extent   = new Vector3(anchor.extent.x, anchor.extent.y, anchor.extent.z);
                                #if UNITY_ANDROID
                arPlaneAnchor.center = new Vector3(anchor.center.x, anchor.center.y, anchor.center.z);
                #elif UNITY_IOS
                arPlaneAnchor.center = GetPosition(matrix);
                //Debug.Log(arPlaneAnchor.center.ToString("f3"));
                #endif
                arPlaneAnchor.isValid = anchor.isValid;
            }
            return(arPlaneAnchor);
        }