StelViewportEffect.cpp   StelViewportEffect.cpp 
skipping to change at line 54 skipping to change at line 54
{ {
Vec2f ver_xy; Vec2f ver_xy;
Vec4f color; Vec4f color;
double h; double h;
}; };
StelViewportDistorterFisheyeToSphericMirror::StelViewportDistorterFisheyeTo SphericMirror(int screen_w,int screen_h) StelViewportDistorterFisheyeToSphericMirror::StelViewportDistorterFisheyeTo SphericMirror(int screen_w,int screen_h)
: screen_w(screen_w) : screen_w(screen_w)
, screen_h(screen_h) , screen_h(screen_h)
, originalProjectorParams(StelApp::getInstance().getCore()->getCurre ntStelProjectorParams()) , originalProjectorParams(StelApp::getInstance().getCore()->getCurre ntStelProjectorParams())
, texture_wh(1)
, 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_ fov",175.f).toFloat(); double distorter_max_fov = conf.value("spheric_mirror/distorter_max_ fov",175.f).toFloat();
if (distorter_max_fov > 240.f) if (distorter_max_fov > 240.f)
skipping to change at line 103 skipping to change at line 102
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 ewportCenterX", 0.5*newProjectorParams.viewportXywh[2]).toFloat(); newProjectorParams.viewportCenter[0] = conf.value("spheric_mirror/vi ewportCenterX", 0.5*newProjectorParams.viewportXywh[2]).toFloat();
newProjectorParams.viewportCenter[1] = conf.value("spheric_mirror/vi ewportCenterY", 0.5*newProjectorParams.viewportXywh[3]).toFloat(); newProjectorParams.viewportCenter[1] = conf.value("spheric_mirror/vi 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])).toFloat(); newProjectorParams.viewportFovDiameter = conf.value("spheric_mirror/ viewport_fov_diameter", qMin(newProjectorParams.viewportXywh[2],newProjecto rParams.viewportXywh[3])).toFloat();
// Vestigial mirror texture dimensions: used to be a single value, viewport_texture_offset[0] = (screen_w-newProjectorParams.viewportXy
while (texture_wh < newProjectorParams.viewportXywh[2] || texture_wh wh[2])>>1;
< newProjectorParams.viewportXywh[3]) viewport_texture_offset[1] = (screen_h-newProjectorParams.viewportXy
texture_wh <<= 1; wh[3])>>1;
viewport_texture_offset[0] = (texture_wh-newProjectorParams.viewport
Xywh[2])>>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())
skipping to change at line 167 skipping to change at line 163
// artefacts by specifying a viewport size a little less then // artefacts by specifying a viewport size a little less then
// (1<<n)*(1<<n), for instance 1022*1022. Wi th a viewport size // (1<<n)*(1<<n), for instance 1022*1022. Wi th a viewport size
// of 512*512 and viewportFovDiameter=512 yo u will get clamping // of 512*512 and viewportFovDiameter=512 yo u will get clamping
// artefacts in the 3 otherwise black hills on the bottom of the image. // artefacts in the 3 otherwise black hills on the bottom of the image.
// if (x < 0.f) {x=0.f;vertex_point.h=0 ;} // if (x < 0.f) {x=0.f;vertex_point.h=0 ;}
// else if (x > newProjectorParams.view portXywh[2]) {x=newProjectorParams.viewportXywh[2];vertex_point.h=0;} // else if (x > newProjectorParams.view portXywh[2]) {x=newProjectorParams.viewportXywh[2];vertex_point.h=0;}
// if (y < 0.f) {y=0.f;vertex_point.h=0 ;} // if (y < 0.f) {y=0.f;vertex_point.h=0 ;}
// else if (y > newProjectorParams.view portXywh[3]) {y=newProjectorParams.viewportXywh[3];vertex_point.h=0;} // else if (y > newProjectorParams.view portXywh[3]) {y=newProjectorParams.viewportXywh[3];vertex_point.h=0;}
texture_point[0] = (viewport_texture_offset[ texture_point[0] = (viewport_texture_offset[
0]+x)/texture_wh; 0]+x)/screen_w;
texture_point[1] = (viewport_texture_offset[ texture_point[1] = (viewport_texture_offset[
1]+y)/texture_wh; 1]+y)/screen_h;
if (vertex_point.h > max_h) max_h = vertex_p oint.h; if (vertex_point.h > max_h) max_h = vertex_p oint.h;
} }
} }
for (int j=0;j<=max_y;j++) for (int j=0;j<=max_y;j++)
// FIXME: Comment out with /**/ after testing. --BM // FIXME: Comment out with /**/ after testing. --BM
/*qDebug() << "StelViewportDistorterFisheyeToSphericMirror():" /*qDebug() << "StelViewportDistorterFisheyeToSphericMirror():"
<< "screen_w:" << this->screenWidth << "screen_w:" << this->screenWidth
<< "screen_h:" << this->screenHeight << endl << "screen_h:" << this->screenHeight << endl
skipping to change at line 211 skipping to change at line 207
<< newProjectorParams.viewportFovDiameter << endl << newProjectorParams.viewportFovDiameter << endl
<< "originalProjectorParams.zNear,zFar:" << "originalProjectorParams.zNear,zFar:"
<< originalProjectorParams.zNear << originalProjectorParams.zNear
<< originalProjectorParams.zFar << endl << originalProjectorParams.zFar << endl
<< "newProjectorParams.zNear,zFar:" << "newProjectorParams.zNear,zFar:"
<< newProjectorParams.zNear << newProjectorParams.zNear
<< newProjectorParams.zFar << endl << newProjectorParams.zFar << endl
//<< "viewport_texture_offset:" //<< "viewport_texture_offset:"
//<< viewport_texture_offset[0] //<< viewport_texture_offset[0]
//<< viewport_texture_offset[1] << endl //<< viewport_texture_offset[1] << endl
<< "texture_w:" << texture_w << endl
<< "texture_h:" << texture_h << endl << "texture_h:" << texture_h << endl
<< "max_x:" << maxGridX << endl << "max_x:" << maxGridX << endl
<< "max_y:" << maxGridY;*/ << "max_y:" << maxGridY;*/
{ {
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)]);
vertex_point.color[0] = vertex_point.color[1 ] = vertex_point.color[2] = vertex_point.color[0] = vertex_point.color[1 ] = vertex_point.color[2] =
(vertex_point.h<=0.0) ? 0.0 : exp(gamma*log(vertex_point.h/max_ h)); (vertex_point.h<=0.0) ? 0.0 : exp(gamma*log(vertex_point.h/max_ h));
vertex_point.color[3] = 1.0f; vertex_point.color[3] = 1.0f;
skipping to change at line 259 skipping to change at line 254
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;
float x,y; float x,y;
in >> x >> y >> vertex_point.color[0] >> ver tex_point.color[1] >> vertex_point.color[2]; in >> x >> y >> vertex_point.color[0] >> ver tex_point.color[1] >> vertex_point.color[2];
vertex_point.color[3] = 1.0f; vertex_point.color[3] = 1.0f;
Q_ASSERT(in.status()!=QTextStream::Ok); Q_ASSERT(in.status()!=QTextStream::Ok);
texture_point[0] = (viewport_texture_offset[ texture_point[0] = (viewport_texture_offset[
0]+x)/texture_wh; 0]+x)/screen_w;
texture_point[1] = (viewport_texture_offset[ texture_point[1] = (viewport_texture_offset[
1]+y)/texture_wh; 1]+y)/screen_h;
} }
} }
} }
// initialize the display list // initialize the display list
displayVertexList.clear(); displayVertexList.clear();
for (int j=0;j<max_y;j++) for (int j=0;j<max_y;j++)
{ {
const Vec2f *t0 = texture_point_array + j*(max_x+1); const Vec2f *t0 = texture_point_array + j*(max_x+1);
const Vec2f *t1 = t0; const Vec2f *t1 = t0;
skipping to change at line 369 skipping to change at line 364
if (i == 0) if (i == 0)
{ {
dx -= 0.5f*dy; dx -= 0.5f*dy;
dx *= 2.f; dx *= 2.f;
} }
texture_x = t[max_x+1][0] + (1.f-dy) * (t[0][0]-t[ma x_x+1][0]) + dx * (t[max_x+2][0]-t[max_x+1][0]); texture_x = t[max_x+1][0] + (1.f-dy) * (t[0][0]-t[ma x_x+1][0]) + dx * (t[max_x+2][0]-t[max_x+1][0]);
texture_y = t[max_x+1][1] + (1.f-dy) * (t[0][1]-t[ma x_x+1][1]) + dx * (t[max_x+2][1]-t[max_x+1][1]); texture_y = t[max_x+1][1] + (1.f-dy) * (t[0][1]-t[ma x_x+1][1]) + dx * (t[max_x+2][1]-t[max_x+1][1]);
} }
} }
x = texture_wh*texture_x - viewport_texture_offset[0] + newProjector x = screen_w*texture_x - viewport_texture_offset[0] + newProjectorPa
Params.viewportXywh[0]; rams.viewportXywh[0];
y = texture_wh*texture_y - viewport_texture_offset[1] + newProjector y = screen_h*texture_y - viewport_texture_offset[1] + newProjectorPa
Params.viewportXywh[1]; rams.viewportXywh[1];
} }
void StelViewportDistorterFisheyeToSphericMirror::paintViewportBuffer(const QOpenGLFramebufferObject* buf) const void StelViewportDistorterFisheyeToSphericMirror::paintViewportBuffer(const QOpenGLFramebufferObject* buf) const
{ {
StelPainter sPainter(StelApp::getInstance().getCore()->getProjection 2d()); StelPainter sPainter(StelApp::getInstance().getCore()->getProjection 2d());
sPainter.enableTexture2d(true); sPainter.enableTexture2d(true);
glBindTexture(GL_TEXTURE_2D, buf->texture()); glBindTexture(GL_TEXTURE_2D, buf->texture());
glDisable(GL_BLEND); glDisable(GL_BLEND);
sPainter.enableClientStates(true, true, true); sPainter.enableClientStates(true, true, true);
sPainter.setColorPointer(4, GL_FLOAT, displayColorList.constData()); sPainter.setColorPointer(4, GL_FLOAT, displayColorList.constData());
sPainter.setVertexPointer(2, GL_FLOAT, displayVertexList.constData() ); sPainter.setVertexPointer(2, GL_FLOAT, displayVertexList.constData() );
sPainter.setTexCoordPointer(2, GL_FLOAT, displayTexCoordList.constDa ta()); sPainter.setTexCoordPointer(2, GL_FLOAT, displayTexCoordList.constDa ta());
for (int j=0;j<max_y;j++) for (int j=0;j<max_y;j++)
{ {
glDrawArrays(GL_TRIANGLE_STRIP, j*(max_x+1)*2, (max_x+1)*2);
sPainter.drawFromArray(StelPainter::TriangleStrip, (max_x+1) *2, j*(max_x+1)*2, false); sPainter.drawFromArray(StelPainter::TriangleStrip, (max_x+1) *2, j*(max_x+1)*2, false);
} }
sPainter.enableClientStates(false); sPainter.enableClientStates(false);
} }
 End of changes. 7 change blocks. 
22 lines changed or deleted 17 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/