This topic is now archived and is closed to further replies.


silhouette rendering

Recommended Posts

Hi. I am using silhouette rendering and cel-shading in my game to make it look cartoon-like. To speed up my code I use triangle strips to simulate lines, because my card does not have hw-acceleration for lines. That''s why I have to determine myself whether a triangle is front-facing the camera or not. But that doesn''t work well, it seems like it is a little inaccurate of I am using the wrong coordinates. Here is my code: First the transformations: VERTEX Vt; // the camera is behind the player Vt.x=3.0*sinyrot; Vt.y=3.0*(float)sin(lookupdown*piover180); Vt.z=3.0*cosyrot; // calculate translations and rotations. xtrans = -xpos-Vt.x; ytrans = -yheight-1.35f-Vt.y; ztrans = -zpos-Vt.z; sceneroty = 360.0f - yrot; // Rotate and Translate glRotatef(lookupdown, 1.0f, 0, 0); glRotatef(sceneroty, 0, 1.0f, 0); glTranslatef(xtrans, ytrans, ztrans); then the backface-stuff in the drawing routine: int backfacing(VERTEX v,VERTEX n,float x,float y,float z) { VERTEX v2; v2.x=v.x-x; v2.y=v.y-y; v2.z=v.z-z; float l=sqrt(v2.x*v2.x+v2.y*v2.y+v2.z*v2.z); v2.x/=l; v2.y/=l; v2.z/=l; float DOT=Dot(v2,n); return (DOT>0.0); } Call the function: if(backfacing(trigz[2].midpoint,tris[trigz.ID].normal,-xtrans,-ytrans,-ztrans)) draw outlines What''s wrong?

Share this post

Link to post
Share on other sites