Jump to content
  • Advertisement
Sign in to follow this  
pex22

billboarding

This topic is 4993 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi, its me again i used glOrtho for billboarding but my text isn't billboarded when i move in 2D directions (up,down,west,east). it is billboarded only when i rotate the camera or move foreward/backward. this is my billboard function:
/* math.h */
#define BILLBOARD_BEGIN 0
#define BILLBOARD_MASK  1
#define BILLBOARD_IMAGE 2
#define BILLBOARD_END   3
void billboard(int level=-1);
static int bblevel;

/* math.cpp */
void billboard(int level)
{
	if (level!=-1)
		bblevel=level;
	if (bblevel==1)
		goto BBMASK;
	else if (bblevel==2)
		goto BBIMAGE;
	else if (bblevel==3)
		goto BBPERSPECTIVE;
	else
		bblevel=0;
	// Set ortho mode
	glMatrixMode(GL_PROJECTION);
	glPushMatrix();
	glLoadIdentity();
	glOrtho(0,0,glutGet(GLUT_WINDOW_WIDTH),glutGet(GLUT_WINDOW_HEIGHT),0,1);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	goto BBEND;
BBMASK:
	// Draw mask
	glDisable(GL_DEPTH_TEST);
	glBlendFunc(GL_DST_COLOR,GL_ZERO);
	glEnable(GL_BLEND);
	goto BBEND;
BBIMAGE:
	// Draw image
	glBlendFunc(GL_ONE,GL_ONE);
	goto BBEND;
BBPERSPECTIVE:
	// Set perspective mode
	glDisable(GL_BLEND);
	glEnable(GL_DEPTH_TEST);
	glMatrixMode(GL_PROJECTION);
	glPopMatrix();
	glMatrixMode(GL_MODELVIEW);
BBEND:
	bblevel++;
}


and in main():
	billboard(BILLBOARD_BEGIN);
	billboard(BILLBOARD_MASK);
	text.color(1.0,0.0,0.0);
	text.pos(cam.getPosition().x,cam.getPosition().y);
	text.print("pex");
	billboard(BILLBOARD_IMAGE);
	text.color(1.0,0.0,0.0);
	text.pos(cam.getPosition().x,cam.getPosition().y);
	text.print("pex");
	billboard(BILLBOARD_END);


the text class uses bitmap fonts (glutBitmapCharacter) well, maybe billboard() doesn't need to be in math.h/cpp, but i dont know where to put it. anyway, thats not matter. what is the solution to my problem? thnx, pex. [Edited by - pex22 on October 21, 2004 1:58:08 PM]

Share this post


Link to post
Share on other sites
Advertisement
anyone?
everybody uses it in games or testing features (fps text is billboarded)
so i tried to use glOrtho but its not fully billboarded
so what should i do? or its the glOrtho settings?..

pex.

Share this post


Link to post
Share on other sites
billboarding is where u draw the an object and it faces the camera always in a 3d world, u keep the same projection matrix for both the billboards and the normal 3d stuff.
perhaps what u want to do is draw a HUD heads up display (when normally info is written on the screen eg fps, players score etc)
to do this draw the 3d scene first and then switch to a 2d projection matrix with glOrtho2D(..) and draw the text , the text will remain in the aame position on the screen

matrix mode PROJECTION
glPerspective(...)
matrixmode MODELVIEW
aim camera
..draw world

matrix mode PROJECTION
glOrtho2d()
matrixmode MODELVIEW
glLoadIdentity();
draw HUD

Share this post


Link to post
Share on other sites
oh, so i should use glOrtho2D instead of glOrtho? ok, thanks!

@grekster, so thats the difference between and [ source], i see. thanks!

Share this post


Link to post
Share on other sites
gluOrtho2D is same as glOrtho where the last parameters are 0 and 1, exactly as what i did in my code.
any other solution to my problem?..

Share this post


Link to post
Share on other sites
As said, billboarding is rotating a 3d polygon so that it is facing the screen. 'fps text' is not billboarded, it is simply printed using Ortho mode. NeHe has a tutorial on printing text using Ortho mode.

I'm not sure exactly what you want. If you want a kind of signpost, then use standard 3d billboarding, and texturemap the text onto it.

Share this post


Link to post
Share on other sites
Quote:
Original post by pex22
gluOrtho2D is same as glOrtho where the last parameters are 0 and 1, exactly as what i did in my code.
any other solution to my problem?..


you seem to be missing, that ortho will NOT magically billboard everything you have. in fact the only difference is that things wont look smaller if they are far away (ok, very simplified).

if you just want text, then load the identity and dont even think about calling lookat after that or do any kind of camera setup

Share this post


Link to post
Share on other sites
Quote:
Original post by Trienco
if you just want text, then load the identity and dont even think about calling lookat after that or do any kind of camera setup

oh i get it.
works thanks.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!