In this note I want to talk about how to draw 2d circle which is always oriented to the observer. Render in Mobu is based on OpenGL, so that the tip is more general in nature and not tied to a specified software product.

Circle is drawing in this way

1
2
3
4
5
6
7
X(t) = (x, y, z),

x = r * sin(t)

y = r * cos(t)

z = 0.0

where r – circle radius, and t – parameter between [0; 2*PI]

To make a billboard we have to extract euler rotation from the model view matrix.

1
2
3
4
5
6
7
FBMatrix m;

m = pCamera->GetMatrix(kFBModelView);

FBVector3d rot;

FBMatrixToRotation(rot, m);

where pCamera – pointer to a scene camera

FBMatrixToRotation – MoBu function for a matrix to euler conversion

 

So the drawing code will be like that

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
glPushMatrix();

{

glRotatef( -rot[2], 1.0f, 0.0f, 0.0f );

glRotatef( -rot[1], 0.0f, 1.0f, 0.0f );

glRotatef( -rot[0], 0.0f, 0.0f, 1.0f );

//

//-- circle drawing

//

}

glPopMatrix();
MoBu tip: drawing a circle billboard
Tagged on:             

Leave a Reply

Your email address will not be published. Required fields are marked *