OSGScaleManipulator.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 "OSGScaleManipulator.h"
00053
00054 OSG_USING_NAMESPACE
00055
00056
00057
00058
00059
00065
00066
00067
00068
00069
00070
00071
00072
00073 void ScaleManipulator::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 &ScaleManipulator::intersectEnter));
00083
00084 IntersectAction::registerLeaveDefault(
00085 getClassType(),
00086 reinterpret_cast<Action::Callback>(
00087 &ScaleManipulator::intersectLeave));
00088
00089 RenderAction::registerEnterDefault(
00090 getClassType(),
00091 reinterpret_cast<Action::Callback>(&ScaleManipulator::renderEnter));
00092
00093 RenderAction::registerLeaveDefault(
00094 getClassType(),
00095 reinterpret_cast<Action::Callback>(&ScaleManipulator::renderLeave));
00096 }
00097 }
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110 ScaleManipulator::ScaleManipulator(void) :
00111 Inherited()
00112 {
00113 }
00114
00115 ScaleManipulator::ScaleManipulator(const ScaleManipulator &source) :
00116 Inherited(source)
00117 {
00118 }
00119
00120 ScaleManipulator::~ScaleManipulator(void)
00121 {
00122 }
00123
00124
00125
00126 void ScaleManipulator::changed(ConstFieldMaskArg whichField,
00127 UInt32 origin,
00128 BitVector details )
00129 {
00130 Inherited::changed(whichField, origin, details);
00131 }
00132
00133 void ScaleManipulator::dump( UInt32 uiIndent,
00134 const BitVector bvFlags) const
00135 {
00136 Inherited::dump(uiIndent, bvFlags);
00137 }
00138
00139 NodeTransitPtr ScaleManipulator::makeHandleGeo()
00140 {
00141 return makeCylinder(0.75f, 0.1f, 12, true, true, true);
00142 }
00143
00144 void ScaleManipulator::doMovement( Transform *t,
00145 const Int32 coord,
00146 const Real32 value,
00147 const Vec3f &translation,
00148 const Quaternion &rotation,
00149 const Vec3f &scaleFactor,
00150 const Quaternion &scaleOrientation)
00151 {
00152 Vec3f scale(1.0f, 1.0f, 1.0f);
00153 scale[coord] += value;
00154
00155 Matrix ma, mb, mc, md, me;
00156
00157 ma.setTranslate(-translation );
00158 mb.setRotate ( rotation.inverse());
00159 mc.setScale ( scale );
00160 md.setRotate ( rotation );
00161 me.setTranslate( translation );
00162
00163 t->editMatrix().multLeft(ma);
00164 t->editMatrix().multLeft(mb);
00165 t->editMatrix().multLeft(mc);
00166 t->editMatrix().multLeft(md);
00167 t->editMatrix().multLeft(me);
00168
00169 commitChanges();
00170 }