View Full Version : outline of an object?
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?
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
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..
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.
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.
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.