StelSkyDrawer.hpp   StelSkyDrawer.hpp 
skipping to change at line 23 skipping to change at line 23
* 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., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#ifndef _STELSKYDRAWER_HPP_ #ifndef _STELSKYDRAWER_HPP_
#define _STELSKYDRAWER_HPP_ #define _STELSKYDRAWER_HPP_
#include "StelTextureTypes.hpp"
#include "StelProjectorType.hpp" #include "StelProjectorType.hpp"
#include "VecMath.hpp" #include "VecMath.hpp"
#include "RefractionExtinction.hpp" #include "RefractionExtinction.hpp"
#include "renderer/StelIndexBuffer.hpp"
#include "renderer/StelVertexBuffer.hpp"
#include <QObject> #include <QObject>
class StelToneReproducer; class StelToneReproducer;
class StelCore; class StelCore;
class StelPainter;
//! @class StelSkyDrawer //! @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 StelSkyDrawer : public QObject class StelSkyDrawer : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
//! Constructor //! Constructor
StelSkyDrawer(StelCore* core); StelSkyDrawer(StelCore* core, class StelRenderer* renderer);
//! Destructor //! Destructor
~StelSkyDrawer(); ~StelSkyDrawer();
//! Init parameters from config file //! Init parameters from config file
void init(); void init();
//! Update with respect to the time and StelProjector/StelToneReprod ucer state //! 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);
//! Set the proper openGL state before making calls to drawPointSour //! Prepare to draw point sources (must be called before drawing).
ce void preDrawPointSource();
//! @param p a pointer to a valid instance of a Painter. The instanc
e must be valid until postDrawPointSource() is called //! Finalize the drawing of point sources.
void preDrawPointSource(StelPainter* p); void postDrawPointSource(StelProjectorP projector);
//! Finalize the drawing of point sources //! Determine if a point source is visible (should be drawn).
void postDrawPointSource(StelPainter* sPainter); //!
//! This function is separate from drawPointSource for optimization.
//!
//! Also projects the point source to window coordinates.
//!
//! @param projector Projector to project the point sourc
e.
//! @param v the 3d position of the source in J20
00 reference frame
//! @param rcMag the radius and luminance of the sour
ce as computed by computeRCMag()
//! @param checkInScreen Whether source in screen should be c
hecked to avoid unnecessary drawing.
//! @param outWindowCoordinates Window coordinates out the point sou
rce are written here.
//!
//! @return true if the point source is visible, false otherwise.
bool pointSourceVisible(StelProjector* projector, const Vec3f& v, co
nst float rcMag[2],
bool checkInScreen, Vec3f& outWindowCoordina
tes)
{
// If radius is negative
if (rcMag[0] <= 0.0f){return false;}
return checkInScreen ? projector->projectCheck(v, outWindowC
oordinates)
: projector->project(v, outWindowCoordi
nates);
}
//! Draw a point source halo. //! Draw a point source halo.
//! @param sPainter the StelPainter to use for drawing. //!
//! @param v the 3d position of the source in J2000 reference frame //! This is used in combination with pointSourceVisible (which
//! avoids unnecessary draws and projects a point source to window c
oordinates).
//!
//! Example:
//!
//! @code
//! Vec3f win;
//! if(skyDrawer->pointSourceVisible(&(*projector), pos3D, rcMag, ch
eckInScreen, win))
//! {
//! skyDrawer->drawPointSource(win, rcMag, bV);
//! }
//! @endcode
//!
//! @param win Coordinates of the point source in the window
//! (computed by pointSourceVisible)
//! @param rcMag the radius and luminance of the source as computed by computeRCMag() //! @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
//! @param checkInScreen whether source in screen should be checked void drawPointSource(const Vec3f& win, const float rcMag[2], unsigne
to avoid unnecessary drawing. d int bV)
//! @return true if the source was actually visible and drawn {
bool drawPointSource(StelPainter* sPainter, const Vec3d& v, const fl return drawPointSource(win, rcMag, colorTable[bV]);
oat rcMag[2], unsigned int bV, bool checkInScreen=false) }
{return drawPointSource(sPainter, v, rcMag, colorTable[bV],
checkInScreen);} void drawPointSource(const Vec3f& win, const float rcMag[2], const V
ec3f& bcolor);
bool drawPointSource(StelPainter* sPainter, const Vec3d& v, const fl //! Draw's the sun's corona during a solar eclipse on earth.
oat rcMag[2], const Vec3f& bcolor, bool checkInScreen=false); void drawSunCorona(StelProjectorP projector, const Vec3d& v, float r
adius, float alpha);
//! Terminate drawing of a 3D model, draw the halo //! Terminate drawing of a 3D model, draw the halo
//! @param p the StelPainter instance to use for this drawing operat ion //! @param projector Projector to use for this drawing operation
//! @param v the 3d position of the source in J2000 reference frame //! @param v the 3d position of the source in J2000 reference frame
//! @param illuminatedArea the illuminated area in arcmin^2 //! @param illuminatedArea the illuminated area in arcmin^2
//! @param mag the source integrated magnitude //! @param mag the source integrated magnitude
//! @param color the object halo RGB color //! @param color the object halo RGB color
void postDrawSky3dModel(StelPainter* p, const Vec3d& v, float illumi natedArea, float mag, const Vec3f& color = Vec3f(1.f,1.f,1.f)); void postDrawSky3dModel(StelProjectorP projector, const Vec3d& v, fl oat illuminatedArea, float mag, 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
skipping to change at line 138 skipping to change at line 177
//! Set source twinkle amount. //! Set source twinkle amount.
void setTwinkleAmount(double b) {twinkleAmount=b;} void setTwinkleAmount(double b) {twinkleAmount=b;}
//! Get source twinkle amount. //! Get source twinkle amount.
float getTwinkleAmount() const {return twinkleAmount;} float getTwinkleAmount() const {return twinkleAmount;}
//! Set flag for source twinkling. //! Set flag for source twinkling.
void setFlagTwinkle(bool b) {flagStarTwinkle=b;} void setFlagTwinkle(bool b) {flagStarTwinkle=b;}
//! Get flag for source twinkling. //! Get flag for source twinkling.
bool getFlagTwinkle() const {return flagStarTwinkle;} bool getFlagTwinkle() const {return flagStarTwinkle;}
//! Set flag for displaying point sources as GLpoints (faster on som //! Set flag for displaying point sources as points (faster on some
e hardware but not so nice). hardware but not so nice).
void setFlagPointStar(bool b) {flagPointStar=b;} void setDrawStarsAsPoints(bool b) {drawStarsAsPoints=b;}
//! Get flag for displaying point sources as GLpoints (faster on som //! Get flag for displaying point sources as points (faster on some
e hardware but not so nice). hardware but not so nice).
bool getFlagPointStar() const {return flagPointStar;} bool getDrawStarsAsPoints() const {return drawStarsAsPoints;}
//! Set the parameters so that the stars disapear at about the limit given by the bortle scale //! Set the parameters so that the stars disapear at about the limit given by the bortle scale
//! The limit is valid only at a given zoom level (around 60 deg) //! The limit is valid only at a given zoom level (around 60 deg)
//! See http://en.wikipedia.org/wiki/Bortle_Dark-Sky_Scale //! See http://en.wikipedia.org/wiki/Bortle_Dark-Sky_Scale
void setBortleScale(int index); void setBortleScale(int index);
//! Get the current Bortle scale index //! Get the current Bortle scale index
int getBortleScale() const {return bortleScaleIndex;} int getBortleScale() const {return bortleScaleIndex;}
//! Get the magnitude of the currently faintest visible point source //! Get the magnitude of the currently faintest visible point source
//! It depends on the zoom level, on the eye adapation and on the po int source rendering parameters //! It depends on the zoom level, on the eye adapation and on the po int source rendering parameters
skipping to change at line 245 skipping to change at line 284
//! 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;
//! Used to draw the sky.
class StelRenderer* renderer;
StelToneReproducer* eye; StelToneReproducer* eye;
Extinction extinction; Extinction extinction;
Refraction refraction; Refraction refraction;
float maxAdaptFov, minAdaptFov, lnfovFactor; float maxAdaptFov, minAdaptFov, lnfovFactor;
bool flagPointStar; bool drawStarsAsPoints;
bool flagStarTwinkle; bool flagStarTwinkle;
float twinkleAmount; float twinkleAmount;
//! Informing the drawer whether atmosphere is displayed. //! Informing the drawer whether atmosphere is displayed.
//! This is used to avoid twinkling/simulate extinction/refraction. //! This is used to avoid twinkling/simulate extinction/refraction.
bool flagHasAtmosphere; bool flagHasAtmosphere;
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
StelTextureSP texHalo; class StelTextureNew* 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 StelToneReproducer //! The scaling applied to input luminance before they are converted by the StelToneReproducer
float inScale; float inScale;
// Variables used for GL optimization when displaying point sources //! 2D vertex with position and color.
//! Buffer for storing the vertex array data struct ColoredVertex
Vec2f* verticesGrid; {
//! Buffer for storing the color array data Vec2f position;
Vec3f* colorGrid; Vec3f color;
//! Buffer for storing the texture coordinate array data ColoredVertex(Vec2f position, Vec3f color):position(position
Vec2f* textureGrid; ), color(color){}
//! Current number of sources stored in the buffers (still to displa
y) VERTEX_ATTRIBUTES(Vec2f Position, Vec3f Color);
unsigned int nbPointSources; };
//! Maximum number of sources which can be stored in the buffers
unsigned int maxPointSources; //! 2D vertex with position, color and texture coordinate.
struct ColoredTexturedVertex
{
Vec2f position;
Vec3f color;
Vec2f texCoord;
ColoredTexturedVertex(Vec2f position, Vec3f color, Vec2f tex
Coord)
:position(position), color(color), texCoord(texCoord
){}
VERTEX_ATTRIBUTES(Vec2f Position, Vec3f Color, Vec2f TexCoor
d);
};
//! When stars are drawn as points, these are stored in this buffer.
StelVertexBuffer<ColoredVertex>* starPointBuffer;
//! Star sprite triangles.
StelVertexBuffer<ColoredTexturedVertex>* starSpriteBuffer;
//! Big halo triangles.
StelVertexBuffer<ColoredTexturedVertex>* bigHaloBuffer;
//! Sun halo triangles.
StelVertexBuffer<ColoredTexturedVertex>* sunHaloBuffer;
//! Sun corona triangles.
StelVertexBuffer<ColoredTexturedVertex>* coronaBuffer;
//! Are we drawing point sources at the moment?
bool drawing;
//! 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
StelTextureSP texBigHalo; class StelTextureNew* texBigHalo;
StelTextureSP texSunHalo; class StelTextureNew* texSunHalo;
class StelTextureNew* texCorona;
bool flagLuminanceAdaptation; bool flagLuminanceAdaptation;
bool useShader;
class QGLShaderProgram* starsShaderProgram;
float big3dModelHaloRadius; float big3dModelHaloRadius;
//! Are the statistics IDs initialized?
bool statisticsInitialized;
//! ID used to modify the big halo draw statistic.
int bigHaloStatID;
//! ID used to modify the sun halo draw statistic.
int sunHaloStatID;
//! ID used to modify the star draw statistic.
int starStatID;
}; };
#endif // _STELSKYDRAWER_HPP_ #endif // _STELSKYDRAWER_HPP_
 End of changes. 19 change blocks. 
49 lines changed or deleted 138 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/