StelViewportEffect.cpp   StelViewportEffect.cpp 
skipping to change at line 30 skipping to change at line 30
#include "StelViewportEffect.hpp" #include "StelViewportEffect.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelPainter.hpp" #include "StelPainter.hpp"
#include "SphericMirrorCalculator.hpp" #include "SphericMirrorCalculator.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelMovementMgr.hpp" #include "StelMovementMgr.hpp"
#include <QGLFramebufferObject> #include <QGLFramebufferObject>
#include <QSettings> #include <QSettings>
#include <QFile>
void StelViewportEffect::paintViewportBuffer(const QGLFramebufferObject* bu f) const void StelViewportEffect::paintViewportBuffer(const QGLFramebufferObject* bu f) const
{ {
StelPainter sPainter(StelApp::getInstance().getCore()->getProjection 2d()); StelPainter sPainter(StelApp::getInstance().getCore()->getProjection 2d());
sPainter.setColor(1,1,1); sPainter.setColor(1,1,1);
sPainter.enableTexture2d(true); sPainter.enableTexture2d(true);
glBindTexture(GL_TEXTURE_2D, buf->texture()); glBindTexture(GL_TEXTURE_2D, buf->texture());
sPainter.drawRect2d(0, 0, buf->size().width(), buf->size().height()) ; sPainter.drawRect2d(0, 0, buf->size().width(), buf->size().height()) ;
} }
skipping to change at line 58 skipping to change at line 59
screen_w(screen_w), screen_h(screen_h), screen_w(screen_w), screen_h(screen_h),
originalProjectorParams(StelApp::getInstance().getCore()->ge tCurrentStelProjectorParams()), originalProjectorParams(StelApp::getInstance().getCore()->ge tCurrentStelProjectorParams()),
texture_point_array(NULL) texture_point_array(NULL)
{ {
QSettings& conf = *StelApp::getInstance().getSettings(); QSettings& conf = *StelApp::getInstance().getSettings();
StelCore* core = StelApp::getInstance().getCore(); StelCore* core = StelApp::getInstance().getCore();
// initialize viewport parameters and texture size: // initialize viewport parameters and texture size:
// maximum FOV value of the not yet distorted image // maximum FOV value of the not yet distorted image
double distorter_max_fov = conf.value("spheric_mirror/distorter_max_ double distorter_max_fov = conf.value("spheric_mirror/distorter_max_
fov",175.0).toDouble(); fov",175.f).toFloat();
if (distorter_max_fov > 240.0) if (distorter_max_fov > 240.f)
distorter_max_fov = 240.0; distorter_max_fov = 240.f;
else if (distorter_max_fov < 120.0) else if (distorter_max_fov < 120.f)
distorter_max_fov = 120.0; distorter_max_fov = 120.f;
if (distorter_max_fov > core->getMovementMgr()->getMaxFov()) if (distorter_max_fov > core->getMovementMgr()->getMaxFov())
distorter_max_fov = core->getMovementMgr()->getMaxFov(); distorter_max_fov = core->getMovementMgr()->getMaxFov();
StelProjectorP prj = core->getProjection(StelCore::FrameJ2000); StelProjectorP prj = core->getProjection(StelCore::FrameJ2000);
core->getMovementMgr()->setMaxFov(distorter_max_fov); core->getMovementMgr()->setMaxFov(distorter_max_fov);
// width of the not yet distorted image // width of the not yet distorted image
newProjectorParams.viewportXywh[2] = conf.value("spheric_mirror/newP rojectorParams.viewportXywh[2]idth", originalProjectorParams.viewportXywh[2 ]).toInt(); newProjectorParams.viewportXywh[2] = conf.value("spheric_mirror/newP rojectorParams.viewportXywh[2]idth", originalProjectorParams.viewportXywh[2 ]).toInt();
if (newProjectorParams.viewportXywh[2] <= 0) if (newProjectorParams.viewportXywh[2] <= 0)
{ {
skipping to change at line 92 skipping to change at line 93
if (newProjectorParams.viewportXywh[3] <= 0) if (newProjectorParams.viewportXywh[3] <= 0)
{ {
newProjectorParams.viewportXywh[3] = originalProjectorParams .viewportXywh[3]; newProjectorParams.viewportXywh[3] = originalProjectorParams .viewportXywh[3];
} }
else if (newProjectorParams.viewportXywh[3] > screen_h) else if (newProjectorParams.viewportXywh[3] > screen_h)
{ {
newProjectorParams.viewportXywh[3] = screen_h; newProjectorParams.viewportXywh[3] = screen_h;
} }
// center of the FOV-disk in the not yet distorted image // center of the FOV-disk in the not yet distorted image
newProjectorParams.viewportCenter[0] = conf.value("spheric_mirror/vi newProjectorParams.viewportCenter[0] = conf.value("spheric_mirror/vi
ewportCenterX", 0.5*newProjectorParams.viewportXywh[2]).toDouble(); ewportCenterX", 0.5*newProjectorParams.viewportXywh[2]).toFloat();
newProjectorParams.viewportCenter[1] = conf.value("spheric_mirror/vi newProjectorParams.viewportCenter[1] = conf.value("spheric_mirror/vi
ewportCenterY", 0.5*newProjectorParams.viewportXywh[3]).toDouble(); ewportCenterY", 0.5*newProjectorParams.viewportXywh[3]).toFloat();
// diameter of the FOV-disk in pixels // diameter of the FOV-disk in pixels
newProjectorParams.viewportFovDiameter = conf.value("spheric_mirror/ viewport_fov_diameter", qMin(newProjectorParams.viewportXywh[2],newProjecto rParams.viewportXywh[3])).toDouble(); newProjectorParams.viewportFovDiameter = conf.value("spheric_mirror/ viewport_fov_diameter", qMin(newProjectorParams.viewportXywh[2],newProjecto rParams.viewportXywh[3])).toFloat();
texture_wh = 1; texture_wh = 1;
while (texture_wh < newProjectorParams.viewportXywh[2] || texture_wh < newProjectorParams.viewportXywh[3]) while (texture_wh < newProjectorParams.viewportXywh[2] || texture_wh < newProjectorParams.viewportXywh[3])
texture_wh <<= 1; texture_wh <<= 1;
viewport_texture_offset[0] = (texture_wh-newProjectorParams.viewport Xywh[2])>>1; viewport_texture_offset[0] = (texture_wh-newProjectorParams.viewport Xywh[2])>>1;
viewport_texture_offset[1] = (texture_wh-newProjectorParams.viewport Xywh[3])>>1; viewport_texture_offset[1] = (texture_wh-newProjectorParams.viewport Xywh[3])>>1;
newProjectorParams.viewportXywh[0] = (screen_w-newProjectorParams.vi ewportXywh[2]) >> 1; newProjectorParams.viewportXywh[0] = (screen_w-newProjectorParams.vi ewportXywh[2]) >> 1;
newProjectorParams.viewportXywh[1] = (screen_h-newProjectorParams.vi ewportXywh[3]) >> 1; newProjectorParams.viewportXywh[1] = (screen_h-newProjectorParams.vi ewportXywh[3]) >> 1;
StelApp::getInstance().getCore()->setCurrentStelProjectorParams(newP rojectorParams); StelApp::getInstance().getCore()->setCurrentStelProjectorParams(newP rojectorParams);
// init transformation // init transformation
VertexPoint *vertex_point_array = 0; VertexPoint *vertex_point_array = 0;
const QString custom_distortion_file = conf.value("spheric_mirror/cu stom_distortion_file","").toString(); const QString custom_distortion_file = conf.value("spheric_mirror/cu stom_distortion_file","").toString();
if (custom_distortion_file.isEmpty()) if (custom_distortion_file.isEmpty())
{ {
double texture_triangle_base_length = conf.value("spheric_mi float texture_triangle_base_length = conf.value("spheric_mir
rror/texture_triangle_base_length",16.0).toDouble(); ror/texture_triangle_base_length",16.f).toFloat();
if (texture_triangle_base_length > 256.0) if (texture_triangle_base_length > 256.f)
texture_triangle_base_length = 256.0; texture_triangle_base_length = 256.f;
else if (texture_triangle_base_length < 2.0) else if (texture_triangle_base_length < 2.f)
texture_triangle_base_length = 2.0; texture_triangle_base_length = 2.f;
max_x = (int)trunc(0.5 + screen_w/texture_triangle_base_leng th); max_x = (int)trunc(0.5 + screen_w/texture_triangle_base_leng th);
step_x = screen_w / (double)(max_x-0.5); step_x = screen_w / (double)(max_x-0.5);
max_y = (int)trunc(screen_h/(texture_triangle_base_length*0. 5*sqrt(3.0))); max_y = (int)trunc(screen_h/(texture_triangle_base_length*0. 5*sqrt(3.0)));
step_y = screen_h/ (double)max_y; step_y = screen_h/ (double)max_y;
double gamma = conf.value("spheric_mirror/projector_gamma",0 .45).toDouble(); double gamma = conf.value("spheric_mirror/projector_gamma",0 .45).toDouble();
if (gamma < 0.0) if (gamma < 0.0)
gamma = 0.0; gamma = 0.0;
const float view_scaling_factor = 0.5 * newProjectorParams.v iewportFovDiameter / prj->fovToViewScalingFactor(distorter_max_fov*(M_PI/36 0.0)); const float view_scaling_factor = 0.5 * newProjectorParams.v iewportFovDiameter / prj->fovToViewScalingFactor(distorter_max_fov*(M_PI/36 0.0));
skipping to change at line 141 skipping to change at line 142
double max_h = 0; double max_h = 0;
SphericMirrorCalculator calc(conf); SphericMirrorCalculator calc(conf);
for (int j=0;j<=max_y;j++) for (int j=0;j<=max_y;j++)
{ {
for (int i=0;i<=max_x;i++) for (int i=0;i<=max_x;i++)
{ {
VertexPoint &vertex_point(vertex_point_array [(j*(max_x+1)+i)]); VertexPoint &vertex_point(vertex_point_array [(j*(max_x+1)+i)]);
Vec2f &texture_point(texture_point_array[(j* (max_x+1)+i)]); Vec2f &texture_point(texture_point_array[(j* (max_x+1)+i)]);
vertex_point.ver_xy[0] = ((i == 0) ? 0.f : ( i == max_x) ? screen_w : (i-0.5f*(j&1))*step_x); vertex_point.ver_xy[0] = ((i == 0) ? 0.f : ( i == max_x) ? screen_w : (i-0.5f*(j&1))*step_x);
vertex_point.ver_xy[1] = j*step_y; vertex_point.ver_xy[1] = j*step_y;
Vec3d v,vX,vY; Vec3f v,vX,vY;
bool rc = calc.retransform( bool rc = calc.retransform(
(vertex_point.ver_ xy[0]-0.5f*screen_w) / screen_h, (vertex_point.ver_ xy[0]-0.5f*screen_w) / screen_h,
(vertex_point.ver_ xy[1]-0.5f*screen_h) / screen_h, v,vX,vY); (vertex_point.ver_ xy[1]-0.5f*screen_h) / screen_h, v,vX,vY);
rc &= prj->forward(v); rc &= prj->forward(v);
const float x = newProjectorParams.viewportC enter[0] + v[0] * view_scaling_factor; const float x = newProjectorParams.viewportC enter[0] + v[0] * view_scaling_factor;
const float y = newProjectorParams.viewportC enter[1] + v[1] * view_scaling_factor; const float y = newProjectorParams.viewportC enter[1] + v[1] * view_scaling_factor;
vertex_point.h = rc ? (vX^vY).length() : 0.0 ; vertex_point.h = rc ? (vX^vY).length() : 0.0 ;
// sharp image up to the border of the fishe ye image, at the cost of // sharp image up to the border of the fishe ye image, at the cost of
// accepting clamping artefacts. You can get rid of the clamping // accepting clamping artefacts. You can get rid of the clamping
 End of changes. 6 change blocks. 
18 lines changed or deleted 19 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/