// Instance API static VrAssetService() { Matrix4x4 polyFromUnity = AxisConvention.GetFromUnity(AxisConvention.kGltfAccordingToPoly); // Provably non-lossy: the mat4 is purely TRS, and the S is uniform kPolyFromUnity = TrTransform.FromMatrix4x4(polyFromUnity); }
/// Given a transform, returns that transform in another basis. /// The new basis is specified by outputFromInput. /// /// Not guaranteed to work if the change-of-basis matrix has non-uniform /// scale. Otherwise, the resulting transform will not "fit" in a TrTransform. public static TrTransform ChangeBasis( TrTransform xfInput, Matrix4x4 outputFromInput, Matrix4x4 inputFromOutput) { // It might make this a little more accurate if outputFromInput were a TrTransform. // Although... outputFromInput and inputFromOutput expressed as Matrix4x4 are always // infinitely precise, for axis convention changes at least. Doing the same with a quat // might involve sqrt(2)s. But maybe not for the common case of unity -> fbx / gltf? Matrix4x4 m = outputFromInput * xfInput.ToMatrix4x4() * inputFromOutput; return(TrTransform.FromMatrix4x4(m)); }
public void TestFromMatrix4x4() { for (int i = 0; i < 100; ++i) { var t = Random.insideUnitSphere * 10; var r = Random.rotationUniform; var s = Random.Range(2f, 100f); if (Random.value < .5f) { s = 1 / s; } var xf = TrTransform.TRS(t, r, s); var m4 = Matrix4x4.TRS(t, r, Vector3.one * s); AssertAlmostEqual(TrTransform.FromMatrix4x4(m4), xf, allowFlip: true); } }
private TrTransform UsdXformToWorldSpaceXform(USD.NET.Unity.XformSample usdXform) { TrTransform xf_CS = TrTransform.FromMatrix4x4(usdXform.transform); return(TrTransform.FromTransform(App.Scene.ActiveCanvas.transform) * xf_CS); }
static void SetLocalTransform(this FbxNode node, Matrix4x4 xf) { node.SetLocalTransform(TrTransform.FromMatrix4x4(xf)); }