public static void SetRotation(this Common.Models.Transform t, UnityEngine.Transform got) { t.BasisX = new XYZ { X = got.right.x, Y = got.right.z, Z = got.right.y, }; t.BasisY = new XYZ { X = got.forward.x, Y = got.forward.z, Z = got.forward.y, }; t.BasisZ = new XYZ { X = got.up.x, Y = got.up.z, Z = got.up.y, }; }
public static void SetPosition(this UnityEngine.Transform got, Common.Models.Transform t) { XYZ originXYZ = t.Origin; Vector3 origin = new Vector3( (float)originXYZ.X * Helpers.Constants.M_PER_FT, (float)originXYZ.Z * Helpers.Constants.M_PER_FT, (float)originXYZ.Y * Helpers.Constants.M_PER_FT ); Vector3 newForward = new Vector3( (float)t.BasisY.X, (float)t.BasisY.Z, (float)t.BasisY.Y ); Vector3 newRight = new Vector3( (float)t.BasisX.X, (float)t.BasisX.Z, (float)t.BasisX.Y ); //if (f.IsHandFlipped) //{ // newRight = -newRight; //} //if (f.IsFlipped) //{ // newForward = -newForward; // newRight = -newRight; //} Vector3 newUp = Vector3.Cross(newForward, newRight); got.position = origin; got.rotation = Quaternion.LookRotation( newForward, newUp ); }