void GenerateRailSleepers() { int nSleepers = NSleepers; if (nSleepers <= 0) { return; } for (int i = 0; i < nSleepers; i++) { float k = (float)i / (m_Closed ? nSleepers : (nSleepers - 1)); Vector3 pos, normal, tangent; m_RailBaseSpline.GetPositionNormalTangent(k, out pos, out normal, out tangent); GetProjectedPosition(pos, -normal, out pos, out normal); normal.Normalize(); tangent.Normalize(); Vector3 dir = Vector3.Cross(tangent, normal).normalized; GameObject newSleeperGO = Instantiate(m_SleeperCubePrefab); newSleeperGO.name = "RailSleeper_" + i; newSleeperGO.transform.localScale = m_RailSleeperSize; newSleeperGO.transform.position = pos; newSleeperGO.transform.rotation = Quaternion.LookRotation(tangent, normal); newSleeperGO.transform.SetParent(m_SleepersContainer); } }
public bool GetPositionNormalTangent(float t, out Vector3 pos, out Vector3 normal, out Vector3 tangent, out int segmentIndex) { return(m_RailBaseSpline.GetPositionNormalTangent(t, out pos, out normal, out tangent, out segmentIndex)); }