|
Katana Plug-in APIs 0.1
|
00001 // Copyright (c) 2017 The Foundry Visionmongers Ltd. All Rights Reserved. 00002 00003 #ifndef GLROTATEAXISHANDLE_H_ 00004 #define GLROTATEAXISHANDLE_H_ 00005 00006 #include <stdint.h> 00007 #include <vector> 00008 #include <FnViewer/plugin/FnManipulatorHandle.h> 00009 #include <FnViewer/plugin/FnMathTypes.h> 00010 #include <FnViewer/utils/FnDrawable.h> 00011 00012 #include "FnGLTransformManipulator.h" 00013 00014 using namespace Foundry::Katana::ViewerAPI; 00015 using namespace Foundry::Katana::ViewerUtils; 00016 00048 class GLRotateAxisHandle : public GLTransformManipulatorHandle 00049 { 00050 public: 00052 GLRotateAxisHandle(); 00053 00055 virtual ~GLRotateAxisHandle(); 00056 00058 static Foundry::Katana::ViewerAPI::ManipulatorHandle* create() 00059 { 00060 return new GLRotateAxisHandle(); 00061 } 00062 00064 static void flush(){} 00065 00069 void draw(); 00070 00076 void pickerDraw(int64_t pickerId); 00077 00079 void setup(const IMATH_NAMESPACE::V3d& axis); 00080 00084 void setupViewHandle() 00085 { 00086 m_isViewHandle = true; 00087 setup(IMATH_NAMESPACE::V3d(0, 0, 1)); 00088 } 00089 00090 virtual Orientation getOrientation() 00091 { 00092 if (m_isViewHandle) 00093 return VIEW; 00094 00095 return GLTransformManipulatorHandle::getOrientation(); 00096 } 00097 00103 FnAttribute::Attribute getOption( 00104 Foundry::Katana::ViewerAPI::OptionIdGenerator::value_type optionId); 00105 00106 protected: 00110 virtual std::string getComponentName() { return "rotate?"; } 00111 00117 bool getDraggingPlane(Vec3d& origin, Vec3d& normal); 00118 00123 void startDrag(const Vec3d& initialPointOnPlane, 00124 const Vec2i& initialMousePosition); 00125 00131 void drag(const Vec3d& initialPointOnPlane, 00132 const Vec3d& previousPointOnPlane, 00133 const Vec3d& currentPointOnPlane, 00134 const Vec2i& initialMousePosition, 00135 const Vec2i& previousMousePosition, 00136 const Vec2i& currentMousePosition, 00137 bool isFinal); 00138 00142 void endDrag(); 00143 00148 void applyXformToLocation(const std::string& locationPath, 00149 const IMATH_NAMESPACE::M44d& xform, 00150 bool isFinal); 00151 00152 private: 00159 void initMesh(); 00160 00169 void updateSliceMesh(const IMATH_NAMESPACE::V3d& initialAngle, 00170 double angle); 00171 00173 IMATH_NAMESPACE::V3d m_axis; 00174 00179 IMATH_NAMESPACE::V3d m_axisWorldSpace; 00180 00184 Vec3d m_originWorldSpace; 00185 Vec3d m_normalWorldSpace; 00186 00188 Drawable m_mesh; 00189 Drawable m_sliceMesh; 00190 Drawable m_sliceOutlineMesh; 00191 00193 std::vector<Vec3f> m_sliceVertices; 00194 00201 IMATH_NAMESPACE::M44d m_meshXform; 00202 00208 IMATH_NAMESPACE::M44d m_initialXform; 00209 00216 IMATH_NAMESPACE::V3d m_initialAngle; 00217 00219 double m_totalAngle; 00220 00232 bool m_isOrbital; 00233 00234 bool m_isViewHandle; 00235 00236 Vec4f m_axisColor; 00237 00238 static const int s_sliceSections = 64; 00239 }; 00240 00241 #endif // GLROTATEAXISHANDLE_H_
1.7.3