StelProjector.hpp   StelProjector.hpp 
skipping to change at line 129 skipping to change at line 129
//! Get the vertical viewport offset in pixels. //! Get the vertical viewport offset in pixels.
int getViewportPosY(void) const {return viewportXywh[1];} int getViewportPosY(void) const {return viewportXywh[1];}
//! Get the viewport width in pixels. //! Get the viewport width in pixels.
int getViewportWidth(void) const {return viewportXywh[2];} int getViewportWidth(void) const {return viewportXywh[2];}
//! Get the viewport height in pixels. //! Get the viewport height in pixels.
int getViewportHeight(void) const {return viewportXywh[3];} int getViewportHeight(void) const {return viewportXywh[3];}
//! Return a convex polygon on the sphere which includes the viewpor t in the current frame. //! Return a convex polygon on the sphere which includes the viewpor t in the current frame.
//! @param marginX an extra margin in pixel which extends the polygo n size in the X direction. //! @param marginX an extra margin in pixel which extends the polygo n size in the X direction.
//! @param marginY an extra margin in pixel which extends the polygo n size in the Y direction. //! @param marginY an extra margin in pixel which extends the polygo n size in the Y direction.
//! @return a ConvexPolygon or the special fullSky ConvexPolygon if the viewport cannot be //! @return a SphericalConvexPolygon or the special fullSky region i f the viewport cannot be
//! represented by a convex polygon (e.g. if aperture > 180 deg). //! represented by a convex polygon (e.g. if aperture > 180 deg).
StelGeom::ConvexPolygon getViewportConvexPolygon(double marginX=0., double marginY=0.) const; SphericalRegionP getViewportConvexPolygon(double marginX=0., double marginY=0.) const;
//! Return a Halfspace containing the whole viewport //! Return a Halfspace containing the whole viewport
StelGeom::HalfSpace getBoundingHalfSpace() const; SphericalCap getBoundingSphericalCap() const;
//! Get size of a radian in pixels at the center of the viewport dis k //! Get size of a radian in pixels at the center of the viewport dis k
double getPixelPerRadAtCenter(void) const {return pixelPerRad;} double getPixelPerRadAtCenter(void) const {return pixelPerRad;}
//! Get the current FOV diameter in degree //! Get the current FOV diameter in degree
double getFov() const {return 360./M_PI*viewScalingFactorToFov(0.5*v iewportFovDiameter/pixelPerRad);} double getFov() const {return 360./M_PI*viewScalingFactorToFov(0.5*v iewportFovDiameter/pixelPerRad);}
//! Get whether front faces need to be oriented in the clockwise dir ection //! Get whether front faces need to be oriented in the clockwise dir ection
bool needGlFrontFaceCW(void) const {return (flipHorz*flipVert < 0.0) ;} bool needGlFrontFaceCW(void) const {return (flipHorz*flipVert < 0.0) ;}
skipping to change at line 177 skipping to change at line 177
else else
v1=v; v1=v;
} }
return v; return v;
} }
//! Project the vector v from the current frame into the viewport. //! Project the vector v from the current frame into the viewport.
//! @param v the vector in the current frame. //! @param v the vector in the current frame.
//! @param win the projected vector in the viewport 2D frame. //! @param win the projected vector in the viewport 2D frame.
//! @return true if the projected coordinate is valid. //! @return true if the projected coordinate is valid.
bool project(const Vec3d& v, Vec3d& win) const inline bool project(const Vec3d& v, Vec3d& win) const
{ {
// really important speedup: win = v;
win[0] = modelViewMatrix.r[0]*v[0] + modelViewMatrix.r[4]*v[ return projectInPlace(win);
1] }
+ modelViewMatrix.r[8]*v[2] + modelViewMatri
x.r[12]; virtual void project(int n, const Vec3d* in, Vec3f* out)
win[1] = modelViewMatrix.r[1]*v[0] + modelViewMatrix.r[5]*v[ {
1] Vec3d v;
+ modelViewMatrix.r[9]*v[2] + modelViewMatri for (int i = 0; i < n; ++i)
x.r[13]; {
win[2] = modelViewMatrix.r[2]*v[0] + modelViewMatrix.r[6]*v[ v = in[i];
1] v.transfo4d(modelViewMatrix);
+ modelViewMatrix.r[10]*v[2] + modelViewMatr forward(v);
ix.r[14]; out[i][0] = viewportCenter[0] + flipHorz * pixelPerR
const bool rval = forward(win); ad * v[0];
out[i][1] = viewportCenter[1] + flipVert * pixelPerR
ad * v[1];
out[i][2] = (v[2] - zNear) * oneOverZNearMinusZFar;
}
}
//! Project the vector v from the current frame into the viewport.
//! @param v the vector in the current frame.
//! @return true if the projected coordinate is valid.
inline bool projectInPlace(Vec3d& v) const
{
v.transfo4d(modelViewMatrix);
const bool rval = forward(v);
// very important: even when the projected point comes from an // very important: even when the projected point comes from an
// invisible region of the sky (rval=false), we must finish // invisible region of the sky (rval=false), we must finish
// reprojecting, so that OpenGl can successfully eliminate // reprojecting, so that OpenGl can successfully eliminate
// polygons by culling. // polygons by culling.
win[0] = viewportCenter[0] + flipHorz * pixelPerRad * win[0] v[0] = viewportCenter[0] + flipHorz * pixelPerRad * v[0];
; v[1] = viewportCenter[1] + flipVert * pixelPerRad * v[1];
win[1] = viewportCenter[1] + flipVert * pixelPerRad * win[1] v[2] = (v[2] - zNear) * oneOverZNearMinusZFar;
;
win[2] = (win[2] - zNear) * oneOverZNearMinusZFar;
return rval; return rval;
} }
//! Project the vector v from the current frame into the viewport. //! Project the vector v from the current frame into the viewport.
//! @param v the vector in the current frame. //! @param v the direction vector in the current frame. Does not nee
//! @param win the projected vector in the viewport 2D frame. d to be normalized.
//! @param win the projected vector in the viewport 2D frame. win[0]
and win[1] are in screen pixels, win[2] is unused.
//! @return true if the projected point is inside the viewport. //! @return true if the projected point is inside the viewport.
bool projectCheck(const Vec3d& v, Vec3d& win) const {return (project (v, win) && checkInViewport(win));} bool projectCheck(const Vec3d& v, Vec3d& win) const {return (project (v, win) && checkInViewport(win));}
//! Project the vector v from the viewport frame into the current fr ame. //! Project the vector v from the viewport frame into the current fr ame.
//! @param win the vector in the viewport 2D frame. //! @param win the vector in the viewport 2D frame. win[0] and win[1
//! @param v the projected vector in the current frame. ] are in screen pixels, win[2] is unused.
//! @param v the unprojected direction vector in the current frame.
//! @return true if the projected coordinate is valid. //! @return true if the projected coordinate is valid.
bool unProject(const Vec3d& win, Vec3d& v) const {return unProject(w in[0], win[1], v);} bool unProject(const Vec3d& win, Vec3d& v) const {return unProject(w in[0], win[1], v);}
bool unProject(double x, double y, Vec3d& v) const; bool unProject(double x, double y, Vec3d& v) const;
//! Project the vectors v1 and v2 from the current frame into the vi ewport. //! Project the vectors v1 and v2 from the current frame into the vi ewport.
//! @param v1 the first vector in the current frame. //! @param v1 the first vector in the current frame.
//! @param v2 the second vector in the current frame. //! @param v2 the second vector in the current frame.
//! @param win1 the first projected vector in the viewport 2D frame. //! @param win1 the first projected vector in the viewport 2D frame.
//! @param win2 the second projected vector in the viewport 2D frame . //! @param win2 the second projected vector in the viewport 2D frame .
//! @return true if at least one of the projected vector is within t he viewport. //! @return true if at least one of the projected vector is within t he viewport.
bool projectLineCheck(const Vec3d& v1, Vec3d& win1, const Vec3d& v2, Vec3d& win2) const bool projectLineCheck(const Vec3d& v1, Vec3d& win1, const Vec3d& v2, Vec3d& win2) const
{return project(v1, win1) && project(v2, win2) && (checkInVi ewport(win1) || checkInViewport(win2));} {return project(v1, win1) && project(v2, win2) && (checkInVi ewport(win1) || checkInViewport(win2));}
//! Get the current model view matrix. //! Get the current model view matrix.
const Mat4d& getModelViewMatrix() const {return modelViewMatrix;} const Mat4d& getModelViewMatrix() const {return modelViewMatrix;}
//! Get the current projection matrix.
Mat4f getProjectionMatrix() const {return Mat4f(2./viewportXywh[2],
0, 0, 0, 0, 2./viewportXywh[3], 0, 0, 0, 0, -1., 0., -(2.f*viewportXywh[0]
+ viewportXywh[2])/viewportXywh[2], -(2.f*viewportXywh[1] + viewportXywh[3]
)/viewportXywh[3], 0, 1);}
//////////////////////////////////////////////////////////////////// /////// //////////////////////////////////////////////////////////////////// ///////
//! Get a string description of a StelProjectorMaskType. //! Get a string description of a StelProjectorMaskType.
static const QString maskTypeToString(StelProjectorMaskType type); static const QString maskTypeToString(StelProjectorMaskType type);
//! Get a StelProjectorMaskType from a string description. //! Get a StelProjectorMaskType from a string description.
static StelProjectorMaskType stringToMaskType(const QString &s); static StelProjectorMaskType stringToMaskType(const QString &s);
//! Get the current type of the mask if any. //! Get the current type of the mask if any.
StelProjectorMaskType getMaskType(void) const {return maskType;} StelProjectorMaskType getMaskType(void) const {return maskType;}
protected: protected:
//! Private constructor. Only StelCore can create instances of StelP rojector. //! Private constructor. Only StelCore can create instances of StelP rojector.
StelProjector(const Mat4d& modelViewMat) : modelViewMatrix(modelView Mat) {;} StelProjector(const Mat4d& modelViewMat) : modelViewMatrix(modelView Mat) {;}
//! Return whether the projection presents discontinuities. Used for optimization. //! Return whether the projection presents discontinuities. Used for optimization.
virtual bool hasDiscontinuity() const =0; virtual bool hasDiscontinuity() const =0;
//! Determine whether a great circle connection p1 and p2 intersects with a projection discontinuity. //! Determine whether a great circle connection p1 and p2 intersects with a projection discontinuity.
//! For many projections without discontinuity, this should return a lways false, but for other like //! For many projections without discontinuity, this should return a lways false, but for other like
//! cylindrical projection it will return true if the line cuts the wrap-around line (i.e. at lon=180 if the observer look at lon=0). //! cylindrical projection it will return true if the line cuts the wrap-around line (i.e. at lon=180 if the observer look at lon=0).
virtual bool intersectViewportDiscontinuityInternal(const Vec3d& p1, const Vec3d& p2) const = 0; virtual bool intersectViewportDiscontinuityInternal(const Vec3d& p1, const Vec3d& p2) const = 0;
private:
//! Initialise the StelProjector from a param instance
void init(const StelProjectorParams& param);
Mat4d modelViewMatrix; // openGL MODELVIEW Matrix
double flipHorz,flipVert; // Whether to flip in horizontal or v
ertical directions
double pixelPerRad; // pixel per rad at the center of the
viewport disk
StelProjectorMaskType maskType; // The current projector mask StelProjectorMaskType maskType; // The current projector mask
double zNear, oneOverZNearMinusZFar; // Near and far clipping plane s double zNear, oneOverZNearMinusZFar; // Near and far clipping plane s
Vec4i viewportXywh; // Viewport parameters Vec4i viewportXywh; // Viewport parameters
Vec2d viewportCenter; // Viewport center in screen pixel Vec2d viewportCenter; // Viewport center in screen pixel
double viewportFovDiameter; // diameter of the FOV disk in pixel double viewportFovDiameter; // diameter of the FOV disk in pixel
double pixelPerRad; // pixel per rad at the center of the
viewport disk
double flipHorz,flipVert; // Whether to flip in horizontal or v
ertical directions
bool gravityLabels; // should label text align with the h orizon? bool gravityLabels; // should label text align with the h orizon?
Mat4d modelViewMatrix; // openGL MODELVIEW Matrix
private:
//! Initialise the StelProjector from a param instance
void init(const StelProjectorParams& param);
}; };
#endif // _STELPROJECTOR_HPP_ #endif // _STELPROJECTOR_HPP_
 End of changes. 13 change blocks. 
35 lines changed or deleted 56 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/