SkyDrawer.hpp   StelSkyDrawer.hpp 
skipping to change at line 20 skipping to change at line 20
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA.
*/ */
#ifndef _SKYDRAWER_HPP_ #ifndef _STELSKYDRAWER_HPP_
#define _SKYDRAWER_HPP_ #define _STELSKYDRAWER_HPP_
#include "STextureTypes.hpp" #include "StelTextureTypes.hpp"
#include "vecmath.h" #include "StelProjectorType.hpp"
#include "VecMath.hpp"
#include <QObject> #include <QObject>
class Projector; class StelToneReproducer;
class ToneReproducer;
class StelCore; class StelCore;
class StelPainter;
//! @class SkyDrawer //! @class StelSkyDrawer
//! Provide a set of methods used to draw sky objects taking into account //! Provide a set of methods used to draw sky objects taking into account
//! eyes adaptation, zoom level and instrument model //! eyes adaptation, zoom level and instrument model
class SkyDrawer : public QObject class StelSkyDrawer : public QObject
{ {
Q_OBJECT; Q_OBJECT
public: public:
//! Constructor //! Constructor
SkyDrawer(StelCore* core); StelSkyDrawer(StelCore* core);
//! Destructor //! Destructor
~SkyDrawer(); ~StelSkyDrawer();
//! Init parameters from config file //! Init parameters from config file
void init(); void init();
//! Update with respect to the time and Projector/ToneReproducer sta te //! Update with respect to the time and StelProjector/StelToneReprod ucer state
//! @param deltaTime the time increment in second since last call. //! @param deltaTime the time increment in second since last call.
void update(double deltaTime); void update(double deltaTime);
//! Get the painter currently used or NULL
const StelPainter* getPainter() {return sPainter;}
//! Set the proper openGL state before making calls to drawPointSour ce //! Set the proper openGL state before making calls to drawPointSour ce
void preDrawPointSource(); //! @param p a pointer to a valid instance of a Painter. The instanc
e must be valid until postDrawPointSource() is called
void preDrawPointSource(const StelPainter* p);
//! Finalize the drawing of point sources //! Finalize the drawing of point sources
void postDrawPointSource(); void postDrawPointSource();
//! Draw a point source halo. //! Draw a point source halo.
//! @param x the x position of the object on the screen //! @param x the x position of the object on the screen
//! @param y the y position of the object on the screen //! @param y the y position of the object on the screen
//! @param mag the source magnitude //! @param rcMag the radius and luminance of the source as computed by computeRCMag()
//! @param bV the source B-V index //! @param bV the source B-V index
//! @return true if the source was actually visible and drawn //! @return true if the source was actually visible and drawn
bool drawPointSource(double x, double y, const float rcMag[2], unsig ned int bV) bool drawPointSource(double x, double y, const float rcMag[2], unsig ned int bV)
{return drawPointSource(x, y, rcMag, colorTable[bV]);} {return drawPointSource(x, y, rcMag, colorTable[bV]);}
bool drawPointSource(double x, double y, const float rcMag[2], const Vec3f& color); bool drawPointSource(double x, double y, const float rcMag[2], const Vec3f& color);
//! Draw a disk source halo. The real surface brightness is smaller as if it were a //! Draw a disk source halo. The real surface brightness is smaller as if it were a
//! point source because the flux is spread on the disk area //! point source because the flux is spread on the disk area
//! @param x the x position of the disk center in pixel //! @param x the x position of the disk center in pixel
//! @param y the y position of the disk centre in pixel //! @param y the y position of the disk centre in pixel
//! @param r radius of the disk in pixel //! @param r radius of the disk in pixel
//! @param mag the source integrated magnitude //! @param mag the source integrated magnitude
//! @param color the source RGB color //! @param color the source RGB color
//! @return true if the source was actually visible and drawn //! @return true if the source was actually visible and drawn
bool drawDiskSource(double x, double y, double r, float mag, const V ec3f& color); bool drawDiskSource(double x, double y, double r, float mag, const V ec3f& color);
//! Set-up openGL lighting and color before drawing a 3d model.
//! @param illuminatedArea the total illuminated area in arcmin^2
//! @param mag the object integrated V magnitude
//! @param lighting whether lighting computations should be activate
d for rendering
void preDrawSky3dModel(double illuminatedArea, float mag, bool light
ing=true);
//! Terminate drawing of a 3D model, draw the halo //! Terminate drawing of a 3D model, draw the halo
//! @param x the x position of the object centroid in pixel //! @param x the x position of the object centroid in pixel
//! @param y the y position of the object centroid in pixel //! @param y the y position of the object centroid in pixel
//! @param illuminatedArea the illuminated area in arcmin^2
//! @param mag the source integrated magnitude
//! @param p the StelPainter instance to use for this drawing operat
ion
//! @param color the object halo RGB color //! @param color the object halo RGB color
void postDrawSky3dModel(double x, double y, double illuminatedArea, float mag, const Vec3f& color = Vec3f(1.f,1.f,1.f)); void postDrawSky3dModel(double x, double y, double illuminatedArea, float mag, const StelPainter* p, const Vec3f& color = Vec3f(1.f,1.f,1.f));
//! Compute RMag and CMag from magnitude. //! Compute RMag and CMag from magnitude.
//! @param mag the object integrated V magnitude //! @param mag the object integrated V magnitude
//! @param rcMag array of 2 floats containing the radius and luminan ce //! @param rcMag array of 2 floats containing the radius and luminan ce
//! @return false if the object is too faint to be displayed //! @return false if the object is too faint to be displayed
bool computeRCMag(float mag, float rcMag[2]) const; bool computeRCMag(float mag, float rcMag[2]) const;
//! Report that an object of luminance lum with an on-screen area of area pixels is currently displayed //! Report that an object of luminance lum with an on-screen area of area pixels is currently displayed
//! This information is used to determine the world adaptation lumin ance //! This information is used to determine the world adaptation lumin ance
//! This method should be called during the update operations of the main loop //! This method should be called during the update operations of the main loop
//! @param lum luminance in cd/m^2 //! @param lum luminance in cd/m^2
//! @param fastAdaptation adapt the eye quickly if true, other wise use a smooth adaptation //! @param fastAdaptation adapt the eye quickly if true, other wise use a smooth adaptation
void reportLuminanceInFov(double lum, bool fastAdaptation=false); void reportLuminanceInFov(double lum, bool fastAdaptation=false);
//! To be called before the drawing stage starts //! To be called before the drawing stage starts
void preDraw(); void preDraw();
//! Compute the luminance for an extended source with the given surf ace brightness //! Compute the luminance for an extended source with the given surf ace brightness
//! @param sb Surface brightness in V magnitude/arcmin^2 //! @param sb surface brightness in V magnitude/arcmin^2
//! @return the luminance in cd/m^2 //! @return the luminance in cd/m^2
static float surfacebrightnessToLuminance(float sb); static float surfacebrightnessToLuminance(float sb);
//! Compute the surface brightness from the luminance of an extended
source
//! @param lum luminance in cd/m^2
//! @return surface brightness in V magnitude/arcmin^2
static float luminanceToSurfacebrightness(float lum);
//! Convert quantized B-V index to float B-V //! Convert quantized B-V index to float B-V
static inline float indexToBV(unsigned char bV) static inline float indexToBV(unsigned char bV)
{ {
return (float)bV*(4.f/127.f)-0.5f; return (float)bV*(4.f/127.f)-0.5f;
} }
//! Convert quantized B-V index to RGB colors //! Convert quantized B-V index to RGB colors
static inline const Vec3f& indexToColor(unsigned char bV) static inline const Vec3f& indexToColor(unsigned char bV)
{ {
skipping to change at line 181 skipping to change at line 187
private: private:
// Debug // Debug
float reverseComputeRCMag(float rmag) const; float reverseComputeRCMag(float rmag) const;
//! Compute the current limit magnitude by dichotomy //! Compute the current limit magnitude by dichotomy
float computeLimitMagnitude() const; float computeLimitMagnitude() const;
//! Compute the current limit luminance by dichotomy //! Compute the current limit luminance by dichotomy
float computeLimitLuminance() const; float computeLimitLuminance() const;
//! Get SkyDrawer maximum FOV. //! Get StelSkyDrawer maximum FOV.
float getMaxFov(void) const {return maxFov;} float getMaxAdaptFov(void) const {return maxAdaptFov;}
//! Set SkyDrawer maximum FOV. //! Set StelSkyDrawer maximum FOV.
//! Usually stars/planet halos are drawn fainter when FOV gets large r, //! Usually stars/planet halos are drawn fainter when FOV gets large r,
//! but when FOV gets larger than this value, the stars do not becom e //! but when FOV gets larger than this value, the stars do not becom e
//! fainter any more. Must be >= 60.0. //! fainter any more. Must be >= 60.0.
void setMaxFov(float fov) {maxFov = (fov < 60.f) ? 60.f : fov;} void setMaxAdaptFov(float fov) {maxAdaptFov = (fov < 60.f) ? 60.f : fov;}
//! Get SkyDrawer minimum FOV. //! Get StelSkyDrawer minimum FOV.
float getMinFov(void) const {return minFov;} float getMinAdaptFov(void) const {return minAdaptFov;}
//! Set SkyDrawer minimum FOV. //! Set StelSkyDrawer minimum FOV.
//! Usually stars/planet halos are drawn brighter when FOV gets smal ler. //! Usually stars/planet halos are drawn brighter when FOV gets smal ler.
//! But when FOV gets smaller than this value, the stars do not beco me //! But when FOV gets smaller than this value, the stars do not beco me
//! brighter any more. Must be <= 60.0. //! brighter any more. Must be <= 60.0.
void setMinFov(float fov) {minFov = (fov > 60.f) ? 60.f : fov;} void setMinAdaptFov(float fov) {minAdaptFov = (fov > 60.f) ? 60.f : fov;}
//! Set the scaling applied to input luminance before they are conve rted by the ToneReproducer //! Set the scaling applied to input luminance before they are conve rted by the StelToneReproducer
void setInputScale(double in) {inScale = in;} void setInputScale(double in) {inScale = in;}
//! Get the scaling applied to input luminance before they are conve rted by the ToneReproducer //! Get the scaling applied to input luminance before they are conve rted by the StelToneReproducer
float getInputScale() const {return inScale;} float getInputScale() const {return inScale;}
//! Compute the luminance for a point source with the given mag for the current FOV //! Compute the luminance for a point source with the given mag for the current FOV
//! @param mag V magnitude of the point source //! @param mag V magnitude of the point source
//! @return the luminance in log(cd/m^2) //! @return the luminance in log(cd/m^2)
inline float pointSourceMagToLuminance(float mag) const {return std: :exp(pointSourceMagToLnLuminance(mag));} inline float pointSourceMagToLuminance(float mag) const {return std: :exp(pointSourceMagToLnLuminance(mag));}
//! Compute the V magnitude for a point source with the given lumina nce for the current FOV //! Compute the V magnitude for a point source with the given lumina nce for the current FOV
//! @param lum the luminance in cd/m^2 //! @param lum the luminance in cd/m^2
//! @return V magnitude of the point source //! @return V magnitude of the point source
skipping to change at line 222 skipping to change at line 228
//! Compute the log of the luminance for a point source with the giv en mag for the current FOV //! Compute the log of the luminance for a point source with the giv en mag for the current FOV
//! @param mag V magnitude of the point source //! @param mag V magnitude of the point source
//! @return the luminance in cd/m^2 //! @return the luminance in cd/m^2
float pointSourceMagToLnLuminance(float mag) const; float pointSourceMagToLnLuminance(float mag) const;
//! Find the world adaptation luminance to use so that a point sourc e of magnitude mag //! Find the world adaptation luminance to use so that a point sourc e of magnitude mag
//! is displayed with a halo of size targetRadius //! is displayed with a halo of size targetRadius
float findWorldLumForMag(float mag, float targetRadius); float findWorldLumForMag(float mag, float targetRadius);
StelCore* core; StelCore* core;
Projector* prj; StelToneReproducer* eye;
ToneReproducer* eye;
float maxFov, minFov, lnfovFactor; float maxAdaptFov, minAdaptFov, lnfovFactor;
bool flagPointStar; bool flagPointStar;
bool flagStarTwinkle; bool flagStarTwinkle;
float twinkleAmount; float twinkleAmount;
float starRelativeScale; float starRelativeScale;
float starAbsoluteScaleF; float starAbsoluteScaleF;
float starLinearScale; // optimization variable float starLinearScale; // optimization variable
//! Current magnitude limit for point sources //! Current magnitude limit for point sources
float limitMagnitude; float limitMagnitude;
//! Current magnitude luminance //! Current magnitude luminance
float limitLuminance; float limitLuminance;
//! Little halo texture //! Little halo texture
STextureSP texHalo; StelTextureSP texHalo;
//! Load B-V conversion parameters from config file //! Load B-V conversion parameters from config file
void initColorTableFromConfigFile(class QSettings* conf); void initColorTableFromConfigFile(class QSettings* conf);
//! Contains the list of colors matching a given B-V index //! Contains the list of colors matching a given B-V index
static Vec3f colorTable[128]; static Vec3f colorTable[128];
//! The current Bortle Scale index //! The current Bortle Scale index
int bortleScaleIndex; int bortleScaleIndex;
//! The scaling applied to input luminance before they are converted by the ToneReproducer //! The scaling applied to input luminance before they are converted by the StelToneReproducer
double inScale; double inScale;
// Variables used for GL optimization when displaying point sources // Variables used for GL optimization when displaying point sources
//! Buffer for storing the vertex array data //! Buffer for storing the vertex array data
Vec2f* verticesGrid; Vec2f* verticesGrid;
//! Buffer for storing the color array data //! Buffer for storing the color array data
Vec3f* colorGrid; Vec3f* colorGrid;
//! Buffer for storing the texture coordinate array data //! Buffer for storing the texture coordinate array data
Vec2f* textureGrid; Vec2f* textureGrid;
//! Current number of sources stored in the buffers (still to displa y) //! Current number of sources stored in the buffers (still to displa y)
unsigned int nbPointSources; unsigned int nbPointSources;
//! Maximum number of sources which can be stored in the buffers //! Maximum number of sources which can be stored in the buffers
unsigned int maxPointSources; unsigned int maxPointSources;
//! The maximum transformed luminance to apply at the next update //! The maximum transformed luminance to apply at the next update
float maxLum; float maxLum;
//! The previously used world luminance //! The previously used world luminance
float oldLum; float oldLum;
//! Big halo texture //! Big halo texture
STextureSP texBigHalo; StelTextureSP texBigHalo;
STextureSP texSunHalo; StelTextureSP texSunHalo;
bool flagLuminanceAdaptation; bool flagLuminanceAdaptation;
const StelPainter* sPainter;
}; };
#endif // _SKYDRAWER_HPP_ #endif // _STELSKYDRAWER_HPP_
 End of changes. 31 change blocks. 
41 lines changed or deleted 49 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/