[346] | 1 | /* osgVisual test. distortionNG, experimental. |
---|
| 2 | * |
---|
| 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
---|
| 4 | * of this software and associated documentation files (the "Software"), to deal |
---|
| 5 | * in the Software without restriction, including without limitation the rights |
---|
| 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
---|
| 7 | * copies of the Software, and to permit persons to whom the Software is |
---|
| 8 | * furnished to do so, subject to the following conditions: |
---|
| 9 | * |
---|
| 10 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
---|
| 11 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
---|
| 12 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
---|
| 13 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
---|
| 14 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
---|
| 15 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
---|
| 16 | * THE SOFTWARE. |
---|
| 17 | */ |
---|
| 18 | |
---|
| 19 | #ifndef OSGGA_DISTORTION_MANIPULATOR |
---|
| 20 | #define OSGGA_DISTORTION_MANIPULATOR 1 |
---|
| 21 | |
---|
[349] | 22 | #include <osgGA/GUIEventHandler> |
---|
[353] | 23 | #include <osg/Referenced> |
---|
| 24 | #include <osg/Switch> |
---|
| 25 | #include <osg/Geometry> |
---|
| 26 | #include <osgUtil/IntersectionVisitor> |
---|
| 27 | #include <osgUtil/LineSegmentIntersector> |
---|
| 28 | |
---|
[349] | 29 | #include "DistortionSet.h" |
---|
[346] | 30 | |
---|
| 31 | |
---|
| 32 | namespace osgViewer { |
---|
| 33 | |
---|
[353] | 34 | |
---|
[346] | 35 | class DistortionManipulator : public osgGA::GUIEventHandler |
---|
| 36 | { |
---|
| 37 | public: |
---|
[348] | 38 | enum SetupMode { |
---|
| 39 | DISABLED, |
---|
| 40 | MANUAL, |
---|
| 41 | DELEGATED |
---|
| 42 | }; |
---|
| 43 | enum DistortionMode { |
---|
| 44 | MESH, |
---|
| 45 | TEXCOORDINATES |
---|
| 46 | }; |
---|
| 47 | enum ManualSetupMode { |
---|
| 48 | DISTORTION, |
---|
| 49 | BLENDING |
---|
| 50 | }; |
---|
| 51 | enum VisualizationMode { |
---|
| 52 | DISTORTION_MESH, |
---|
| 53 | INTENSITY_MAP, |
---|
| 54 | NONE |
---|
| 55 | }; |
---|
| 56 | |
---|
| 57 | |
---|
[353] | 58 | DistortionManipulator(DistortionSet* ds); |
---|
[346] | 59 | virtual ~DistortionManipulator(); |
---|
| 60 | |
---|
| 61 | virtual void getUsage(osg::ApplicationUsage& usage) const; |
---|
| 62 | virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa, osg::Object*, osg::NodeVisitor* nv); |
---|
[347] | 63 | |
---|
[349] | 64 | void setDistortionSet(DistortionSet* ds) {_distortionSet = ds;} |
---|
| 65 | |
---|
[353] | 66 | |
---|
| 67 | |
---|
[347] | 68 | private: |
---|
| 69 | void resetIntensityMap(); |
---|
| 70 | void resetDistortion(); |
---|
[349] | 71 | void showDistortionMesh(bool show); |
---|
| 72 | void showIntensityMap(bool show); |
---|
[348] | 73 | |
---|
[353] | 74 | void computeSelectedVertex( osgUtil::LineSegmentIntersector::Intersection& result ); |
---|
| 75 | void createVertexHighlighter(); |
---|
| 76 | |
---|
[348] | 77 | SetupMode activeSetupMode; |
---|
| 78 | DistortionMode activeDistortionMode; |
---|
| 79 | ManualSetupMode activeManualSetupMode; |
---|
| 80 | VisualizationMode activeVisualizationMode; |
---|
[349] | 81 | |
---|
| 82 | osg::ref_ptr<DistortionSet> _distortionSet; |
---|
[353] | 83 | |
---|
| 84 | |
---|
| 85 | osg::ref_ptr<osg::Geometry> _highlighter; |
---|
| 86 | osg::observer_ptr<osg::Camera> _camera; |
---|
| 87 | osg::Geometry* _distortionMesh; |
---|
| 88 | const osg::Vec4 _highlightColor; |
---|
[346] | 89 | }; |
---|
| 90 | |
---|
| 91 | |
---|
| 92 | } |
---|
| 93 | |
---|
| 94 | #endif /* OSGGA_DISTORTION_MANIPULATOR */ |
---|