OSGRotateManipulator.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #include <stdlib.h>
00044 #include <stdio.h>
00045
00046 #define OSG_COMPILEMANIPULATORSLIB
00047
00048 #include "OSGConfig.h"
00049 #include "OSGRenderAction.h"
00050 #include "OSGIntersectAction.h"
00051
00052 #include "OSGRotateManipulator.h"
00053
00054 OSG_USING_NAMESPACE
00055
00056
00057
00058
00059
00065
00066
00067
00068
00069
00070
00071
00072
00073 void RotateManipulator::initMethod(InitPhase ePhase)
00074 {
00075 Inherited::initMethod(ePhase);
00076
00077 if(ePhase == TypeObject::SystemPost)
00078 {
00079 IntersectAction::registerEnterDefault(
00080 getClassType(),
00081 reinterpret_cast<Action::Callback>(
00082 &RotateManipulator::intersectEnter));
00083
00084 IntersectAction::registerLeaveDefault(
00085 getClassType(),
00086 reinterpret_cast<Action::Callback>(
00087 &RotateManipulator::intersectLeave));
00088
00089 RenderAction::registerEnterDefault(
00090 getClassType(),
00091 reinterpret_cast<Action::Callback>(
00092 &RotateManipulator::renderEnter));
00093
00094 RenderAction::registerLeaveDefault(
00095 getClassType(),
00096 reinterpret_cast<Action::Callback>(
00097 &RotateManipulator::renderLeave));
00098 }
00099 }
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111 RotateManipulator::RotateManipulator(void) :
00112 Inherited()
00113 {
00114 }
00115
00116 RotateManipulator::RotateManipulator(const RotateManipulator &source) :
00117 Inherited(source)
00118 {
00119 }
00120
00121 RotateManipulator::~RotateManipulator(void)
00122 {
00123 }
00124
00125
00126
00127 void RotateManipulator::changed(ConstFieldMaskArg whichField,
00128 UInt32 origin,
00129 BitVector details)
00130 {
00131 Inherited::changed(whichField, origin, details);
00132 }
00133
00134 void RotateManipulator::dump( UInt32 uiIndent,
00135 const BitVector bvFlags ) const
00136 {
00137 Inherited::dump(uiIndent, bvFlags);
00138 }
00139
00140 NodeTransitPtr RotateManipulator::makeHandleGeo()
00141 {
00142 return makeSphere(2, 0.2f);
00143 }
00144
00145 void RotateManipulator::doMovement( Transform *t,
00146 const Int32 coord,
00147 const Real32 value,
00148 const Vec3f &translation,
00149 const Quaternion &rotation,
00150 const Vec3f &scaleFactor,
00151 const Quaternion &scaleOrientation)
00152 {
00153 Vec3f axis(0.0f, 0.0f, 0.0f);
00154 axis[coord] = 1.0;
00155 const Quaternion rot(axis, value);
00156
00157 Matrix ma, mb, mc, md, me;
00158
00159 ma.setTranslate(-translation );
00160 mb.setRotate ( rotation.inverse() );
00161 mc.setRotate ( rot );
00162 md.setRotate ( rotation );
00163 me.setTranslate( translation );
00164 t->editMatrix().multLeft(ma);
00165 t->editMatrix().multLeft(mb);
00166 t->editMatrix().multLeft(mc);
00167 t->editMatrix().multLeft(md);
00168 t->editMatrix().multLeft(me);
00169
00170 commitChanges();
00171 }