home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / sys / sgi / graphics / 59 < prev    next >
Encoding:
Internet Message Format  |  1992-12-23  |  2.2 KB

  1. Path: sparky!uunet!usc!sdd.hp.com!spool.mu.edu!olivea!sgigate!sgi!fido!blivet!reuel
  2. From: reuel@blivet.houst.sgi.com (Reuel Nash)
  3. Newsgroups: comp.sys.sgi.graphics
  4. Subject: Re: Setting Material Color
  5. Message-ID: <1hanj7INNpu4@fido.asd.sgi.com>
  6. Date: 23 Dec 92 22:01:11 GMT
  7. References: <7671@dove.nist.gov>
  8. Organization: Silicon Graphics, Inc.  Mountain View, CA
  9. Lines: 100
  10. NNTP-Posting-Host: blivet.houst.sgi.com
  11.  
  12.  
  13. In article <7671@dove.nist.gov>, fred@poly2.nist.gov writes:
  14. > Suppose you have a material color:
  15. > float object_color[] = 
  16. > {
  17. >         DIFFUSE,    0.1, 1.0, 0.2,
  18. >         SPECULAR,   0.3, 0.9, 0.3,
  19. >         EMISSION,   1.0, 0.1, 1.0,
  20. >         SHININESS,  24.0,
  21. >         LMNULL 
  22. > };
  23. > which has been set with:
  24. >     lmdef(DEFMATERIAL, 1, 15, object_color);
  25. > First, are you allowed to change the EMISSION values (or really any
  26. > of object_color's properties) on the fly?  
  27.  
  28. Yes.
  29.  
  30. > Second, If you can change on the fly, do you need to do a new call to
  31. > lmdef every time for the changes to take effect or is the first call
  32. > sufficient?
  33.  
  34. You have to call lmdef each time:
  35.  
  36. float object_color[] = 
  37.  
  38. {
  39.     DIFFUSE,    0.1, 1.0, 0.2,
  40.     SPECULAR,   0.3, 0.9, 0.3,
  41.     EMISSION,   1.0, 0.1, 1.0,
  42.     SHININESS,  24.0,
  43.     LMNULL 
  44. };
  45.  
  46. float object_color_emission[] = {
  47.     EMISSION,   1.0, 0.1, 1.0,
  48.     LMNULL
  49. };
  50.  
  51.     
  52.  
  53.     lmdef(DEFMATERIAL,1,0,object_color);
  54.     lmbind(MATERIAL,1);
  55.     draw_stuff();
  56.     object_color_emission[2] = .2;
  57.  
  58.     /*
  59.      * Since material #1 is bound, these changes will take place now.
  60.      * Only emission is changed.
  61.      */
  62.     lmdef(DEFMATERIAL,1,0,object_color_emission);
  63.     
  64.     draw_stuff();
  65.  
  66. If you have LOTS of such changes, uou can use lmcolor:
  67.  
  68.     float c[][3] = {
  69.         0,0,0,
  70.         .1,0,0,
  71.         0.,.1,0,    etc.
  72.     };
  73.  
  74.     lmdef(DEFMATERIAL,1,0,object_color);
  75.     lmbind(MATERIAL,1);
  76.     lmcolor(LMC_EMISSION);
  77.  
  78.     /* new emission for each polygon ... */
  79.     for( i = 0; i < sizeof(c)/sizeof(c[0]); i++) {
  80.         c3f(c[i]);
  81.         draw_polygon(i);
  82.     }
  83.  
  84.     /* new emission for each vertex ... */
  85.     bgnpolygon();
  86.     for( i = 0; ...; i++) {
  87.         c3f(c[i]);
  88.         n3f(n[i]);
  89.         v3f(v[i]);
  90.     }
  91.     endpolygon();
  92.  
  93.  
  94.     LMC_AD is a popular way to use lmcolor.
  95.  
  96.  
  97.  
  98.     
  99.  
  100.  
  101. Reuel Nash    (713)293-9292    FAX (713)293-0503
  102. Silicon Graphics, 11490 Westheimer Suite 100, Houston, TX  77077
  103.  
  104. Visualize Whirled Peas
  105.