public void RenderMotionCycles() { //float w = Camera.main.pixelWidth; float h = Camera.main.pixelHeight; //Color strongColor = new Color(0, 0, 0, 1); Color weakColor = new Color(0.7f, 0.7f, 0.7f, 1); for (int m=0; m<legC.cycleMotions.Length; m++) { DrawArea graph = new DrawArea( new Vector3(0.01f*h+0.2f*h*m,0.31f*h,0), new Vector3(0.19f*h+0.2f*h*m,0.49f*h,0) ); graph.canvasMin = new Vector3(-1.1f,-1.1f,0); graph.canvasMax = new Vector3( 1.1f, 1.1f,0); GL.Begin( GL.LINES ); graph.DrawLine (-0.9f*Vector3.up, -1.1f*Vector3.up, weakColor); for (int i=0; i<90; i++) { graph.DrawLine ( Quaternion.AngleAxis( i /90.0f*360, Vector3.forward) * Vector3.up, Quaternion.AngleAxis((i+1)/90.0f*360, Vector3.forward) * Vector3.up, weakColor); } GL.End(); GL.Begin( GL.QUADS ); for (int leg=0; leg<legs.Length; leg++) { Color c = legs[leg].debugColor; Vector3 cycleVect; float t = ( legC.cycleMotions[m].cycles[leg].stanceTime - legC.cycleMotions[m].cycleOffset*(0.5f+0.5f*Mathf.Sin(Time.time*2)) ); cycleVect = Quaternion.AngleAxis(360.0f*t, -Vector3.forward) * -Vector3.up; graph.DrawRect(cycleVect-Vector3.one*0.1f, cycleVect+Vector3.one*0.1f, c); } GL.End(); } }
public void RenderCycleGraph() { float w = Camera.main.pixelWidth; float h = Camera.main.pixelHeight; //Color strongColor = new Color(0, 0, 0, 1); Color weakColor = new Color(0.7f, 0.7f, 0.7f, 1); DrawArea graph = new DrawArea(new Vector3(w-0.49f*h,0.01f*h,0),new Vector3(w-0.01f*h,0.49f*h,0)); graph.canvasMin = new Vector3(-1.1f,-1.1f,0); graph.canvasMax = new Vector3( 1.1f, 1.1f,0); GL.Begin( GL.QUADS ); graph.DrawRect(new Vector3(-1,-1,0), new Vector3(1,1,0), new Color(0,0,0,0.2f)); GL.End(); GL.Begin( GL.LINES ); graph.DrawLine (-0.9f*Vector3.up, -1.1f*Vector3.up, weakColor); for (int i=0; i<90; i++) { graph.DrawLine ( Quaternion.AngleAxis( i /90.0f*360, Vector3.forward) * Vector3.up, Quaternion.AngleAxis((i+1)/90.0f*360, Vector3.forward) * Vector3.up, weakColor); } for (int leg=0; leg<legs.Length; leg++) { Color c = legs[leg].debugColor; Vector3 marker; marker = Quaternion.AngleAxis( 360.0f*legStates[leg].liftoffTime, -Vector3.forward ) * -Vector3.up; graph.DrawLine(marker*0.9f, marker*1.1f, c); marker = Quaternion.AngleAxis( 360.0f*legStates[leg].strikeTime, -Vector3.forward ) * -Vector3.up; graph.DrawLine(marker*0.9f, marker*1.1f, c); } GL.End(); GL.Begin( GL.QUADS ); for (int leg=0; leg<legs.Length; leg++) { Color c = legs[leg].debugColor; Vector3 cycleVect; cycleVect = Quaternion.AngleAxis( 360.0f*legStates[leg].cycleTime, -Vector3.forward ) * -Vector3.up; graph.DrawRect(cycleVect-Vector3.one*0.1f, cycleVect+Vector3.one*0.1f, c); float dictatedCycle = Util.CyclicDiff(normalizedTime, legStates[leg].stanceTime); cycleVect = Quaternion.AngleAxis(360.0f*dictatedCycle, -Vector3.forward) * -Vector3.up * 0.8f; graph.DrawRect(cycleVect-Vector3.one*0.05f, cycleVect+Vector3.one*0.05f, c); } GL.End(); }