StelViewportEffect.cpp   StelViewportEffect.cpp 
skipping to change at line 58 skipping to change at line 58
}; };
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_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();
StelProjector::StelProjectorParams params = core->getCurrentStelProj
ectorParams();
screen_h *= params.devicePixelsPerPixel;
screen_w *= params.devicePixelsPerPixel;
// 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)
distorter_max_fov = 240.f; distorter_max_fov = 240.f;
else if (distorter_max_fov < 120.f) else if (distorter_max_fov < 120.f)
distorter_max_fov = 120.f; 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();
skipping to change at line 108 skipping to change at line 110
// 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();
viewport_texture_offset[0] = (screen_w-newProjectorParams.viewportXy wh[2])>>1; viewport_texture_offset[0] = (screen_w-newProjectorParams.viewportXy wh[2])>>1;
viewport_texture_offset[1] = (screen_h-newProjectorParams.viewportXy wh[3])>>1; viewport_texture_offset[1] = (screen_h-newProjectorParams.viewportXy wh[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;
newProjectorParams.viewportXywh[2] *= originalProjectorParams.device
PixelsPerPixel;
newProjectorParams.viewportXywh[3] *= originalProjectorParams.device
PixelsPerPixel;
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()) {
{
float texture_triangle_base_length = conf.value("spheric_mir ror/texture_triangle_base_length",16.f).toFloat(); float texture_triangle_base_length = conf.value("spheric_mir ror/texture_triangle_base_length",16.f).toFloat();
if (texture_triangle_base_length > 256.f) if (texture_triangle_base_length > 256.f) {
texture_triangle_base_length = 256.f; texture_triangle_base_length = 256.f;
else if (texture_triangle_base_length < 2.f) } else if (texture_triangle_base_length < 2.f) {
texture_triangle_base_length = 2.f; texture_triangle_base_length = 2.f;
max_x = (int)StelUtils::trunc(0.5 + screen_w/texture_triangle_base_ }
length); max_x = (int)StelUtils::trunc(0.5 + screen_w/texture_triangl
e_base_length);
step_x = screen_w / (double)(max_x-0.5); step_x = screen_w / (double)(max_x-0.5);
max_y = (int)StelUtils::trunc(screen_h/(texture_triangle_base_lengt h*0.5*sqrt(3.0))); max_y = (int)StelUtils::trunc(screen_h/(texture_triangle_bas e_length*0.5*std::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));
texture_point_array = new Vec2f[(max_x+1)*(max_y+1)]; texture_point_array = new Vec2f[(max_x+1)*(max_y+1)];
vertex_point_array = new VertexPoint[(max_x+1)*(max_y+1)]; vertex_point_array = new VertexPoint[(max_x+1)*(max_y+1)];
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;
Vec3f 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;
skipping to change at line 169 skipping to change at line 172
// 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[ 0]+x)/screen_w; texture_point[0] = (viewport_texture_offset[ 0]+x)/screen_w;
texture_point[1] = (viewport_texture_offset[ 1]+y)/screen_h; texture_point[1] = (viewport_texture_offset[ 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++) {
for (int i=0;i<=max_x;i++) {
// FIXME: Comment out with /**/ after testing. --BM
/*qDebug() << "StelViewportDistorterFisheyeToSphericMirror():"
<< "screen_w:" << this->screenWidth
<< "screen_h:" << this->screenHeight << endl
<< "originalProjectorParams.viewportXywh:"
<< originalProjectorParams.viewportXywh[0]
<< originalProjectorParams.viewportXywh[1]
<< originalProjectorParams.viewportXywh[2]
<< originalProjectorParams.viewportXywh[3] << endl
<< "newProjectorParams.viewportXywh:"
<< newProjectorParams.viewportXywh[0]
<< newProjectorParams.viewportXywh[1]
<< newProjectorParams.viewportXywh[2]
<< newProjectorParams.viewportXywh[3] << endl
<< "originalProjectorParams.fov:"
<< originalProjectorParams.fov << endl
<< "newProjectorParams.fov:" << newProjectorParams.fov << e
ndl
<< "originalProjectorParams.viewportCenter:"
<< originalProjectorParams.viewportCenter[0]
<< originalProjectorParams.viewportCenter[1] << endl
<< "newProjectorParams.viewportCenter:"
<< newProjectorParams.viewportCenter[0]
<< newProjectorParams.viewportCenter[1] << endl
<< "originalProjectorParams.viewportFovDiameter:"
<< originalProjectorParams.viewportFovDiameter << endl
<< "newProjectorParams.viewportFovDiameter:"
<< newProjectorParams.viewportFovDiameter << endl
<< "originalProjectorParams.zNear,zFar:"
<< originalProjectorParams.zNear
<< originalProjectorParams.zFar << endl
<< "newProjectorParams.zNear,zFar:"
<< newProjectorParams.zNear
<< newProjectorParams.zFar << endl
//<< "viewport_texture_offset:"
//<< viewport_texture_offset[0]
//<< viewport_texture_offset[1] << endl
<< "texture_h:" << texture_h << endl
<< "max_x:" << maxGridX << endl
<< "max_y:" << maxGridY;*/
{
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;
} }
} }
} } else {
else
{
QFile file; QFile file;
QTextStream in; QTextStream in;
QString fName = StelFileMgr::findFile(custom_distortion_file ); QString fName = StelFileMgr::findFile(custom_distortion_file );
if (fName.isEmpty()) if (fName.isEmpty()) {
qWarning() << "WARNING: could not open custom_distor tion_file:" << custom_distortion_file; qWarning() << "WARNING: could not open custom_distor tion_file:" << custom_distortion_file;
else } else {
{
file.setFileName(fName); file.setFileName(fName);
if(file.open(QIODevice::ReadOnly)) if(file.open(QIODevice::ReadOnly))
in.setDevice(&file); in.setDevice(&file);
else else
qWarning() << "WARNING: could not open custo m_distortion_file:" << custom_distortion_file; qWarning() << "WARNING: could not open custo m_distortion_file:" << custom_distortion_file;
} }
Q_ASSERT(file.error()!=QFile::NoError); Q_ASSERT(file.error()!=QFile::NoError);
in >> max_x >> max_y; in >> max_x >> max_y;
Q_ASSERT(in.status()==QTextStream::Ok && max_x>0 && max_y>0) ; Q_ASSERT(in.status()==QTextStream::Ok && max_x>0 && max_y>0) ;
step_x = screen_w / (double)(max_x-0.5); step_x = screen_w / (double)(max_x-0.5);
 End of changes. 14 change blocks. 
64 lines changed or deleted 24 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/