|
Katana Plug-in APIs 0.1
|
00001 // Copyright (c) 2017 The Foundry Visionmongers Ltd. All Rights Reserved. 00002 00003 #ifndef GLTRANSLATEPLANEHANDLE_H_ 00004 #define GLTRANSLATEPLANEHANDLE_H_ 00005 00006 #include "FnGLTransformManipulator.h" 00007 00008 #include <string> 00009 00010 #include <FnViewer/plugin/FnManipulatorHandle.h> 00011 #include <FnViewer/plugin/FnMathTypes.h> 00012 #include <FnViewer/utils/FnDrawable.h> 00013 00014 using Foundry::Katana::ViewerAPI::Vec2i; 00015 using Foundry::Katana::ViewerAPI::Vec3d; 00016 using Foundry::Katana::ViewerAPI::Vec4f; 00017 using Foundry::Katana::ViewerAPI::Matrix44d; 00018 00026 class GLTranslatePlaneHandle : 00027 public Foundry::Katana::ViewerUtils::GLTransformManipulatorHandle 00028 { 00029 public: 00031 GLTranslatePlaneHandle(); 00032 00034 virtual ~GLTranslatePlaneHandle(); 00035 00037 static Foundry::Katana::ViewerAPI::ManipulatorHandle* create() 00038 { 00039 return new GLTranslatePlaneHandle(); 00040 } 00041 00043 static void flush(){} 00044 00048 void draw(); 00049 00055 void pickerDraw(int64_t pickerId); 00056 00058 void setup(const IMATH_NAMESPACE::V3d& normal); 00059 00060 protected: 00064 virtual std::string getComponentName() { return "translate"; } 00065 00071 bool getDraggingPlane(Vec3d& origin, Vec3d& normal); 00072 00078 void drag(const Vec3d& initialPointOnPlane, 00079 const Vec3d& previousPointOnPlane, 00080 const Vec3d& currentPointOnPlane, 00081 const Vec2i& initialMousePosition, 00082 const Vec2i& previousMousePosition, 00083 const Vec2i& currentMousePosition, 00084 bool isFinal); 00085 00089 void startDrag(const Vec3d& initialPointOnPlane, 00090 const Vec2i& initialMousePosition); 00091 00095 void endDrag(); 00096 00101 void applyXformToLocation(const std::string& locationPath, 00102 const IMATH_NAMESPACE::M44d& xform, 00103 bool isFinal); 00104 00116 virtual IMATH_NAMESPACE::M44d getOrientationXform( 00117 const std::string& locationPath); 00118 00123 virtual void calculateAndSetLocalXform(const std::string& locationPath); 00124 00125 private: 00129 void initMesh(); 00130 00132 Foundry::Katana::ViewerUtils::Drawable m_mesh; 00133 IMATH_NAMESPACE::M44d m_meshXform; 00134 00135 IMATH_NAMESPACE::V3d m_normal; 00136 00137 Vec4f m_color; 00138 00139 Vec3d m_originWorldSpace; 00140 Vec3d m_normalWorldSpace; 00141 }; 00142 00143 #endif // GLTRANSLATEPLANEHANDLE_H_
1.7.3