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 "RefractionExtinction.hpp"
#include "StelTextureTypes.hpp"
#include "StelProjectorType.hpp" #include "StelProjectorType.hpp"
#include "VecMath.hpp" #include "VecMath.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;
//! Contains the 2 parameters necessary to draw a star on screen.
//! the radius and luminance of the star halo texture.
struct RCMag
{
float radius;
float luminance;
};
//! @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, instrument model and artificially set magn itude limits //! eyes adaptation, zoom level, instrument model and artificially set magn itude limits
class StelSkyDrawer : public QObject class StelSkyDrawer : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
//! Constructor //! Constructor
StelSkyDrawer(StelCore* core, class StelRenderer* renderer); StelSkyDrawer(StelCore* core);
//! 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);
//! Prepare to draw point sources (must be called before drawing). //! Set the proper openGL state before making calls to drawPointSour
void preDrawPointSource(); ce
//! @param p a pointer to a valid instance of a Painter. The instanc
e must be valid until postDrawPointSource() is called
void preDrawPointSource(StelPainter* p);
//! Finalize the drawing of point sources. //! Finalize the drawing of point sources
void postDrawPointSource(StelProjectorP projector); void postDrawPointSource(StelPainter* sPainter);
//! Determine if a point source is visible (should be drawn).
//!
//! 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.
//! This is used in combination with pointSourceVisible (which //! @param v the 3d position of the source in J2000 reference frame
//! 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
void drawPointSource(const Vec3f& win, const float rcMag[2], unsigne //! @param checkInScreen whether source in screen should be checked
d int bV) to avoid unnecessary drawing.
{ //! @return true if the source was actually visible and drawn
return drawPointSource(win, rcMag, colorTable[bV]); bool drawPointSource(StelPainter* sPainter, const Vec3f& v, const RC
} Mag &rcMag, unsigned int bV, bool checkInScreen=false)
{return drawPointSource(sPainter, v, rcMag, colorTable[bV],
void drawPointSource(const Vec3f& win, const float rcMag[2], const V checkInScreen);}
ec3f& bcolor);
//! Draw's the sun's corona during a solar eclipse on earth. bool drawPointSource(StelPainter* sPainter, const Vec3f& v, const RC
void drawSunCorona(StelProjectorP projector, const Vec3d& v, float r Mag &rcMag, const Vec3f& bcolor, bool checkInScreen=false);
adius, float alpha);
//! Terminate drawing of a 3D model, draw the halo //! Terminate drawing of a 3D model, draw the halo
//! @param projector Projector to use for this drawing operation //! @param p the StelPainter instance to use for this drawing operat ion
//! @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(StelProjectorP projector, const Vec3d& v, fl oat illuminatedArea, float mag, const Vec3f& color = Vec3f(1.f,1.f,1.f)); void postDrawSky3dModel(StelPainter* p, const Vec3f& v, float illumi natedArea, 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, RCMag*) 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(float lum, bool fastAdaptation=false); void reportLuminanceInFov(float lum, bool fastAdaptation=false);
//! To be called before the drawing stage starts //! To be called before the drawing stage starts
void preDraw(); void preDraw();
skipping to change at line 177 skipping to change at line 147
//! 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 points (faster on some //! Set the parameters so that the stars disappear at about the limi
hardware but not so nice). t given by the bortle scale
void setDrawStarsAsPoints(bool b) {drawStarsAsPoints=b;}
//! Get flag for displaying point sources as points (faster on some
hardware but not so nice).
bool getDrawStarsAsPoints() const {return drawStarsAsPoints;}
//! 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 setBortleScaleIndex(int index);
//! Get the current Bortle scale index //! Get the current Bortle scale index
int getBortleScale() const {return bortleScaleIndex;} int getBortleScaleIndex() 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
//! @return the limit V mag at which a point source will be displaye d //! @return the limit V mag at which a point source will be displaye d
float getLimitMagnitude() const {return limitMagnitude;} float getLimitMagnitude() const {return limitMagnitude;}
//! Toggle the application of user-defined star magnitude limit. //! Toggle the application of user-defined star magnitude limit.
//! If enabled, stars fainter than the magnitude set with //! If enabled, stars fainter than the magnitude set with
//! setCustomStarMagnitudeLimit() will not be displayed. //! setCustomStarMagnitudeLimit() will not be displayed.
// FIXME: Exposed to scripts - make sure it synchs with the GUI. --B M // FIXME: Exposed to scripts - make sure it synchs with the GUI. --B M
skipping to change at line 249 skipping to change at line 214
double getExtinctionCoefficient() const {return extinction.getExtinc tionCoefficient();} double getExtinctionCoefficient() const {return extinction.getExtinc tionCoefficient();}
//! Set atmospheric (ground) temperature in deg celsius (for refract ion). //! Set atmospheric (ground) temperature in deg celsius (for refract ion).
void setAtmosphereTemperature(double celsius) {refraction.setTempera ture(celsius);} void setAtmosphereTemperature(double celsius) {refraction.setTempera ture(celsius);}
//! Get atmospheric (ground) temperature in deg celsius (for refract ion). //! Get atmospheric (ground) temperature in deg celsius (for refract ion).
double getAtmosphereTemperature() const {return refraction.getTemper ature();} double getAtmosphereTemperature() const {return refraction.getTemper ature();}
//! Set atmospheric (ground) pressure in mbar (for refraction). //! Set atmospheric (ground) pressure in mbar (for refraction).
void setAtmospherePressure(double mbar) {refraction.setPressure(mbar );} void setAtmospherePressure(double mbar) {refraction.setPressure(mbar );}
//! Get atmospheric (ground) pressure in mbar (for refraction). //! Get atmospheric (ground) pressure in mbar (for refraction).
double getAtmospherePressure() const {return refraction.getPressure( );} double getAtmospherePressure() const {return refraction.getPressure( );}
//! Get the current valid extinction computation class. //! Get the current valid extinction computation object.
const Extinction& getExtinction() const {return extinction;} const Extinction& getExtinction() const {return extinction;}
//! Get the current valid fefraction computation class. //! Get the current valid refraction computation object.
const Refraction& getRefraction() const {return refraction;} const Refraction& getRefraction() const {return refraction;}
//! Get the radius of the big halo texture used when a 3d model is v ery bright. //! Get the radius of the big halo texture used when a 3d model is v ery bright.
float getBig3dModelHaloRadius() const {return big3dModelHaloRadius;} float getBig3dModelHaloRadius() const {return big3dModelHaloRadius;}
//! Set the radius of the big halo texture used when a 3d model is v ery bright. //! Set the radius of the big halo texture used when a 3d model is v ery bright.
void setBig3dModelHaloRadius(float r) {big3dModelHaloRadius=r;} void setBig3dModelHaloRadius(float r) {big3dModelHaloRadius=r;}
private: private:
// Debug // Debug
float reverseComputeRCMag(float rmag) const; float reverseComputeRCMag(float rmag) const;
skipping to change at line 310 skipping to change at line 275
//! 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 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;
//! Controls the application of the user-defined star magnitude limi t. //! Controls the application of the user-defined star magnitude limi t.
//! @see customStarMagnitudeLimit //! @see customStarMagnitudeLimit
bool flagStarMagnitudeLimit; bool flagStarMagnitudeLimit;
skipping to change at line 358 skipping to change at line 319
//! Used if flagStarMagnitudeLimit is true. //! Used if flagStarMagnitudeLimit is true.
float customStarMagLimit; float customStarMagLimit;
//! User-defined magnitude limit for deep-sky objects. //! User-defined magnitude limit for deep-sky objects.
//! Interpreted as a lower limit - nebulae fainter than this value w ill not //! Interpreted as a lower limit - nebulae fainter than this value w ill not
//! be displayed. //! be displayed.
//! Used if flagNebulaMagnitudeLimit is true. //! Used if flagNebulaMagnitudeLimit is true.
//! @todo Why the asterisks this is not in NebulaMgr? --BM //! @todo Why the asterisks this is not in NebulaMgr? --BM
float customNebulaMagLimit; float customNebulaMagLimit;
//! Little halo texture //! Little halo texture
class StelTextureNew* 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 StelToneReproducer //! The scaling applied to input luminance before they are converted by the StelToneReproducer
float inScale; float inScale;
//! 2D vertex with position and color. // Variables used for GL optimization when displaying point sources
struct ColoredVertex //! Vertex format for a point source.
{ //! Texture pos is stored in another separately.
Vec2f position; struct StarVertex {
Vec3f color; Vec2f pos;
ColoredVertex(Vec2f position, Vec3f color):position(position unsigned char color[4];
), color(color){}
VERTEX_ATTRIBUTES(Vec2f Position, Vec3f Color);
}; };
//! 2D vertex with position, color and texture coordinate. //! Buffer for storing the vertex array data
struct ColoredTexturedVertex StarVertex* vertexArray;
{
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. //! Buffer for storing the texture coordinate array data.
StelVertexBuffer<ColoredVertex>* starPointBuffer; unsigned char* textureCoordArray;
//! Star sprite triangles. class QOpenGLShaderProgram* starShaderProgram;
StelVertexBuffer<ColoredTexturedVertex>* starSpriteBuffer; struct StarShaderVars {
int projectionMatrix;
//! Big halo triangles. int texCoord;
StelVertexBuffer<ColoredTexturedVertex>* bigHaloBuffer; int pos;
int color;
//! Sun halo triangles. int texture;
StelVertexBuffer<ColoredTexturedVertex>* sunHaloBuffer; };
StarShaderVars starShaderVars;
//! Sun corona triangles.
StelVertexBuffer<ColoredTexturedVertex>* coronaBuffer;
//! Are we drawing point sources at the moment? //! Current number of sources stored in the buffers (still to displa
bool drawing; y)
unsigned int nbPointSources;
//! Maximum number of sources which can be stored in the buffers
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
class StelTextureNew* texBigHalo; StelTextureSP texBigHalo;
class StelTextureNew* texSunHalo; StelTextureSP texSunHalo;
class StelTextureNew* texCorona;
bool flagLuminanceAdaptation; bool flagLuminanceAdaptation;
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. 28 change blocks. 
142 lines changed or deleted 68 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/