/* osgVisual test. distortionNG, experimental. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #include "DistortionManipulator.h" #include using namespace osg; using namespace osgViewer; DistortionManipulator::DistortionManipulator() { activeSetupMode = DISABLED; activeDistortionMode = MESH; activeManualSetupMode = DISTORTION; activeVisualizationMode = NONE; _distortionSet = NULL; } DistortionManipulator::~DistortionManipulator() { } void DistortionManipulator::getUsage(osg::ApplicationUsage& usage) const { usage.addKeyboardMouseBinding("Keypad 7","Show distortion mesh / intensity map / none."); usage.addKeyboardMouseBinding("Keypad 8","Save distortion set."); // via plugin usage.addKeyboardMouseBinding("Keypad 4","Toggles Setup Mode between DISABLED, MANUAL & DELEGATED."); usage.addKeyboardMouseBinding("Keypad 5","MANUAL Mode: Toggle between blending & distortion setup."); usage.addKeyboardMouseBinding("Keypad 6","MANUAL Mode: Toggle if distortion drags affect mesh or rtt texture coordinates."); // Defaults to Mesh usage.addKeyboardMouseBinding("Keypad 1","Reset distortion."); usage.addKeyboardMouseBinding("Keypad 2","Reset intensity blending."); } bool DistortionManipulator::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa, osg::Object* obj, osg::NodeVisitor* nv) { //osgViewer::View* viewer = dynamic_cast(&aa); //if ( viewer && !_distortionSet.isValid()) //{ // OSG_ALWAYS<<"Fetching valid DistortionSet!"<getDistortionSet(); //} switch(ea.getEventType()) { case(osgGA::GUIEventAdapter::MOVE): break; case(osgGA::GUIEventAdapter::DRAG): { OSG_ALWAYS<<"DRAG!"< defaults to Mesh { activeDistortionMode = (activeDistortionMode==MESH?TEXCOORDINATES:MESH); OSG_ALWAYS<<"KEY_KP_6 : activeDistortionMode is now "< image = _distortionSet->getIntensityMap(); OSG_ALWAYS<<"Reseting IntensityMap Blending."<isDataContiguous()) { OSG_WARN<<"Warning: DistortionManipulator does not support working with non contiguous imagery as blendmaps!"<data(); for(unsigned int i=0;igetTotalSizeInBytes();i++) { *dataPtr++ = 255; } image->dirty(); } void DistortionManipulator::resetDistortion() { if(!_distortionSet.valid()) return; OSG_ALWAYS<<"ToDo: resetDistortion()"<(_stateset->getAttribute(osg::StateAttribute::POLYGONMODE)); if (!polyModeObj) { polyModeObj = new osg::PolygonMode; _stateset->setAttribute(polyModeObj); } if(show) polyModeObj->setMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::LINE); else polyModeObj->setMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::FILL);*/ } void DistortionManipulator::showIntensityMap(bool show) { OSG_ALWAYS<<"ToDo: showIntensityMap(bool) is now "<setShowIntensityMapOnly(show); }