PDA

View Full Version : How to define a variable-color-mapping?



earth_walker
08-19-2003, 09:02 AM
Hi!

I want to draw a polygon representing an area. Each point in the area has its temperature property. So every points in the polygon may have different colors. The temperature is defined in each vertices of polygon, and it is assumed to linearly interpolated between vertices.

I can define two colors for the extreme temperature values, map them to two different colors, do linear mapping between these two temperature values.

for example, I let maximum temperature to be 100, and the minumn to be 0.



glBegin(GL_POLYGON)
glColor4f( temp1/100, 0, 0);
glVertex3f(......);
glColor4f( temp2/100, 0, 0);
glVertex3f(......);
glColor4f( temp3/100, 0, 0);
glVertex3f(......);
glEnd;


However, this way can only do linear mapping. It cannot make the variable-color-mapping more visually comfortable. For example, I want to map the minumn value to green; when the variable increase, it goes to yellow; from yellow it changes to red when the color increase to maximum.

I want the [green]-[yellow]-[red] mapping, but if I define two vertices to green and red, I can only get [green]-[other color]-red, which does not meet requirement of color mapping.

How can I solve this problem? Thank you very much!

Deiussum
08-19-2003, 09:16 AM
It sounds like you want something like a 1-dimensional texture. Just have the texture go through the progression of colors you want, and then use glTexCoord1f to specify where in the texture the particular color you want for a point is.

earth_walker
08-19-2003, 09:54 AM
Thank you! I will read something about texture.

earth_walker
08-19-2003, 11:32 AM
Hi!
If I don't use Lighting, Blending, Antialiasing, Fog, can I still use texturing? The reason I ask this is I haven't read those parts of the reference book. Can I directly read the part of texturing?
Thank you!

errno
08-20-2003, 12:32 AM
yes you can.

earth_walker
08-20-2003, 04:41 AM
Thank you!

earth_walker
08-20-2003, 11:59 AM
Thank you!