xxdon@monet.lerc.nasa.gov (Don Sosoka) (06/14/91)
I know this should be an easy one and the answer must be docummented some- where but I can't find it. Please Help! I want to draw smooth (GOURAUD) shaded lighted polygons starting with different colors at each vertex. Assuming the lighting model is setup correct (which it seems to be), if I do something like call SHADEM (GOURAU) call BGNPOL do 10 i = 1,N vn(1) = XN(i) vn(2) = YN(i) vn(3) = ZN(i) call N3F (vn) icv(1) = IRED(i) icv(2) = IGREEN(i) icv(3) = IBLUE(i) call C3I (icv) v(1) = X(i) v(2) = Y(i) v(3) = Z(i) call V3F (v) 10 continue call ENDPOL I get smooth shaded colored polygons but no lighting effects. If I reverse the order: call SHADEM (GOURAU) call BGNPOL do 10 i = 1,N icv(1) = IRED(i) icv(2) = IGREEN(i) icv(3) = IBLUE(i) call C3I (icv) vn(1) = XN(i) vn(2) = YN(i) vn(3) = ZN(i) call N3F (vn) v(1) = X(i) v(2) = Y(i) v(3) = Z(i) call V3F (v) 10 continue call ENDPOL I get a nicely lit surface but all gray shaded. What's the trick? (or am I way off base). Thank's.
reuel@khaki.asd.sgi.com (Reuel Nash) (06/14/91)
In article <1991Jun14.145543.23235@eagle.lerc.nasa.gov>, xxdon@monet.lerc.nasa.gov (Don Sosoka) writes: > I want to draw smooth (GOURAUD) shaded lighted polygons starting with > different colors at each vertex. You're real close with the second loop. You need to call lmcolor to tell the graphics system what to do with the C3I calls. In "C" it would be: lmcolor(LMC_AD); > call SHADEM (GOURAU) > call BGNPOL > do 10 i = 1,N > icv(1) = IRED(i) > icv(2) = IGREEN(i) > icv(3) = IBLUE(i) > call C3I (icv) > vn(1) = XN(i) > vn(2) = YN(i) > vn(3) = ZN(i) > call N3F (vn) > v(1) = X(i) > v(2) = Y(i) > v(3) = Z(i) > call V3F (v) > 10 continue > call ENDPOL > BTW, this can go LOTS faster if you can arrange to not copy the color, normal, and vertex data, but use it where it is. I don't know how to do this in FORTRAN, but in "C" it would be: float v[MAXN][3], c[MAXN][3], nm[MAXN][3]; . . . bgnpolygon(); for(i = 0; i < MAXN; i++) { c3f(c[i]); n3f(n[i]); v3f(v[i]); } endpolygon(); Reuel Nash Email: reuel@sgi.sgi.com "Question Skepticism" Voicemail: x8749 Mail stop:SR-254 Work Phone:(713)266-1333 Home Phone:(713)589-6258 USMail: Silicon Graphics, 5858 Westheimer Suite 100, Houston, TX 77057