public void RenderCircle(Vector3 position, float radius, uint col) { const int Reso = 36; const float MaxDeg = 360f; const float DegToRad = 0.0174533f; const float Ang = DegToRad * MaxDeg / Reso; var dir = Vector3.Normalize(position - camera.Position); var up = Vector3.Normalize(dir.GetPerpVec()); var axis = Vector3.Cross(dir, up); var c = new VertexTypePC[Reso]; for (var i = 0; i < Reso; i++) { var rDir = Quaternion.RotationAxis(dir, i * Ang).Multiply(axis); c[i].Position = position + (rDir * radius); c[i].Colour = col; } for (var i = 0; i < c.Length; i++) { LineVerts.Add(c[i]); LineVerts.Add(c[(i + 1) % c.Length]); } }
public void RenderCubeLines(Vector3 p1, Vector3 p2, Vector3 a2, Vector3 a3, uint col) { VertexTypePC v = new VertexTypePC(); v.Colour = col; var c1 = p1 - a2 - a3; var c2 = p1 - a2 + a3; var c3 = p1 + a2 + a3; var c4 = p1 + a2 - a3; var c5 = p2 - a2 - a3; var c6 = p2 - a2 + a3; var c7 = p2 + a2 + a3; var c8 = p2 + a2 - a3; v.Position = c1; LineVerts.Add(v); v.Position = c2; LineVerts.Add(v); LineVerts.Add(v); v.Position = c3; LineVerts.Add(v); LineVerts.Add(v); v.Position = c4; LineVerts.Add(v); LineVerts.Add(v); v.Position = c1; LineVerts.Add(v); LineVerts.Add(v); v.Position = c5; LineVerts.Add(v); v.Position = c2; LineVerts.Add(v); v.Position = c6; LineVerts.Add(v); v.Position = c3; LineVerts.Add(v); v.Position = c7; LineVerts.Add(v); v.Position = c4; LineVerts.Add(v); v.Position = c8; LineVerts.Add(v); v.Position = c5; LineVerts.Add(v); v.Position = c6; LineVerts.Add(v); LineVerts.Add(v); v.Position = c7; LineVerts.Add(v); LineVerts.Add(v); v.Position = c8; LineVerts.Add(v); LineVerts.Add(v); v.Position = c5; LineVerts.Add(v); }
public void RenderArrowLines3D(Vector3 pos, Vector3 dir, Vector3 up, Quaternion ori, float len, float rad, uint colour) { Vector3 ax = Vector3.Cross(dir, up); Vector3 sx = ax * rad; Vector3 sy = up * rad; Vector3 sz = dir * len; VertexTypePC[] c = new VertexTypePC[8]; Vector3 d0 = -sx - sy; Vector3 d1 = -sx + sy; Vector3 d2 = +sx - sy; Vector3 d3 = +sx + sy; c[0].Position = d0; c[1].Position = d1; c[2].Position = d2; c[3].Position = d3; c[4].Position = d0 + sz; c[5].Position = d1 + sz; c[6].Position = d2 + sz; c[7].Position = d3 + sz; for (int i = 0; i < 8; i++) { c[i].Colour = colour; c[i].Position = pos + ori.Multiply(c[i].Position); } LineVerts.Add(c[0]); LineVerts.Add(c[1]); LineVerts.Add(c[1]); LineVerts.Add(c[3]); LineVerts.Add(c[3]); LineVerts.Add(c[2]); LineVerts.Add(c[2]); LineVerts.Add(c[0]); LineVerts.Add(c[4]); LineVerts.Add(c[5]); LineVerts.Add(c[5]); LineVerts.Add(c[7]); LineVerts.Add(c[7]); LineVerts.Add(c[6]); LineVerts.Add(c[6]); LineVerts.Add(c[4]); LineVerts.Add(c[0]); LineVerts.Add(c[4]); LineVerts.Add(c[1]); LineVerts.Add(c[5]); LineVerts.Add(c[2]); LineVerts.Add(c[6]); LineVerts.Add(c[3]); LineVerts.Add(c[7]); c[0].Position = pos + ori.Multiply(dir * (len + rad * 5.0f)); c[4].Position += ori.Multiply(d0); c[5].Position += ori.Multiply(d1); c[6].Position += ori.Multiply(d2); c[7].Position += ori.Multiply(d3); LineVerts.Add(c[4]); LineVerts.Add(c[5]); LineVerts.Add(c[5]); LineVerts.Add(c[7]); LineVerts.Add(c[7]); LineVerts.Add(c[6]); LineVerts.Add(c[6]); LineVerts.Add(c[4]); LineVerts.Add(c[0]); LineVerts.Add(c[4]); LineVerts.Add(c[0]); LineVerts.Add(c[5]); LineVerts.Add(c[0]); LineVerts.Add(c[6]); LineVerts.Add(c[0]); LineVerts.Add(c[7]); }