PDA

View Full Version : outline of an object?



10-16-2001, 12:41 AM
hi

please help me out on this:
1. Is it possible to get the outline of an irregular object in opengl?
2. Also is it possible to just display part of it?
3. How do u obtain the corresponding 2d coordinates so that the outline can be plotted out?

thks.

pATChes11
10-17-2001, 10:41 AM
Get out your mathbook, buddy... you're gonna have to calculate the outline yourself. Don't ask me how though... I don't know and won't know for countless years to come :P

Nutty
10-17-2001, 12:19 PM
There is a simple trick to get all the outlines of the object.

Simply do a dot product with the view vector, and the normals of the objects. When this value is 0, you have the outline. i.e. the edge of the object. This is where the normals of the poly is exactly 90 degrees to the camera vector.

Usefull for toon shading that method, but probably very little else..

Nutty

Gavin
10-17-2001, 02:02 PM
Nutty are you sure? Think of a single polygon. All of its edges are the outline. If you rotate it the dot prouct will only be 90 deg when it is 'edge on'. From what I can see. If you are not worried about speed you can render your scene with all poly's say black and the background is white and then check each pixel for it's 4/8 connected neighbours. If there are white pixels then it is a boundary pixel. Or you could render the scene, blur it and then subtract that from the original. Blurring it just increases the size of the image by say a pixel subtracting this from the original will leave the boundary. Look at clip planes for displaying part of it, I think that is what you want. Perhaps there is a better way as these are just image processing algorithms.

JML
10-17-2001, 10:54 PM
Now this is theory for me, I've no experience with it myself, but AFAIK the procedure to generate outlines is as follows:

- assumption: objects are closed meshes of quads/triangles.

1. render front-faces of object with depth-testing and depth-writing enabled
2. disable depth writing (keep depth testing enabled GL_LEQUAL)
3. set the correct outline color
4. render back-faces in line mode with a line width > 1

The outlines should now show.

Look for the tutorial on cartoon rendering at NeHe (nehe.gamedev.net) for a more in-depth explanation.

HTH

Jean-Marc.