UpdateWorldOrigin.cs 1.5 KB

1234567891011121314151617181920212223242526272829
  1. /****************************************************************************
  2. * Copyright 2019 Nreal Techonology Limited. All rights reserved.
  3. *
  4. * This file is part of NRSDK.
  5. *
  6. * https://www.nreal.ai/
  7. *
  8. *****************************************************************************/
  9. namespace NRKernal
  10. {
  11. using UnityEngine;
  12. /// <summary> Align the world coordinate to the pose. </summary>
  13. public class UpdateWorldOrigin
  14. {
  15. /// <summary> Align the world coordinate to positon and rotation. </summary>
  16. /// <param name="cameraRoot"> .</param>
  17. /// <param name="position"> .</param>
  18. /// <param name="rotation"> .</param>
  19. public static void AlignWorldCoordinate(Transform cameraRoot, Vector3 position, Quaternion rotation)
  20. {
  21. var marker_in_world = ConversionUtility.GetTMatrix(position, rotation);
  22. var world_in_marker = Matrix4x4.Inverse(marker_in_world);
  23. cameraRoot.position = ConversionUtility.GetPositionFromTMatrix(world_in_marker);
  24. cameraRoot.rotation = ConversionUtility.GetRotationFromTMatrix(world_in_marker);
  25. }
  26. }
  27. }