Exemplo n.º 1
0
        public static Quaternion QuaternionFromMatrix(Matrix4x4 m)
        {
            Quaternion rot = Quaternion.identity;

            // from Leto: http://answers.unity3d.com/questions/11363/converting-matrix4x4-to-quaternion-vector3.html

            if (m == Matrix4x4.identity)
            {
                return(rot);
            }

            if (float.IsNaN(m.m00))
            {
                return(rot);
            }

            if (AXUtilities.GetScale(m) == Vector3.zero)
            {
                return(rot);
            }


            try {
                rot = Quaternion.LookRotation(m.GetColumn(2), m.GetColumn(1));
            } catch {
                return(rot);
            }
            return(rot);
        }
Exemplo n.º 2
0
        public void remapGuids(ref Dictionary <string, string> guidMap)
        {
            if (!guidMap.ContainsKey(pA_guid) || !guidMap.ContainsKey(pB_guid))
            {
                return;
            }

            string old_pA_guid_key = ArchimatixUtils.guidToKey(pA_guid);
            string old_pB_guid_key = ArchimatixUtils.guidToKey(pB_guid);

            string new_pA_guid_key = ArchimatixUtils.guidToKey(guidMap[pA_guid]);
            string new_pB_guid_key = ArchimatixUtils.guidToKey(guidMap[pB_guid]);

            //Debug.Log("+++ remapGuids pA_guid: " + old_pA_guid_key + "==="+new_pA_guid_key);

            //Debug.Log("=====> expression_AB (old): " + expression_AB);
            // EXPRESSIONS

            if (expression_AB != null)
            {
                expression_AB = expression_AB.Replace(old_pA_guid_key, new_pA_guid_key);
            }
            if (expression_BA != null)
            {
                expression_BA = expression_BA.Replace(old_pB_guid_key, new_pB_guid_key);
            }

            // ACTUAL PARAMETER GUIDS
            // replace old guids in the strings with the new guids
            pA_guid = AXUtilities.swapOutGuids(pA_guid, ref guidMap);
            pB_guid = AXUtilities.swapOutGuids(pB_guid, ref guidMap);

            // later, swap guids in pA_expression && pB
        }
        public void positionHandleGameObject()
        {
            Vector3 pos = handle.getPosition();


            pos = context.MultiplyPoint3x4(pos);

//			if (handle.parametricObject.is3D())
//				pos.z /= 2;

            transform.position = pos;            //handle.getPosition();

            Matrix4x4 axisRoter = (handle.parametricObject.is2D()) ? Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(-90, 0, 0), Vector3.one) : Matrix4x4.identity;

            transform.rotation = AXUtilities.QuaternionFromMatrix(context * axisRoter);
        }