/// <summary> /// Set position from world coordinates in the Unity coordinate system. /// </summary> public static void SetWorldPosition(int openDriveIndex, Vector3 position, Vector3 rotationEuler) { Vector3 odrPos = GetOpenDrivePosition(position); Vector3 odrRot = GetOpenDriveRotation(rotationEuler); RoadManagerLibraryCS.SetWorldPosition(openDriveIndex, odrPos.x, odrPos.y, odrPos.z, odrRot.x, odrRot.y, odrRot.z); }
/// <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); }
public static void GetLaneInfo(int openDriveIndex, float lookAheadDistance, ref RoadLaneInfoUnityCoordinates laneInfo, int lookAheadMode) { RoadManagerLibraryCS.GetLaneInfo(openDriveIndex, lookAheadDistance, ref tmpLaneInfo, lookAheadMode); laneInfo.position = GetUnityPosition(tmpLaneInfo.pos[0], tmpLaneInfo.pos[1], tmpLaneInfo.pos[2]); laneInfo.rotation = GetUnityRotation(tmpLaneInfo.heading, tmpLaneInfo.pitch, tmpLaneInfo.roll); laneInfo.curvature = tmpLaneInfo.curvature; laneInfo.speedLimit = tmpLaneInfo.speed_limit; laneInfo.width = tmpLaneInfo.width; }
/// <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; }
public static void GetProbeInfo(int openDriveIndex, float lookAheadDistance, ref RoadProbeInfoUnityCoordinates probeInfo, int lookAheadMode, bool inRoadDrivingDirection = false) { RoadManagerLibraryCS.GetProbeInfo(openDriveIndex, lookAheadDistance, ref tmpProbeInfo, lookAheadMode, inRoadDrivingDirection); probeInfo.roadLaneInfo.position = GetUnityPosition(tmpProbeInfo.laneInfo.pos[0], tmpProbeInfo.laneInfo.pos[1], tmpProbeInfo.laneInfo.pos[2]); probeInfo.roadLaneInfo.rotation = GetUnityRotation(tmpProbeInfo.laneInfo.heading, tmpProbeInfo.laneInfo.pitch, tmpProbeInfo.laneInfo.roll); probeInfo.roadLaneInfo.curvature = tmpProbeInfo.laneInfo.curvature; probeInfo.roadLaneInfo.speedLimit = tmpProbeInfo.laneInfo.speed_limit; probeInfo.roadLaneInfo.width = tmpProbeInfo.laneInfo.width; probeInfo.relativePosition = GetUnityPosition(tmpProbeInfo.relativePos[0], tmpProbeInfo.relativePos[1], tmpProbeInfo.relativePos[2]); probeInfo.relativeHeading = tmpProbeInfo.relativeHeading; }
//public static void GetLaneInfo(int openDriveIndex, float lookAheadDistance, ref RoadLaneInfoUnityCoordinates laneInfo) //{ // GetLaneInfo(openDriveIndex, lookAheadDistance, ref laneInfo, 0); //} //public static void GetLaneInfo(int openDriveIndex, float lookAheadDistance, ref RoadLaneInfoUnityCoordinates laneInfo, int laneId) //{ // RoadManagerLibraryCS.GetLaneInfo(openDriveIndex, lookAheadDistance, ref tmpLaneInfo); // laneInfo.position = GetUnityPosition(tmpLaneInfo.pos[0], tmpLaneInfo.pos[1], tmpLaneInfo.pos[2]); // laneInfo.rotation = GetUnityRotation(tmpLaneInfo.heading, tmpLaneInfo.pitch, tmpLaneInfo.roll); // if (laneId >= 0) // laneInfo.curvature = tmpLaneInfo.curvature; // else // laneInfo.curvature = -tmpLaneInfo.curvature; // laneInfo.speedLimit = tmpLaneInfo.speed_limit; // laneInfo.width = tmpLaneInfo.width; //} public static void GetLaneInfo(int openDriveIndex, float lookAheadDistance, ref RoadLaneInfoUnityCoordinates laneInfo, LookAheadMode lookAheadMode = LookAheadMode.LaneCenter, int laneId = 0, bool inRoadDrivingDirection = false) { RoadManagerLibraryCS.GetLaneInfo(openDriveIndex, lookAheadDistance, ref tmpLaneInfo, (int)lookAheadMode, inRoadDrivingDirection); laneInfo.position = GetUnityPosition(tmpLaneInfo.pos[0], tmpLaneInfo.pos[1], tmpLaneInfo.pos[2]); laneInfo.rotation = GetUnityRotation(tmpLaneInfo.heading, tmpLaneInfo.pitch, tmpLaneInfo.roll); if (laneId >= 0) { laneInfo.curvature = tmpLaneInfo.curvature; } else { laneInfo.curvature = -tmpLaneInfo.curvature; } laneInfo.speedLimit = tmpLaneInfo.speed_limit; laneInfo.width = tmpLaneInfo.width; }
/// <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); }