From: tesmith (tesmith++at++praxis.jsc.nasa.gov)
Date: 04/17/2001 07:46:34
Simon C Mills wrote:
> BTW, the .star loader has an artificial brightening factor applied to
> all stars which makes more bright stars (looks nice) but which also
> makes it more difficult to recognise constellations. I wanted an
> accurate representation of the stars so I commented this out and
> compiled my own version of the loader. I also converted to use the
> currently recommended pfLightPoint API functions.
The artificial brightening factor is a result of Performer treating
magnitude like a linear scale. I was able to accuratly recreate the
magnitude as well as the color (which can be found in the Yale Star
Catalog in column 109) of the stars using the following:
// If t=0 color_range returns a, if t=1 color_range=b
float color_range(float a, float b, float t)
{
return ((b-a)*t)+a;
}
.
.
.
// Rescale magnitude (this will be used as a scaling factor
// for the rgb color components
stars.mag[i]=pow(10.0, (6.0-stars.mag[i])/2.5)*0.1;
if (stars.mag[i]<0.0)
stars.mag[i]=0.0;
if (stars.mag[i]>1.0)
stars.mag[i]=1.0;
strncpy(tmp, buf+109, 5); tmp[5]='\0';
stars.color[i] = atof(tmp);
if (stars.color[i]>1.41)
stars.r[i]=1.0; stars.g[i]=0.5; stars.b[i]=0.5;
else if ((stars.color[i]<=1.41) && (stars.color[i]>0.82))
{
stars.r[i]=color_range(1.0, 1.0, (stars.color[i]-0.82)/(1.41-0.82));
stars.g[i]=color_range(0.75, 0.5, (stars.color[i]-0.82)/(1.41-0.82));
stars.b[i]=color_range(0.54, 0.5, (stars.color[i]-0.82)/(1.41-0.82));
}
else if ((stars.color[i]<=0.82) && (stars.color[i]>0.59))
{
stars.r[i]=color_range(1.0, 1.0, (stars.color[i]-0.59)/(0.82-0.59));
stars.g[i]=color_range(1.0, 0.75, (stars.color[i]-0.59)/(0.82-0.59));
stars.b[i]=color_range(0.7, 0.54, (stars.color[i]-0.59)/(0.82-0.59));
}
else if ((stars.color[i]<=0.59) && (stars.color[i]>0.31))
{
stars.r[i]=color_range(1.0, 1.0, (stars.color[i]-0.31)/(0.59-0.31));
stars.g[i]=color_range(1.0, 1.0, (stars.color[i]-0.31)/(0.59-0.31));
stars.b[i]=color_range(0.83, 0.7, (stars.color[i]-0.31)/(0.59-0.31));
}
else if ((stars.color[i]<=0.31) && (stars.color[i]>0.0))
{
stars.r[i]=color_range(1.0, 1.0, (stars.color[i]-0.0)/(0.31-0.0));
stars.g[i]=color_range(1.0, 1.0, (stars.color[i]-0.0)/(0.31-0.0));
stars.b[i]=color_range(1.0, 0.83, (stars.color[i]-0.0)/(0.31-0.0));
}
else if ((stars.color[i]<=0.0) && (stars.color[i]>-0.29))
{
stars.r[i]=color_range(0.61, 1.0, (stars.color[i]+0.29)/(0.0+0.29));
stars.g[i]=color_range(0.61, 1.0, (stars.color[i]+0.29)/(0.0+0.29));
stars.b[i]=color_range(1.0, 1.0, (stars.color[i]+0.29)/(0.0+0.29));
}
else if (stars.color[i]<=-0.29)
{
stars.r[i]=0.61;
stars.g[i]=0.61;
stars.b[i]=1.0;
}
.
.
.
// Then color stars using the new computed magnitude like this:
color[0] = stars->mag[i]*stars->r[i];
color[1] = stars->mag[i]*stars->g[i];
color[2] = stars->mag[i]*stars->b[i];
glColor3fv(color);
------------------------------------------------------------------
Tom Smith
Barrios Technologies
This archive was generated by hypermail 2b29 : Tue Apr 17 2001 - 07:47:58 PDT