Katana Plug-in APIs 0.1

FnGLTranslateAxisHandle.h

00001 // Copyright (c) 2017 The Foundry Visionmongers Ltd. All Rights Reserved.
00002 
00003 #ifndef GLTRANSLATEAXISHANDLE_H_
00004 #define GLTRANSLATEAXISHANDLE_H_
00005 
00006 #include <stdint.h>
00007 #include <string>
00008 
00009 #include "FnGLTransformManipulator.h"
00010 
00011 #include <FnViewer/plugin/FnManipulatorHandle.h>
00012 #include <FnViewer/plugin/FnMathTypes.h>
00013 #include <FnViewer/utils/FnDrawable.h>
00014 
00015 using namespace Foundry::Katana::ViewerAPI;
00016 using namespace Foundry::Katana::ViewerUtils;
00017 
00028 class GLTranslateAxisHandle : public GLTransformManipulatorHandle
00029 {
00030 public:
00032     GLTranslateAxisHandle();
00033 
00035     virtual ~GLTranslateAxisHandle();
00036 
00038     static Foundry::Katana::ViewerAPI::ManipulatorHandle* create()
00039     {
00040         return new GLTranslateAxisHandle();
00041     }
00042 
00044     static void flush(){}
00045 
00049     void draw();
00050 
00056     void pickerDraw(int64_t pickerId);
00057 
00059     void setup(const IMATH_NAMESPACE::V3d& axis);
00060 
00061 protected:
00065     virtual std::string getComponentName() { return "translate"; }
00066 
00072     bool getDraggingPlane(Vec3d& origin, Vec3d& normal);
00073 
00077     void startDrag(const Vec3d& initialPointOnPlane,
00078         const Vec2i& initialMousePosition);
00079 
00083     void endDrag();
00084 
00089     void drag(const Vec3d& initialPointOnPlane,
00090               const Vec3d& previousPointOnPlane,
00091               const Vec3d& currentPointOnPlane,
00092               const Vec2i& initialMousePosition,
00093               const Vec2i& previousMousePosition,
00094               const Vec2i& currentMousePosition,
00095               bool isFinal);
00096 
00100     void applyXformToLocation(const std::string& locationPath,
00101                               const IMATH_NAMESPACE::M44d& xform,
00102                               bool isFinal);
00103 
00115     virtual IMATH_NAMESPACE::M44d getOrientationXform(
00116         const std::string& locationPath);
00117 
00122     virtual void calculateAndSetLocalXform(const std::string& locationPath);
00123 
00124 private:
00128     void initMesh();
00129 
00131     IMATH_NAMESPACE::V3d m_axis;
00132 
00134     IMATH_NAMESPACE::V3d m_axisWorldSpace;
00135 
00137     Drawable m_coneMesh;
00138     Drawable m_trunkMesh;
00139 
00140     // Drawable for the infinite line that represents the axis where the
00141     // dragging is occurring.
00142     Drawable m_guideLineMesh;
00143 
00144     Vec3d m_originWorldSpace;
00145     Vec3d m_normalWorldSpace;
00146 
00153     IMATH_NAMESPACE::M44d m_meshXform;
00154 
00155     Vec4f m_axisColor;
00156 };
00157 
00158 #endif  // GLTranslateManipulator_H_
 All Classes Functions Variables Typedefs Enumerations Enumerator