Hello, Seattle!

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

Hello, Seattle!

Post #1by HankR » 31.01.2003, 18:21

Just for fun, Celestia developers (or anyone able to build their own version of Celestia from the source files) might like to try out this bit of code:

Code: Select all

 if ( discSize > 150 && body->getName() == "Earth")
 {
   string featureName = "Seattle";
   double lat = 47.6, lon = -122.35;
   double theta = (90-lat)/180*PI;
   double phi = ((lon<180)?(lon+180):(lon-180))/180*PI;
   double r = body->getRadius();
   Point3d locd = Point3d( r*sin(theta)*cos(phi), r*cos(theta), -r*sin(theta)*sin(phi) );
   Vec3d posf = (locd * body->getGeographicToHeliocentric(now)) - observerPos;
   Vec3f fpos((float) posf.x, (float) posf.y, (float) posf.z);
   labelColor = Color(0.0f, 1.0f, 0.0f);
   if ( ( (pos-fpos) * Vec3f( posf.x, posf.y, posf.z ) ) > 0 )
      addLabel(featureName, labelColor, Point3f(fpos.x, fpos.y, fpos.z), 1.0f);
 }


Put it in the file 'render.cpp' in the method 'Renderer::renderPlanetarySystem' inside the 'if (showLabel)' block near line 3670. Then rebuild Celestia, start it up, turn on planet labels, go to planet Earth, and zoom in on the USA's Pacific Northwest...

- Hank

Return to “Development”