I want to draw a cube and circles like this (sphere without fill). I'm using OpenTK
http://farm7.static.flickr.com/6074/6097051938_cb0b798ce0_z.jpg
I've been having issue as below: I've try to draw a circle at the top of Cube. But when we rotate Oy the cube and the circle, the circle become Ellipse.
I've try to draw sphere instead circle. But can not make it like the image above. Anybody have the solution? Thanks in advance!
And this is mine http://farm7.static.flickr.com/6061/6096573967_22d56b2c2a_z.jpg
Draw a circle that always faces the camera, drawing a circle is easy. Just create a ring of vertices and use GL_LINE_STRIP to draw it. Creating a transformation matrix that always looks at the camera is a bit involved. Here is the code that does this. Simply set this one as your world matrix.
Matrix4 createBillbordMatrix(Vector3 position, Vector3 cameraPosition, vector3 up)
{
Vector3 Z = Vector3.Normalize(direction - cameraPosition);
Vector3 X = Vector3.Normalize(Vector3.Cross(up, Zaxis));
Vector3 Y = Vector3.Cross(ZAxis, XAxis);
Vector3 T = cameraPosition;
return new Matrix4(X.X, X.Y, X.Z, 0,
Y.X, Y.Y, Y.Z, 0,
Z.X, Z.Y, Z.Z, 0,
T.X, T.Y, T.Z, 1);
}
If you know how matricies work, you should be able to figure it how it works ;). Otherwise don't worry about it, you shouldn't have a problem implementing it.