| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | #include <osgManipulator/TabBoxDragger> |
|---|
| 16 | |
|---|
| 17 | #include <osg/ShapeDrawable> |
|---|
| 18 | #include <osg/Geometry> |
|---|
| 19 | #include <osg/LineWidth> |
|---|
| 20 | #include <osg/Quat> |
|---|
| 21 | |
|---|
| 22 | using namespace osgManipulator; |
|---|
| 23 | |
|---|
| 24 | TabBoxDragger::TabBoxDragger() |
|---|
| 25 | { |
|---|
| 26 | for (int i=0; i<6; ++i) |
|---|
| 27 | { |
|---|
| 28 | _planeDraggers.push_back(new TabPlaneDragger()); |
|---|
| 29 | addChild(_planeDraggers[i].get()); |
|---|
| 30 | addDragger(_planeDraggers[i].get()); |
|---|
| 31 | } |
|---|
| 32 | |
|---|
| 33 | { |
|---|
| 34 | _planeDraggers[0]->setMatrix(osg::Matrix::translate(osg::Vec3(0.0,0.5,0.0))); |
|---|
| 35 | } |
|---|
| 36 | { |
|---|
| 37 | osg::Quat rotation; rotation.makeRotate(osg::Vec3(0.0f, -1.0f, 0.0f), osg::Vec3(0.0f, 1.0f, 0.0f)); |
|---|
| 38 | _planeDraggers[1]->setMatrix(osg::Matrix(rotation)*osg::Matrix::translate(osg::Vec3(0.0,-0.5,0.0))); |
|---|
| 39 | } |
|---|
| 40 | { |
|---|
| 41 | osg::Quat rotation; rotation.makeRotate(osg::Vec3(0.0f, 0.0f, 1.0f), osg::Vec3(0.0f, 1.0f, 0.0f)); |
|---|
| 42 | _planeDraggers[2]->setMatrix(osg::Matrix(rotation)*osg::Matrix::translate(osg::Vec3(0.0,0.0,-0.5))); |
|---|
| 43 | } |
|---|
| 44 | |
|---|
| 45 | { |
|---|
| 46 | osg::Quat rotation; rotation.makeRotate(osg::Vec3(0.0f, 1.0f, 0.0f), osg::Vec3(0.0f, 0.0f, 1.0f)); |
|---|
| 47 | _planeDraggers[3]->setMatrix(osg::Matrix(rotation)*osg::Matrix::translate(osg::Vec3(0.0,0.0,0.5))); |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | { |
|---|
| 51 | osg::Quat rotation; rotation.makeRotate(osg::Vec3(1.0f, 0.0f, 0.0f), osg::Vec3(0.0f, 1.0f, 0.0f)); |
|---|
| 52 | _planeDraggers[4]->setMatrix(osg::Matrix(rotation)*osg::Matrix::translate(osg::Vec3(-0.5,0.0,0.0))); |
|---|
| 53 | } |
|---|
| 54 | |
|---|
| 55 | { |
|---|
| 56 | osg::Quat rotation; rotation.makeRotate(osg::Vec3(0.0f, 1.0f, 0.0f), osg::Vec3(1.0f, 0.0f, 0.0f)); |
|---|
| 57 | _planeDraggers[5]->setMatrix(osg::Matrix(rotation)*osg::Matrix::translate(osg::Vec3(0.5,0.0,0.0))); |
|---|
| 58 | } |
|---|
| 59 | |
|---|
| 60 | setParentDragger(getParentDragger()); |
|---|
| 61 | } |
|---|
| 62 | |
|---|
| 63 | TabBoxDragger::~TabBoxDragger() |
|---|
| 64 | { |
|---|
| 65 | } |
|---|
| 66 | |
|---|
| 67 | void TabBoxDragger::setupDefaultGeometry() |
|---|
| 68 | { |
|---|
| 69 | for (unsigned int i=0; i<_planeDraggers.size(); ++i) |
|---|
| 70 | _planeDraggers[i]->setupDefaultGeometry(false); |
|---|
| 71 | } |
|---|
| 72 | |
|---|
| 73 | void TabBoxDragger::setPlaneColor(const osg::Vec4& color) |
|---|
| 74 | { |
|---|
| 75 | for (unsigned int i=0; i<_planeDraggers.size(); ++i) |
|---|
| 76 | _planeDraggers[i]->setPlaneColor(color); |
|---|
| 77 | } |
|---|