/// <summary> /// Set position from world coordinates in the Unity coordinate system. /// </summary> public static void SetWorldPosition(int openDriveIndex, Vector3 position) { Vector3 odrPos = GetOpenDrivePosition(position); RoadManagerLibraryCS.SetWorldXYHPosition(openDriveIndex, odrPos.x, odrPos.y, 0); RoadManagerLibraryCS.GetPositionData(openDriveIndex, ref tmpPosData); RoadManagerLibraryCS.SetLanePosition(openDriveIndex, tmpPosData.roadId, tmpPosData.laneId, tmpPosData.laneOffset, tmpPosData.s, true); }
/// <summary> /// Sets the given transform to match the position and rotation of the road user with handle index. /// </summary> /// <param name="openDriveIndex"></param> /// <param name="gameObjTransform">Transform of the road user game object.</param> public static void AlignGameObjectToHandle(int openDriveIndex, GameObject go) { RoadManagerLibraryCS.GetPositionData(openDriveIndex, ref tmpPosData); Vector3 pos = GetUnityPosition(tmpPosData); Quaternion rot = GetUnityRotation(tmpPosData); go.transform.SetPositionAndRotation(pos, rot); }
/// <summary> /// Returns the world position and rotation of the road user with handle index. /// </summary> /// <param name="openDriveIndex"></param> /// <returns></returns> public static WorldPose GetWorldPose(int openDriveIndex) { WorldPose pose = new WorldPose(); RoadManagerLibraryCS.GetPositionData(openDriveIndex, ref tmpPosData); pose.position = GetUnityPosition(tmpPosData); pose.rotation = GetUnityRotation(tmpPosData); return(pose); }
public static void GetOpenDrivePositionDataUnityCoordinates(int openDriveIndex, ref OpenDrivePositionDataUnityCoordinates unityPosData) { RoadManagerLibraryCS.GetPositionData(openDriveIndex, ref tmpPosData); unityPosData.position = GetUnityPosition(tmpPosData); unityPosData.rotation = GetUnityRotation(tmpPosData); unityPosData.hRelative = tmpPosData.hRelative; unityPosData.laneId = tmpPosData.laneId; unityPosData.laneOffset = tmpPosData.laneOffset; unityPosData.roadId = tmpPosData.roadId; unityPosData.s = tmpPosData.s; }