/// <summary> /// Draws curved gizmo lines between waypoints, taken and modified from HOTween. /// <summary> //http://code.google.com/p/hotween/source/browse/trunk/Holoville/HOTween/Core/Path.cs public static void DrawCurved(Vector3[] waypoints) { //helper array for curved paths, includes control points for waypoint array Vector3[] gizmoPoints = new Vector3[waypoints.Length + 2]; waypoints.CopyTo(gizmoPoints, 1); gizmoPoints[0] = waypoints[1]; gizmoPoints[gizmoPoints.Length - 1] = gizmoPoints[gizmoPoints.Length - 2]; Vector3[] drawPs; Vector3 currPt; //store draw points int subdivisions = gizmoPoints.Length * 10; drawPs = new Vector3[subdivisions + 1]; for (int i = 0; i <= subdivisions; ++i) { float pm = i / (float)subdivisions; currPt = GetPoint(gizmoPoints, pm); drawPs[i] = currPt; } //draw path Vector3 prevPt = drawPs[0]; for (int i = 1; i < drawPs.Length; ++i) { currPt = drawPs[i]; Gizmos.DrawLine(currPt, prevPt); prevPt = currPt; } }
/// <summary> /// Add an array of points to this node, if the number exeeds the max, split into eight... /// /// It might be better to use a smaller number than the max, if it's too slow splitting? /// </summary> /// <param name="points"></param> public void AddPoints( Vector3[] points ) { if( m_isLeaf ) { int diff = MAX_POINTS - (points.Length + m_pointsCount); if( diff >= 0 ) { //we fit in the current mesh. sweet. points.CopyTo( m_points, m_pointsCount ); int oldCount = m_pointsCount; m_pointsCount += points.Length; int[] indices = new int[m_pointsCount]; m_indices.CopyTo( indices, 0 ); for( int i = oldCount; i < m_pointsCount; ++i ) { indices[i] = i; } m_indices = indices; //RefreshMesh(); return;//we don't need to do any testing } else { //sheeeit, we gotta split. splitNode();//this adds the current points //AddPoints( points ); //add the new points as well! Debug.Log( "-------------- SPLITTING YO! --------------" ); return;//remove this when uncommenting above!! } } //C'EST NE PAS UN LEAF! //add each point, one by f*****g one foreach( Vector3 point in points ) { foreach( OctTreeNode node in m_children ) {//this could be unrolled? if( node.Contains( point ) ) { node.AddPoint( point ); //Debug.Log( "Adding point: " + point ); break;//next point } } } }
void SetForcedStateVerts(Vector3[] verts, Color[] cols) { if(m_forced_state_verts == null || m_forced_state_verts.Length != verts.Length) m_forced_state_verts = new Vector3[verts.Length]; verts.CopyTo(m_forced_state_verts, 0); if(m_forced_state_cols == null || m_forced_state_cols.Length != cols.Length) m_forced_state_cols = new Color[cols.Length]; cols.CopyTo(m_forced_state_cols, 0); }