Index: stel_ui.cpp =================================================================== --- stel_ui.cpp (revision 2064) +++ stel_ui.cpp (working copy) @@ -42,6 +42,7 @@ #include "StelFontMgr.hpp" #include "StelLocaleMgr.hpp" #include "Navigator.hpp" +#include "Nebula.hpp" //////////////////////////////////////////////////////////////////////////////// // CLASS FUNCTIONS @@ -216,6 +217,8 @@ initialised = true; setTitleObservatoryName(getTitleWithAltitude()); + + nebEditFactor = 3.0; } void StelUI::resize() @@ -863,7 +866,74 @@ const StelObjectMgr& objmgr = StelApp::getInstance().getStelObjectMgr(); if (state==Stel_KEYDOWN) { -//printf("handle_keys: '%c'(%d), %d, 0x%04x\n",key,(int)key,unicode,mod); + //printf("handle_keys: '%c'(%d), %d, 0x%04x\n",key,(int)key,unicode,mod); + + // MNG Nebula editor test + // resize nebula + if (key == StelKey_F3 + || key == StelKey_F4 + || key == StelKey_F5 + || key == StelKey_F6 + || key == StelKey_F7 + || key == StelKey_F8 + || key == StelKey_F9 + || key == StelKey_F10 + || key == StelKey_F11 + || key == StelKey_F12) + + { + StelObjectMgr& omgr = StelApp::getInstance().getStelObjectMgr(); + const std::vector selOb = omgr.getSelectedObject("Nebula"); + if (!selOb.empty()) + { + Nebula* ob = static_cast(selOb[0].get()); + cout << "NEBEDIT of : " << ob->getEnglishName() << endl; + if (key == StelKey_F5) + { + ob->resize(1.0 - (0.01*nebEditFactor)); + } + else if (key == StelKey_F6) + { + ob->resize(1.0 + (0.01*nebEditFactor)); + } + else if (key == StelKey_F7) + { + ob->rotate(0.3*nebEditFactor); + } + else if (key == StelKey_F8) + { + ob->rotate(-0.3*nebEditFactor); + } + else if (key == StelKey_F9) + { + ob->shiftRA(0.001*nebEditFactor); + } + else if (key == StelKey_F10) + { + ob->shiftRA(-0.001*nebEditFactor); + } + else if (key == StelKey_F11) + { + ob->shiftDec(-0.001*nebEditFactor); + } + else if (key == StelKey_F12) + { + ob->shiftDec(0.001*nebEditFactor); + } + else if (key == StelKey_F3) + { + nebEditFactor *= 0.8; + cout << "nebula editor sensitivity factor is now: " << nebEditFactor << endl; + } + else if (key == StelKey_F4) + { + nebEditFactor *= 1.2; + cout << "nebula editor sensitivity factor is now: " << nebEditFactor << endl; + } + cout << endl; + } + } + if (unicode >= 128) { // the user has entered an arkane symbol which cannot // be a key shortcut. Index: Nebula.cpp =================================================================== --- Nebula.cpp (revision 2064) +++ Nebula.cpp (working copy) @@ -210,11 +210,14 @@ StelApp::getInstance().getTextureManager().setDefaultParams(); StelApp::getInstance().getTextureManager().setMipmapsMode(true); neb_tex = StelApp::getInstance().getTextureManager().createTexture("nebulae/"+setName+"/"+tex_name, true); - + texture_filename = tex_name; + luminance = ToneReproducer::mag_to_luminance(mag, tex_angular_size*tex_angular_size*3600); float tex_size = RADIUS_NEB * sin(tex_angular_size/2/60*M_PI/180); + + texture_rotation = tex_rotation; // Precomputation of the rotation/translation matrix Mat4f mat_precomp = Mat4f::translation(XYZ) * @@ -411,3 +414,191 @@ return wsType; } +void Nebula::resize(float factor) +{ + std::cout << "resizing nebula by a factor of " << factor << std::endl; + + float tex_angular_size, tex_size; + double ra_rad, de_rad; + + StelUtils::rect_to_sphe(&ra_rad, &de_rad, XYZ); + + // need to do the inverse of this: angular_size = tex_angular_size/2/60*M_PI/180; + tex_angular_size = angular_size*180*60/M_PI*2; + + // do the resizing and record it back to the angular_size private member + tex_angular_size *= factor; + angular_size = tex_angular_size/2/60*M_PI/180; + + tex_size = RADIUS_NEB * sin(tex_angular_size/2/60*M_PI/180); + + // now to manipulate the actual texture + // Precomputation of the rotation/translation matrix + Mat4f mat_precomp = Mat4f::translation(XYZ) * + Mat4f::zrotation(ra_rad) * + Mat4f::yrotation(-de_rad) * + Mat4f::xrotation(texture_rotation*M_PI/180.); + + // and apply the transformation to the actual position and size + tex_quad_vertex[0] = mat_precomp * Vec3f(0.,-tex_size,-tex_size); // Bottom Right + tex_quad_vertex[1] = mat_precomp * Vec3f(0., tex_size,-tex_size); // Bottom Right + tex_quad_vertex[2] = mat_precomp * Vec3f(0.,-tex_size, tex_size); // Bottom Right + tex_quad_vertex[3] = mat_precomp * Vec3f(0., tex_size, tex_size); // Bottom Right + + // and finally dump some info + dumpTexRecord(); + +} + +void Nebula::rotate(float angle) +{ + std::cout << "rotating nebula by an angle of " << angle << std::endl; + + float tex_angular_size, tex_size; + double ra_rad, de_rad; + + StelUtils::rect_to_sphe(&ra_rad, &de_rad, XYZ); + + // need to do the inverse of this: angular_size = tex_angular_size/2/60*M_PI/180; + tex_angular_size = angular_size*180*60/M_PI*2; + tex_size = RADIUS_NEB * sin(tex_angular_size/2/60*M_PI/180); + + // rotate it. + texture_rotation += angle; + + // now to manipulate the actual texture + // Precomputation of the rotation/translation matrix + Mat4f mat_precomp = Mat4f::translation(XYZ) * + Mat4f::zrotation(ra_rad) * + Mat4f::yrotation(-de_rad) * + Mat4f::xrotation(texture_rotation*M_PI/180.); + + // and apply the transformation to the actual position and size + tex_quad_vertex[0] = mat_precomp * Vec3f(0.,-tex_size,-tex_size); // Bottom Right + tex_quad_vertex[1] = mat_precomp * Vec3f(0., tex_size,-tex_size); // Bottom Right + tex_quad_vertex[2] = mat_precomp * Vec3f(0.,-tex_size, tex_size); // Bottom Right + tex_quad_vertex[3] = mat_precomp * Vec3f(0., tex_size, tex_size); // Bottom Right + + // and finally dump some info + dumpTexRecord(); +} + +void Nebula::shiftRA(float amount) +{ + std::cout << "RA shift of nebula by " << amount << std::endl; + + float tex_angular_size, tex_size; + double ra_rad, de_rad; + + StelUtils::rect_to_sphe(&ra_rad, &de_rad, XYZ); + + // need to do the inverse of this: angular_size = tex_angular_size/2/60*M_PI/180; + tex_angular_size = angular_size*180*60/M_PI*2; + tex_size = RADIUS_NEB * sin(tex_angular_size/2/60*M_PI/180); + + // shift it + ra_rad += ( amount * M_PI / 180 ); + + // Calc the Cartesian coord with RA and DE + StelUtils::sphe_to_rect(ra_rad,de_rad,XYZ); + XYZ*=RADIUS_NEB; + + // now to manipulate the actual texture + // Precomputation of the rotation/translation matrix + Mat4f mat_precomp = Mat4f::translation(XYZ) * + Mat4f::zrotation(ra_rad) * + Mat4f::yrotation(-de_rad) * + Mat4f::xrotation(texture_rotation*M_PI/180.); + + // and apply the transformation to the actual position and size + tex_quad_vertex[0] = mat_precomp * Vec3f(0.,-tex_size,-tex_size); // Bottom Right + tex_quad_vertex[1] = mat_precomp * Vec3f(0., tex_size,-tex_size); // Bottom Right + tex_quad_vertex[2] = mat_precomp * Vec3f(0.,-tex_size, tex_size); // Bottom Right + tex_quad_vertex[3] = mat_precomp * Vec3f(0., tex_size, tex_size); // Bottom Right + + // and finally dump some info + dumpTexRecord(); +} + +void Nebula::shiftDec(float amount) +{ + std::cout << "Dec shift of nebula by " << amount << std::endl; + + float tex_angular_size, tex_size; + double ra_rad, de_rad; + + StelUtils::rect_to_sphe(&ra_rad, &de_rad, XYZ); + + // need to do the inverse of this: angular_size = tex_angular_size/2/60*M_PI/180; + tex_angular_size = angular_size*180*60/M_PI*2; + tex_size = RADIUS_NEB * sin(tex_angular_size/2/60*M_PI/180); + + // shift it + de_rad += ( amount * M_PI / 180 ); + + // Calc the Cartesian coord with RA and DE + StelUtils::sphe_to_rect(ra_rad,de_rad,XYZ); + XYZ*=RADIUS_NEB; + + // now to manipulate the actual texture + // Precomputation of the rotation/translation matrix + Mat4f mat_precomp = Mat4f::translation(XYZ) * + Mat4f::zrotation(ra_rad) * + Mat4f::yrotation(-de_rad) * + Mat4f::xrotation(texture_rotation*M_PI/180.); + + // and apply the transformation to the actual position and size + tex_quad_vertex[0] = mat_precomp * Vec3f(0.,-tex_size,-tex_size); // Bottom Right + tex_quad_vertex[1] = mat_precomp * Vec3f(0., tex_size,-tex_size); // Bottom Right + tex_quad_vertex[2] = mat_precomp * Vec3f(0.,-tex_size, tex_size); // Bottom Right + tex_quad_vertex[3] = mat_precomp * Vec3f(0., tex_size, tex_size); // Bottom Right + + // and finally dump some info + dumpTexRecord(); +} + +void Nebula::dumpTexRecord(void) +{ + float ra, de, tex_angular_size; + double ra_rad, de_rad; + std::string orig_credit(credit); + + std::string::size_type pos = orig_credit.find("Credit: "); + if ( pos != string::npos ) { + cout << "found \"Credit: \", removing" << endl; + orig_credit.erase (0,8); + } + else { + cout << "didn't find \"Credit: \"" << endl; + } + + for(int i=0; i #include "StelObject.hpp" #include "stellarium.h" #include "Projector.hpp" @@ -97,6 +98,20 @@ //! Get the convex polygon matching the nebula image in J2000 frame StelGeom::ConvexPolygon getConvexPolygon() {return StelGeom::ConvexPolygon(tex_quad_vertex[0], tex_quad_vertex[1], tex_quad_vertex[2], tex_quad_vertex[3]);} + void spew(void) + { + std::cout << "NEBULA SPEW: name=" << englishName + << ", angular size=" << angular_size + << ", " + << std::endl; + } + + void resize(float factor); + void rotate(float angle); + void shiftRA(float amount); + void shiftDec(float amount); + void dumpTexRecord(void); + private: void draw_chart(const Projector* prj, const Navigator * nav); void draw_tex(const Projector* prj, const Navigator * nav, ToneReproducer* eye); @@ -114,6 +129,8 @@ string credit; // Nebula image credit float mag; // Apparent magnitude float angular_size; // Angular size in radians + float texture_rotation; // rotation of texture + string texture_filename; // filename Vec3f XYZ; // Cartesian equatorial position Vec3d XY; // Store temporary 2D position nebula_type nType; Index: stel_ui.h =================================================================== --- stel_ui.h (revision 2064) +++ stel_ui.h (working copy) @@ -441,6 +441,9 @@ // Script related string SelectedScript; // script filename (without directory) selected in a UI to run when exit UI string SelectedScriptDirectory; // script directory for same + + // MNG: NEBULA editor - changes how sensitive the nebula modification keys are + float nebEditFactor; }; #endif //_STEL_UI_H Index: NebulaMgr.cpp =================================================================== --- NebulaMgr.cpp (revision 2064) +++ NebulaMgr.cpp (working copy) @@ -397,6 +397,7 @@ Nebula *e = new Nebula; if (!e->readNGC(recordstr)) // reading error { + cout << "rejecting NGC record: " << recordstr << endl; delete e; e = NULL; data_drop++;