The Industry's Foundation for High Performance Graphics

1. How to Add a Compass in My Programme

I am a learner of OpenGL,and use it to write a full-screen programme with big scene,in which user can walk around.Now I want to add a compass(A box and Needle)at the right-top conner of the screen to indicate the direction.I known how to draw the appearance
of the compass but do not known how to make some setting before drawing the compass.
Can you give me some code or advice?Any help are appreciated!

2. Re: How to Add a Compass in My Programme

Well,

You got the rotation of your "Player" arount the y-axis.

So this is the rotation in degrees.

Let's say 0-degree are East,...

To draw the compass simply draw in ortho mode a texture of your compass with the rotation around the Z-axis. You should use a masked texture (-->Nehe tutorial Masking)

Now you have an Texture that rotaes if you user rotates, so you can draw the needle with GL_LINES.

3. Re: How to Add a Compass in My Programme

Thanks a lot!
Now my doubt is "how to make the compass at the corner of the screen when user roam around".Or rather,how to draw a circle there when user roam:the circle is still at the corner,keep immobility,not associated with the 3D volume!

5. Re: How to Add a Compass in My Programme

Thank you very much!
I have finished my idea!

6. Re: How to Add a Compass in My Programme

Hi
I had a similar problem ( a while ago - but didn't solve it ).
Drawing a radar - knew how to do it but had a little problem - no way of calculating the Y rotation - used relaive rotation with quaternions so no way too do somthing like y += 30.0f )

7. Re: How to Add a Compass in My Programme

I do not really known clearly about what you want for my poor english.The code i wrote is as below,i expect this is helpful for you:
// Reset The Current Modelview Matrix
// Save The Current MODELVIEW Matrix
glPushMatrix();
// Translate To The Object's Location
glTranslatef(fxPos,fyPos,0.0f);
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
// you can add some other code for the setting of the needle .....
// draw the need of the compass
glCallList(m_nNeedleList);
// you can add some other code for the setting of the Box .....
glCallList(m_nBoxList);
// Restore The Current MODELVIEW Matrix
glPopMatrix();

[This message has been edited by zjkw (edited 05-21-2002).]

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•