Skip to main content
GameDev.net gamedev.net
🔒 Locked

How to highlight a entity's edge?

Started by HeavySword Nov 18, 2007 at 6:45 AM 3 replies 2.2k views
Original Post
HeavySword
HeavySword
when the cursor is over an entity, I want to highlight it's edge so that a player can immediately know he can pick this entity after he click the mouse left button. for example, there are many monsters around the main character in the game, it is not easy to pick one monster.I googled this,but found nothing.who can give me some suggestion?
all_names_taken
all_names_taken
The simplest method is to draw the object colored in the highlight color, with some scaling to make it larger than the original object. Do this drawing with depth writes turned off. Then, after this, draw the object as usual, with depth writes on again.

There are more complex methods, depending on your application - depending on what is your bottleneck, depending on complexity of your monster models etc etc. but the method above is simple to implement and should work for most cases.
HeavySword
HeavySword
Quote:
Original post by all_names_taken
The simplest method is to draw the object colored in the highlight color, with some scaling to make it larger than the original object. Do this drawing with depth writes turned off. Then, after this, draw the object as usual, with depth writes on again.

There are more complex methods, depending on your application - depending on what is your bottleneck, depending on complexity of your monster models etc etc. but the method above is simple to implement and should work for most cases.

Thank you for your so fast reply.
yahastu
yahastu
Quote:
Original post by all_names_taken
The simplest method is to draw the object colored in the highlight color, with some scaling to make it larger than the original object. Do this drawing with depth writes turned off. Then, after this, draw the object as usual, with depth writes on again.

There are more complex methods, depending on your application - depending on what is your bottleneck, depending on complexity of your monster models etc etc. but the method above is simple to implement and should work for most cases.


That doesn't really work because the border width will not be uniform...

if youre using OGL a better method is to use fat line mode

//renders the outline partglCullFace(GL_FRONT);glEnable(GL_CULL_FACE);glPolygonMode(GL_BACK, GL_LINE);glLineWidth(4);	//fat lines//glDisable(GL_DEPTH_TEST);glDepthMask(GL_FALSE);glDisable(GL_LIGHTING);glDisable(GL_TEXTURE_2D);glCallList(dispListSelected);//renders the regular object part				glEnable(GL_TEXTURE_2D);glEnable(GL_LIGHTING);glDepthMask(GL_TRUE);//glEnable(GL_DEPTH_TEST);glDisable(GL_LINE_SMOOTH);glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); //back to solid modeglDisable(GL_CULL_FACE);glCallList(dispList);


The only difference between dispList and dispListSelected is that dispList renders the object using a texture map while the selected list renders it in solid green (for selection color)

shipListSelected = glGenLists(1);glDisable(GL_TEXTURE_2D);glEnable(GL_COLOR_MATERIAL);glNewList(shipListSelected, GL_COMPILE);	glColor4f(0,0.6f,0,0.8f);	m.render();glEndList();shipList = glGenLists(1);glEnable(GL_TEXTURE_2D);glBindTexture(GL_TEXTURE_2D, shipTex);glNewList(shipList, GL_COMPILE);	glColor4f(1,1,1,1.0f);	m.render();glEndList();


Image Hosted by ImageShack.us
Ravuya
Ravuya
Quote:
Original post by yahastu
if youre using OGL a better method is to use fat line mode
I'm not terribly sure about that -- wireframe rendering mode is really slow on most modern drivers (yes, it's even slower than drawing fills).

If performance isn't a problem, then your method works as well as any, but there's faster ways to do it. When I did this, I did it with the stencil buffer and just re-rendered the model without depth writes or textures (similarly to this routine, although it also uses wireframe mode).

If I did it again, I'd probably implement it with some sort of image-space shader that I could pull off using multiple maps.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.