Jump to content
  • Advertisement
Sign in to follow this  

outline a model

This topic is 4408 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

I have models of tanks and stuff in my game and want there to be a thin green outline around them when they're selected. I thought about drawing each model again in GL_LINE mode but that draws all the polys as lines, not just the outline so it looks more like a net. How can I do it? Thanks. (please ask if I wasn't clear)

Share this post


Link to post
Share on other sites
Advertisement
Thanks for that link.
So if I have code that draws a 3D model: DrawModel();
to get the outline I'd do:

glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA ,GL_ONE_MINUS_SRC_ALPHA);
glPolygonMode (GL_BACK, GL_LINE);
glLineWidth (outlineWidth);
glCullFace (GL_FRONT);
glDepthFunc (GL_LEQUAL);
glColor3fv (&outlineColor[0]);
DrawModel();

and I'd get the outline?
Thanks.

Share this post


Link to post
Share on other sites
On a similar note... are lines the "accepted" way to apply outlines to cell shading (to produce a cartoonish image)? Or is it a screen space normal direction test? (ie see which pixels are within a certain degree of perpendicular to the view direction)?

thanks
-Dan

Share this post


Link to post
Share on other sites
I tried and it didn't work. I did:

Display(tank,0,false);

//outline:

glDisable(GL_TEXTURE_2D);
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA ,GL_ONE_MINUS_SRC_ALPHA);

glPolygonMode (GL_BACK, GL_LINE);
glLineWidth (5);

glCullFace (GL_FRONT);

glDepthFunc (GL_LEQUAL);

glColor3f (0,1,0);

Display(tank,0,false);

glDepthFunc (GL_LESS);
glCullFace (GL_BACK);

glPolygonMode (GL_BACK, GL_FILL);

glLineWidth (1);

glDisable (GL_BLEND);
glEnable(GL_TEXTURE_2D);


were Display() renders a model. But instead of drawing a green outlin the whole tank cameout green, it eas even textured? It was like the front facing culling wasn't working or something.
What did I do wrong?
Thanks.

Share this post


Link to post
Share on other sites
daniel_i_l,
The other simple method is shifting(shaking) the object slightly left/right/up/down, then drawing it 4 times on the stencil buffer to make a silhouette. There is an old example at SGI site, silhouette.c It resizes glViewport instead moving the object. The result is not same as nehe lessen #37. It creates the outlines only, not all edges of the object.

Share this post


Link to post
Share on other sites
The way i did it is similar to songho's method, but without drawing it 4 times. The process goes like this:

1. Disable color writes and draw (filled) to create a mask in the stencil buffer
2. Enable color writes, set linewidth to something big (like 7) and draw again in wireframe where the stencil is not set.

This produces the same effect as his method, ie only the outline.

Share this post


Link to post
Share on other sites
Gaenor, that method sounds good. I don't know much about the stencil buffer though. Do you think that you (or someone else) could explain more? Maybe with a little code?
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!