/// <summary> /// Update the gameObject's transform of an ArUco object. /// </summary> /// <param name="arucoObject">The ArUco object to place.</param> /// <param name="rvec">The estimated rotation vector of the ArUco object.</param> /// <param name="tvec">The estimated translation vector of the ArUco object.</param> /// <param name="cameraId">The id of the camera to use. The gameObject is placed and oriented relative to this camera.</param> /// <param name="positionFactor">Factor on the position vector.</param> protected void PlaceArucoObject(ArucoObject arucoObject, Cv.Vec3d rvec, Cv.Vec3d tvec, int cameraId, float positionFactor = 1f) { GameObject arucoGameObject = arucoObject.gameObject; arucoGameObject.transform.SetParent(arucoTracker.ArucoCamera.ImageCameras[cameraId].transform); arucoGameObject.transform.localPosition = tvec.ToPosition() * positionFactor; arucoGameObject.transform.localRotation = rvec.ToRotation(); arucoGameObject.SetActive(true); }
/// <summary> /// Update the gameObject's transform of an ArUco object. /// </summary> /// <param name="arucoObject">The ArUco object to place.</param> /// <param name="rvec">The estimated rotation vector of the ArUco object.</param> /// <param name="tvec">The estimated translation vector of the ArUco object.</param> /// <param name="cameraId">The id of the camera to use. The gameObject is placed and oriented relative to this camera.</param> /// <param name="positionFactor">Factor on the position vector.</param> protected void PlaceArucoObject(ArucoObject arucoObject, Cv.Vec3d rvec, Cv.Vec3d tvec, int cameraId, float positionFactor = 1f) { GameObject arucoGameObject = arucoObject.gameObject; arucoGameObject.transform.SetParent(arucoTracker.ArucoCamera.ImageCameras[cameraId].transform); arucoGameObject.transform.localPosition = tvec.ToPosition() * positionFactor + arucoGameObject.transform.up * arucoGameObject.transform.localScale.y / 2; // Move up the object to coincide with the marker; arucoGameObject.transform.localRotation = rvec.ToRotation(); arucoGameObject.SetActive(true); }