1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 //---------------------------------------------------------------------------
41 //---------------------------------------------------------------------------
46 #define OSG_COMPILEMANIPULATORSLIB
48 #include "OSGConfig.h"
49 #include "OSGRenderAction.h"
50 #include "OSGIntersectAction.h"
52 #include "OSGRotateManipulator.h"
56 /***************************************************************************\
58 \***************************************************************************/
60 /*! \class OSG::RotateManipulator
61 * The MoveHandle is used for moving objects. It consist of three axis which
62 * can be picked and translated and one center box to translate freely in 3D.
65 /***************************************************************************\
67 \***************************************************************************/
69 /***************************************************************************\
71 \***************************************************************************/
73 void RotateManipulator::initMethod(InitPhase ePhase
)
75 Inherited::initMethod(ePhase
);
77 if(ePhase
== TypeObject::SystemPost
)
79 IntersectAction::registerEnterDefault(
81 reinterpret_cast<Action::Callback
>(
82 &RotateManipulator::intersectEnter
));
84 IntersectAction::registerLeaveDefault(
86 reinterpret_cast<Action::Callback
>(
87 &RotateManipulator::intersectLeave
));
89 RenderAction::registerEnterDefault(
91 reinterpret_cast<Action::Callback
>(
92 &RotateManipulator::renderEnter
));
94 RenderAction::registerLeaveDefault(
96 reinterpret_cast<Action::Callback
>(
97 &RotateManipulator::renderLeave
));
101 /***************************************************************************\
103 \***************************************************************************/
105 /*-------------------------------------------------------------------------*\
107 \*-------------------------------------------------------------------------*/
109 /*----------------------- constructors & destructors ----------------------*/
111 RotateManipulator::RotateManipulator(void) :
116 RotateManipulator::RotateManipulator(const RotateManipulator
&source
) :
121 RotateManipulator::~RotateManipulator(void)
125 /*----------------------------- class specific ----------------------------*/
127 void RotateManipulator::changed(ConstFieldMaskArg whichField
,
131 Inherited::changed(whichField
, origin
, details
);
134 void RotateManipulator::dump( UInt32 uiIndent
,
135 const BitVector bvFlags
) const
137 Inherited::dump(uiIndent
, bvFlags
);
140 NodeTransitPtr
RotateManipulator::makeHandleGeo()
142 return makeSphere(2, 0.2f
);
145 void RotateManipulator::doMovement( Transform
*t
,
148 const Vec3f
&translation
,
149 const Quaternion
&rotation
,
150 const Vec3f
&scaleFactor
,
151 const Quaternion
&scaleOrientation
)
153 Vec3f
axis(0.0f
, 0.0f
, 0.0f
);
155 const Quaternion
rot(axis
, value
);
157 Matrix ma
, mb
, mc
, md
, me
, mf
, mg
;
159 Vec3f
sp( getPivot()[0] * scaleFactor
[0],
160 getPivot()[1] * scaleFactor
[1],
161 getPivot()[2] * scaleFactor
[2]);
163 ma
.setTranslate( - translation
);
164 mb
.setRotate ( rotation
.inverse() );
165 mc
.setTranslate( - sp
);
166 md
.setRotate ( rot
);
167 me
.setTranslate( sp
);
168 mf
.setRotate ( rotation
);
169 mg
.setTranslate( translation
);
172 t
->editMatrix().multLeft(ma
);
173 t
->editMatrix().multLeft(mb
);
174 t
->editMatrix().multLeft(mc
);
175 t
->editMatrix().multLeft(md
);
176 t
->editMatrix().multLeft(me
);
177 t
->editMatrix().multLeft(mf
);
178 t
->editMatrix().multLeft(mg
);