fixed: compile issue
[opensg.git] / Source / Contrib / Manipulators / OSGScaleManipulator.cpp
bloba51e0bd3d5a17999f4615fc1df7eff98195a2e4c
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
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. *
18 * *
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. *
23 * *
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. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 //---------------------------------------------------------------------------
40 // Includes
41 //---------------------------------------------------------------------------
43 #include <stdlib.h>
44 #include <stdio.h>
46 #define OSG_COMPILEMANIPULATORSLIB
48 #include "OSGConfig.h"
49 #include "OSGRenderAction.h"
50 #include "OSGIntersectAction.h"
52 #include "OSGScaleManipulator.h"
54 OSG_USING_NAMESPACE
56 /***************************************************************************\
57 * Description *
58 \***************************************************************************/
60 /*! \class OSG::ScaleManipulator
61 * The ScaleHandle is used for scaleing objects. It consist of three axis
62 * which can be picked and scaled and one center box to scale freely in 3D.
65 /***************************************************************************\
66 * Class variables *
67 \***************************************************************************/
69 /***************************************************************************\
70 * Class methods *
71 \***************************************************************************/
73 void ScaleManipulator::initMethod(InitPhase ePhase)
75 Inherited::initMethod(ePhase);
77 if(ePhase == TypeObject::SystemPost)
79 IntersectAction::registerEnterDefault(
80 getClassType(),
81 reinterpret_cast<Action::Callback>(
82 &ScaleManipulator::intersectEnter));
84 IntersectAction::registerLeaveDefault(
85 getClassType(),
86 reinterpret_cast<Action::Callback>(
87 &ScaleManipulator::intersectLeave));
89 RenderAction::registerEnterDefault(
90 getClassType(),
91 reinterpret_cast<Action::Callback>(&ScaleManipulator::renderEnter));
93 RenderAction::registerLeaveDefault(
94 getClassType(),
95 reinterpret_cast<Action::Callback>(&ScaleManipulator::renderLeave));
100 /***************************************************************************\
101 * Instance methods *
102 \***************************************************************************/
104 /*-------------------------------------------------------------------------*\
105 - private -
106 \*-------------------------------------------------------------------------*/
108 /*----------------------- constructors & destructors ----------------------*/
110 ScaleManipulator::ScaleManipulator(void) :
111 Inherited()
115 ScaleManipulator::ScaleManipulator(const ScaleManipulator &source) :
116 Inherited(source)
120 ScaleManipulator::~ScaleManipulator(void)
124 /*----------------------------- class specific ----------------------------*/
126 void ScaleManipulator::changed(ConstFieldMaskArg whichField,
127 UInt32 origin,
128 BitVector details )
130 Inherited::changed(whichField, origin, details);
133 void ScaleManipulator::dump( UInt32 uiIndent,
134 const BitVector bvFlags) const
136 Inherited::dump(uiIndent, bvFlags);
139 NodeTransitPtr ScaleManipulator::makeHandleGeo()
141 return makeCylinder(0.75f, 0.1f, 12, true, true, true);
144 void ScaleManipulator::doMovement( Transform *t,
145 const Int32 coord,
146 const Real32 value,
147 const Vec3f &translation,
148 const Quaternion &rotation,
149 const Vec3f &scaleFactor,
150 const Quaternion &scaleOrientation)
152 Vec3f scale(1.0f, 1.0f, 1.0f);
154 if(getUniform() == true)
156 scale += Vec3f(value, value, value);
158 else
160 scale[coord] += value;
163 Matrix ma, mb, mc, md, me, mf, mg;
165 Vec3f sp( getPivot()[0] * scaleFactor[0],
166 getPivot()[1] * scaleFactor[1],
167 getPivot()[2] * scaleFactor[2]);
169 ma.setTranslate(-translation );
170 mb.setRotate ( rotation.inverse());
171 mc.setTranslate( - sp );
172 md.setScale ( scale );
173 me.setTranslate( sp );
174 mf.setRotate ( rotation );
175 mg.setTranslate( translation );
177 t->editMatrix().multLeft(ma);
178 t->editMatrix().multLeft(mb);
179 t->editMatrix().multLeft(mc);
180 t->editMatrix().multLeft(md);
181 t->editMatrix().multLeft(me);
182 t->editMatrix().multLeft(mf);
183 t->editMatrix().multLeft(mg);