

Public Member Functions | |
| void | process (const Star &star, float distance, float appMag) |
| StarRenderer () | |
Public Attributes | |
| const ColorTemperatureTable * | colorTemp |
| vector< Renderer::Particle > * | glareParticles |
| float | maxDiscSize |
| Point3f | obsPos |
| vector< RenderListEntry > * | renderList |
| Renderer::StarVertexBuffer * | starVertexBuffer |
| bool | useDiscs |
|
|
Definition at line 6304 of file render.cpp. References STAR_DISTANCE_LIMIT. 06304 : 06305 ObjectRenderer<Star, float>(STAR_DISTANCE_LIMIT), 06306 starVertexBuffer(0), 06307 useDiscs (false), 06308 maxDiscSize (1.0f), 06309 colorTemp (NULL) 06310 { 06311 }
|
|
||||||||||||||||
|
Reimplemented from ObjectRenderer< Star, float >. Definition at line 6314 of file render.cpp. References astro::absToAppMag(), Renderer::StarVertexBuffer::addStar(), RenderListEntry::appMag, astrocentricPosition(), RenderListEntry::body, Renderer::Particle::center, clamp(), Renderer::Particle::color, colorTemp, RenderListEntry::discSizeInPixels, RenderListEntry::distance, distance(), Point3< T >::distanceFromOrigin(), FOV, Observer::getPosition(), Observer::getTime(), glareParticles, RenderListEntry::isCometTail, astro::kilometersToLightYears(), Vector3< T >::length(), astro::lightYearsToKilometers(), ColorTemperatureTable::lookupColor(), maxDiscSize, min, obsPos, RenderListEntry::position, RenderListEntry::radius, RenderDistance, renderList, Renderer::Particle::size, RenderListEntry::star, starVertexBuffer, useDiscs, Point3< T >::x, Vector3< T >::x, Vector3< T >::y, Point3< T >::y, Vector3< T >::z, and Point3< T >::z. 06315 {
06316 nProcessed++;
06317
06318 Point3f starPos = star.getPosition();
06319 Vec3f relPos = starPos - obsPos;
06320 float orbitalRadius = star.getOrbitalRadius();
06321 bool hasOrbit = orbitalRadius > 0.0f;
06322
06323 if (distance > distanceLimit)
06324 return;
06325
06326 if (relPos * viewNormal > 0 || relPos.x * relPos.x < 0.1f || hasOrbit)
06327 {
06328 Color starColor = colorTemp->lookupColor(star.getTemperature());
06329 float renderDistance = distance;
06330 float s = renderDistance * size;
06331 float discSizeInPixels = 0.0f;
06332 float orbitSizeInPixels = 0.0f;
06333
06334 if (hasOrbit)
06335 orbitSizeInPixels = orbitalRadius / (distance * pixelSize);
06336
06337 // Special handling for stars less than one light year away . . .
06338 // We can't just go ahead and render a nearby star in the usual way
06339 // for two reasons:
06340 // * It may be clipped by the near plane
06341 // * It may be large enough that we should render it as a mesh
06342 // instead of a particle
06343 // It's possible that the second condition might apply for stars
06344 // further than one light year away if the star is huge, the fov is
06345 // very small and the resolution is high. We'll ignore this for now
06346 // and use the most inexpensive test possible . . .
06347 if (distance < 1.0f || orbitSizeInPixels > 1.0f)
06348 {
06349 // Compute the position of the observer relative to the star.
06350 // This is a much more accurate (and expensive) distance
06351 // calculation than the previous one which used the observer's
06352 // position rounded off to floats.
06353 Point3d hPos = astrocentricPosition(observer->getPosition(),
06354 star,
06355 observer->getTime());
06356 relPos = Vec3f((float) hPos.x, (float) hPos.y, (float) hPos.z) *
06357 -astro::kilometersToLightYears(1.0f),
06358 distance = relPos.length();
06359
06360 // Recompute apparent magnitude using new distance computation
06361 appMag = astro::absToAppMag(star.getAbsoluteMagnitude(), distance);
06362
06363 float f = RenderDistance / distance;
06364 renderDistance = RenderDistance;
06365 starPos = obsPos + relPos * f;
06366
06367 float radius = star.getRadius();
06368 discSizeInPixels = radius / astro::lightYearsToKilometers(distance) / pixelSize;
06369 ++nClose;
06370 }
06371
06372 if (discSizeInPixels <= 1)
06373 {
06374 float alpha = (faintestMag - appMag) * brightnessScale + brightnessBias;
06375
06376 if (useDiscs)
06377 {
06378 float discSize = size;
06379 if (alpha < 0.0f)
06380 {
06381 alpha = 0.0f;
06382 }
06383 else if (alpha > 1.0f)
06384 {
06385 discSize = min(discSize * (2.0f * alpha - 1.0f), maxDiscSize);
06386 alpha = 1.0f;
06387 }
06388 starVertexBuffer->addStar(starPos,
06389 Color(starColor, alpha),
06390 renderDistance * discSize);
06391 }
06392 else
06393 {
06394 alpha = clamp(alpha);
06395 starVertexBuffer->addStar(starPos,
06396 Color(starColor, alpha),
06397 renderDistance * size);
06398 }
06399
06400 ++nRendered;
06401
06402 // If the star is brighter than the saturation magnitude, add a
06403 // halo around it to make it appear more brilliant. This is a
06404 // hack to compensate for the limited dynamic range of monitors.
06405 if (appMag < saturationMag)
06406 {
06407 Renderer::Particle p;
06408 p.center = starPos;
06409 p.size = renderDistance * size;
06410 p.color = Color(starColor, alpha);
06411
06412 alpha = 0.4f * clamp((appMag - saturationMag) * -0.8f);
06413 s = renderDistance * 0.001f * (3 - (appMag - saturationMag)) * 2;
06414 if (s > p.size * 3 )
06415 p.size = s * 2.0f/(1.0f + FOV/fov);
06416 else
06417 p.size = p.size * 3;
06418 p.color = Color(starColor, alpha);
06419 glareParticles->insert(glareParticles->end(), p);
06420 ++nBright;
06421 }
06422 }
06423 else
06424 {
06425 RenderListEntry rle;
06426 rle.star = ☆
06427 rle.body = NULL;
06428 rle.isCometTail = false;
06429
06430 // Objects in the render list are always rendered relative to
06431 // a viewer at the origin--this is different than for distant
06432 // stars.
06433 float scale = astro::lightYearsToKilometers(1.0f);
06434 rle.position = Point3f(relPos.x * scale, relPos.y * scale, relPos.z * scale);
06435 rle.distance = rle.position.distanceFromOrigin();
06436 rle.radius = star.getRadius();
06437 rle.discSizeInPixels = discSizeInPixels;
06438 rle.appMag = appMag;
06439 renderList->insert(renderList->end(), rle);
06440 }
06441 }
06442 }
|
|
|
Definition at line 6300 of file render.cpp. Referenced by process(), and Renderer::renderStars(). |
|
|
Definition at line 6293 of file render.cpp. Referenced by process(), and Renderer::renderStars(). |
|
|
Definition at line 6298 of file render.cpp. Referenced by process(), and Renderer::renderStars(). |
|
|
Definition at line 6291 of file render.cpp. Referenced by process(), and Renderer::renderStars(). |
|
|
Definition at line 6294 of file render.cpp. Referenced by process(), and Renderer::renderStars(). |
|
|
Definition at line 6295 of file render.cpp. Referenced by process(), and Renderer::renderStars(). |
|
|
Definition at line 6297 of file render.cpp. Referenced by process(), and Renderer::renderStars(). |
1.4.1