Esempio n. 1
0
 public UnityARCamera(UnityARMatrix4x4 wt, UnityARMatrix4x4 pm, ARTrackingState ats, ARTrackingStateReason atsr, UnityVideoParams uvp, Vector3[] pointCloud)
 {
     worldTransform   = wt;
     projectionMatrix = pm;
     trackingState    = ats;
     trackingReason   = atsr;
     videoParams      = uvp;
     pointCloudData   = pointCloud;
 }
Esempio n. 2
0
        public static UnityARMatrix4x4 GetMatrix(Matrix4x4 nativeMatrix)
        {
            var matrix = new UnityARMatrix4x4();

            matrix.column0 = nativeMatrix.GetColumn(0);
            matrix.column1 = nativeMatrix.GetColumn(1);
            matrix.column2 = nativeMatrix.GetColumn(2);
            matrix.column3 = nativeMatrix.GetColumn(3);

            return(matrix);
        }
Esempio n. 3
0
        public static Matrix4x4 GetMatrix(UnityARMatrix4x4 unityMatrix)
        {
            var matrix = new Matrix4x4();

            matrix.SetColumn(0, unityMatrix.column0);
            matrix.SetColumn(1, unityMatrix.column1);
            matrix.SetColumn(2, unityMatrix.column2);
            matrix.SetColumn(3, unityMatrix.column3);

            return(matrix);
        }
 public UnityARCamera(UnityARMatrix4x4 wt, UnityARMatrix4x4 pm, ARTrackingState ats, ARTrackingStateReason atsr, UnityVideoParams uvp, UnityARLightData lightDat, UnityARMatrix4x4 dt, Vector3[] pointCloud, ARWorldMappingStatus awms)
 {
     worldTransform     = wt;
     projectionMatrix   = pm;
     trackingState      = ats;
     trackingReason     = atsr;
     videoParams        = uvp;
     lightData          = lightDat;
     displayTransform   = dt;
     pointCloudData     = pointCloud;
     worldMappingStatus = awms;
 }
Esempio n. 5
0
        //Written by Chris 13/12/2017
        public static UnityARMatrix4x4 InsertRotation(UnityARMatrix4x4 result, Quaternion q)
        {
            //Adapted from: http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToMatrix/index.htm

            double sqw = q.w * q.w;
            double sqx = q.x * q.x;
            double sqy = q.y * q.y;
            double sqz = q.z * q.z;

            // invs (inverse square length) is only required if quaternion is not already normalised
            double invs = 1 / (sqx + sqy + sqz + sqw);

            float m00 = (float)((sqx - sqy - sqz + sqw) * invs);            // since sqw + sqx + sqy + sqz =1/invs*invs
            float m11 = (float)((-sqx + sqy - sqz + sqw) * invs);
            float m22 = (float)((-sqx - sqy + sqz + sqw) * invs);

            double tmp1 = q.x * q.y;
            double tmp2 = q.z * q.w;
            float  m10  = (float)(2.0 * (tmp1 + tmp2) * invs);
            float  m01  = (float)(2.0 * (tmp1 - tmp2) * invs);

            tmp1 = q.x * q.z;
            tmp2 = q.y * q.w;
            float m20 = (float)(2.0 * (tmp1 - tmp2) * invs);
            float m02 = (float)(2.0 * (tmp1 + tmp2) * invs);

            tmp1 = q.y * q.z;
            tmp2 = q.x * q.w;
            float m21 = (float)(2.0 * (tmp1 + tmp2) * invs);
            float m12 = (float)(2.0 * (tmp1 - tmp2) * invs);

            result.column0 = new Vector4(m00, m10, m20, 0);
            result.column1 = new Vector4(m01, m11, m21, 0);
            result.column2 = new Vector4(m02, m12, m22, 0);


            return(result);
        }
Esempio n. 6
0
 public static Pose GetPose(UnityARMatrix4x4 unityMatrix)
 {
     return(GetPose(GetMatrix(unityMatrix)));
 }
Esempio n. 7
0
 //TODO: finish implementing this.
 //Use this to contrsuct a world transform matrix (from old matrix, with offset values for position and rotation)
 public static UnityARMatrix4x4 offset(UnityARMatrix4x4 m, Vector4 position, Quaternion rotation)
 {
     return(new UnityARMatrix4x4());
 }
Esempio n. 8
0
        //Written by Chris
        //This method is required because of the lack of implicit conversion support between UnityARMatrix4x4 and Matrix4x4
        static Quaternion QuaternionFromMatrix(UnityARMatrix4x4 m)
        {
            Matrix4x4 um = new Matrix4x4(m.column0, m.column1, m.column2, m.column3);

            return(QuaternionFromMatrix(um));
        }
Esempio n. 9
0
 public static Quaternion GetRotation(UnityARMatrix4x4 m)
 {
     return(GetRotation(new Matrix4x4(m.column0, m.column1, m.column2, m.column3)));
 }