star color patch

The place to discuss creating, porting and modifying Celestia's source code.
Topic author
drjoe

star color patch

Post #1by drjoe » 01.01.2003, 22:14

This is the first draft of a patch to make for more realistic star colors. When I have
the time, I'll go into the referenced URL and include different colors for subclasses
and luminosity classes. Also is anyone working on an interpolation class?

Code: Select all

===================================================================
RCS file: /cvsroot/celestia/celestia/src/celengine/stellarclass.cpp,v
retrieving revision 1.6
diff -u -r1.6 stellarclass.cpp
--- stellarclass.cpp    13 Dec 2002 18:43:48 -0000      1.6
+++ stellarclass.cpp    1 Jan 2003 21:21:10 -0000
@@ -18,32 +18,43 @@
 
 Color StellarClass::getApparentColor() const
 {
-    return getApparentColor(getSpectralClass());
+    return getApparentColor(getSpectralClass(),
+                           getSpectralSubclass(),
+                           getLuminosityClass(),
+                           getStarType());
 }
 
 
-Color StellarClass::getApparentColor(StellarClass::SpectralClass sc) const
+Color StellarClass::getApparentColor(StellarClass::SpectralClass sc,
+                                    unsigned int ssc,
+                                    StellarClass::LuminosityClass lc,
+                                    StellarClass::StarType st) const
 {
+
+// Use color table provided by Mitchell Charity (mcharity@lcs.mit.edu)
+// from http://www.vendian.org/mncharity/dir3/starcolor/
+
+#define U(x) ((unsigned char) (x))
     switch (sc)
     {
     case Spectral_O:
-        return Color(0.7f, 0.8f, 1.0f);
+      return Color(U('\x9b'),  U('\xb0'), U('\xff'));
     case Spectral_B:
-        return Color(0.8f, 0.9f, 1.0f);
+      return Color(U('\xaa'), U('\xbf'), U('\xff'));
     case Spectral_A:
-        return Color(1.0f, 1.0f, 1.0f);
+      return Color(U('\xca'), U('\xd7'), U('\xff'));
     case Spectral_F:
-        return Color(1.0f, 1.0f, 0.88f);
+      return Color(U('\xf8'), U('\xf7'), U('\xff'));
     case Spectral_G:
-        return Color(1.0f, 1.0f, 0.75f);
+      return Color(U('\xff'), U('\xf4'), U('\xea'));
     case StellarClass::Spectral_K:
-        return Color(1.0f, 0.9f, 0.7f);
+      return Color(U('\xff'), U('\xd2'), U('\xa1'));
     case StellarClass::Spectral_M:
-        return Color(1.0f, 0.7f, 0.7f);
+      return Color(U('\xff'), U('\xcc'), U('\x6f'));
     case StellarClass::Spectral_R:
     case StellarClass::Spectral_S:
     case StellarClass::Spectral_N:
-        return Color(1.0f, 0.4f, 0.4f);
+      return Color(U('\xff'), U('\xcf'), U('\x74'));
     default:
         // TODO: Figure out reasonable colors for Wolf-Rayet stars,
         // white dwarfs, and other oddities
Index: stellarclass.h
===================================================================
RCS file: /cvsroot/celestia/celestia/src/celengine/stellarclass.h,v
retrieving revision 1.4
diff -u -r1.4 stellarclass.h
--- stellarclass.h      8 May 2002 07:02:27 -0000       1.4
+++ stellarclass.h      1 Jan 2003 21:21:10 -0000
@@ -68,7 +68,10 @@
     inline LuminosityClass getLuminosityClass() const;
 
     Color getApparentColor() const;
-    Color getApparentColor(StellarClass::SpectralClass sc) const;
+    Color getApparentColor(StellarClass::SpectralClass sc,
+                          unsigned int,
+                          StellarClass::LuminosityClass,
+                          StellarClass::StarType) const;
 
     char* str(char* buf, unsigned int buflen) const;
     std::string str() const;

billybob884
Posts: 986
Joined: 16.08.2002
With us: 22 years 3 months
Location: USA, East Coast

Post #2by billybob884 » 01.02.2003, 20:24

maybe there could be just one star color: white. celestia could doall the shading for each different stage
Mike M.

TacoTopia!


Return to “Development”