private void Setup_Nodes(ref Vector3[] tVects) { //Process nodes: int index = 0; if (mNodes != null) { mNodes.Clear(); mNodes = null; } mNodes = new List <GSDSplineFN>(); GSDSplineFN tNode; for (index = 0; index < tVects.Length; index++) { tNode = new GSDSplineFN(); tNode.pos = tVects[index]; mNodes.Add(tNode); } float step; Quaternion rot; step = (bClosed) ? 1f / mNodes.Count : 1f / (mNodes.Count - 1); for (index = 0; index < mNodes.Count; index++) { tNode = mNodes[index]; rot = Quaternion.identity; if (index != mNodes.Count - 1) { if (mNodes[index + 1].pos - tNode.pos == Vector3.zero) { rot = Quaternion.identity; } else { rot = Quaternion.LookRotation(mNodes[index + 1].pos - tNode.pos, transform.up); } //rot = Quaternion.LookRotation(mNodes[i+1].pos - tNode.pos, transform.up); } else if (bClosed) { rot = Quaternion.LookRotation(mNodes[0].pos - tNode.pos, transform.up); } else { rot = Quaternion.identity; } tNode.Setup(tNode.pos, rot, new Vector2(0, 1), step * index, "pNode"); } tNode = null; tVects = null; }
private void Setup_Nodes(ref Vector3[] tVects){ //Process nodes: int i=0; if (mNodes != null) { mNodes.Clear(); mNodes = null; } mNodes = new List<GSDSplineFN>(); GSDSplineFN tNode; for(i=0;i<tVects.Length;i++){ tNode = new GSDSplineFN(); tNode.pos = tVects[i]; mNodes.Add (tNode); } float step; Quaternion rot; step = (bClosed) ? 1f / mNodes.Count : 1f / (mNodes.Count - 1); for(i=0;i<mNodes.Count;i++){ tNode = mNodes[i]; rot = Quaternion.identity; if(i != mNodes.Count - 1){ if(mNodes[i+1].pos - tNode.pos == Vector3.zero){ rot = Quaternion.identity; }else{ rot = Quaternion.LookRotation(mNodes[i+1].pos - tNode.pos, transform.up); } //rot = Quaternion.LookRotation(mNodes[i+1].pos - tNode.pos, transform.up); }else if (bClosed){ rot = Quaternion.LookRotation(mNodes[0].pos - tNode.pos, transform.up); }else{ rot = Quaternion.identity; } tNode.Setup(tNode.pos,rot,new Vector2 (0, 1),step*i,"pNode"); } tNode = null; tVects = null; }