🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.sys.sgi.graphics
3 messages
3 total messages Started by Frederick R. Phelan Jr. Wed, 23 Dec 1992 20:44
Setting Material Color
#13
Author: Frederick R. Phelan Jr.
Date: Wed, 23 Dec 1992 20:44
27 lines
887 bytes
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?  

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?

Fred
---
Fred Phelan
fred@poly2.nist.gov
Re: Setting Material Color
#14
Author: Reuel Nash
Date: Wed, 23 Dec 1992 22:01
100 lines
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
Re: Setting Material Color
#16
Author: Gavin Bell
Date: Wed, 23 Dec 1992 22:15
40 lines
1839 bytes
In <7671@dove.nist.gov> fred@poly2.nist.gov (Frederick R. Phelan Jr.) 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.  Use lmcolor(LMC_EMISSION) if you are only changing that one
property, and use c3f() or cpack() commands to change it.

>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?

Changing the value in the array is not sufficient-- you need to send
the values to the GL.  Use lmcolor() if you can, or just issue another
lmdef() with just the values you are changing:

float object_emission[] = { EMISSION, 0.2, 0.5, 0.1, LMNULL };
lmdef(DEFMATERIAL, 1, 5, object_emission);

In OpenGL, this is much simpler-- material properties are just like
colors.  You set them and forget them.

So, in OpenGL, your code will look like:

float emission[3] = { 1.0, 0.1, 1.0 };
glMaterialfv(GL_FRONT, GL_EMISSION, emission);

... no bind necessary.
--
--gavin     (gavin@sgi.com,  (415)390-1024)
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads