Article View: comp.sys.sgi.graphics
Article #14Re: Setting Material Color
From: Reuel Nash
Date: Wed, 23 Dec 1992 22:01
Date: Wed, 23 Dec 1992 22:01
100 lines
2364 bytes
2364 bytes
In article <7671@dove.nist.gov>, fred@poly2.nist.gov writes:
> Suppose you have a material color:
>
> float object_color[] =
> {
> DIFFUSE, 0.1, 1.0, 0.2,
> SPECULAR, 0.3, 0.9, 0.3,
> EMISSION, 1.0, 0.1, 1.0,
> SHININESS, 24.0,
> LMNULL
> };
>
> which has been set with:
>
> lmdef(DEFMATERIAL, 1, 15, object_color);
>
>
> First, are you allowed to change the EMISSION values (or really any
> of object_color's properties) on the fly?
Yes.
>
> Second, If you can change on the fly, do you need to do a new call to
> lmdef every time for the changes to take effect or is the first call
> sufficient?
>
You have to call lmdef each time:
float object_color[] =
{
DIFFUSE, 0.1, 1.0, 0.2,
SPECULAR, 0.3, 0.9, 0.3,
EMISSION, 1.0, 0.1, 1.0,
SHININESS, 24.0,
LMNULL
};
float object_color_emission[] = {
EMISSION, 1.0, 0.1, 1.0,
LMNULL
};
lmdef(DEFMATERIAL,1,0,object_color);
lmbind(MATERIAL,1);
draw_stuff();
object_color_emission[2] = .2;
/*
* Since material #1 is bound, these changes will take place now.
* Only emission is changed.
*/
lmdef(DEFMATERIAL,1,0,object_color_emission);
draw_stuff();
If you have LOTS of such changes, uou can use lmcolor:
float c[][3] = {
0,0,0,
.1,0,0,
0.,.1,0, etc.
};
lmdef(DEFMATERIAL,1,0,object_color);
lmbind(MATERIAL,1);
lmcolor(LMC_EMISSION);
/* new emission for each polygon ... */
for( i = 0; i < sizeof(c)/sizeof(c[0]); i++) {
c3f(c[i]);
draw_polygon(i);
}
/* new emission for each vertex ... */
bgnpolygon();
for( i = 0; ...; i++) {
c3f(c[i]);
n3f(n[i]);
v3f(v[i]);
}
endpolygon();
LMC_AD is a popular way to use lmcolor.
Reuel Nash (713)293-9292 FAX (713)293-0503
Silicon Graphics, 11490 Westheimer Suite 100, Houston, TX 77077
Visualize Whirled Peas
Technical Details
Message-ID:
<1hanj7INNpu4@fido.asd.sgi.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!usc!sdd.hp.com!spool.mu.edu!olivea!sgigate!sgi!fido!blivet!reuelReferences:
<7671@dove.nist.gov>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!sdd.hp.com!spool.mu.edu!olivea!sgigate!sgi!fido!blivet!reuel From: reuel@blivet.houst.sgi.com (Reuel Nash) Newsgroups: comp.sys.sgi.graphics Subject: Re: Setting Material Color Message-ID: <1hanj7INNpu4@fido.asd.sgi.com> Date: 23 Dec 92 22:01:11 GMT References: <7671@dove.nist.gov> Organization: Silicon Graphics, Inc. Mountain View, CA Lines: 100 NNTP-Posting-Host: blivet.houst.sgi.com