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 \*---------------------------------------------------------------------------*/
42 #include "OSGConfig.h"
44 #include "OSGComponentTransform.h"
45 #include "OSGRenderAction.h"
46 #include "OSGIntersectAction.h"
50 // Documentation for this class is emited in the
51 // OSGComponentTransformBase.cpp file.
52 // To modify it, please change the .fcd file (OSGComponentTransform.fcd) and
53 // regenerate the base file.
55 /*-------------------------------------------------------------------------*/
58 void ComponentTransform::changed(ConstFieldMaskArg whichField
,
62 if((whichField
& CenterFieldMask
) ||
63 (whichField
& RotationFieldMask
) ||
64 (whichField
& ScaleFieldMask
) ||
65 (whichField
& ScaleOrientationFieldMask
) ||
66 (whichField
& TranslationFieldMask
) )
68 // be careful not to mark the matrix as changed here to avoid
69 // bouncing changes back and forth
70 _sfMatrix
.getValue().setTransform(getTranslation (),
73 getScaleOrientation(),
78 else if(whichField
& Inherited::MatrixFieldMask
)
83 Quaternion scaleOrientation
;
86 _sfMatrix
.getValue().getTransform(translation
,
92 // be careful not to mark the components as changed here to avoid
93 // bouncing changes back and forth
94 _sfTranslation
.setValue(translation
);
95 _sfRotation
.setValue(rotation
);
96 _sfScale
.setValue(scale
);
97 _sfScaleOrientation
.setValue(scaleOrientation
);
98 _sfCenter
.setValue(center
);
101 Inherited::changed(whichField
, origin
, details
);
104 void ComponentTransform::dump( UInt32 uiIndent
,
105 const BitVector bvFlags
) const
107 Inherited::dump(uiIndent
, bvFlags
);
110 /*-------------------------------------------------------------------------*/
113 ComponentTransform::ComponentTransform(void) :
116 _sfScale
.getValue().setValues(1.f
, 1.f
, 1.f
);
119 ComponentTransform::ComponentTransform(const ComponentTransform
&source
) :
124 /*-------------------------------------------------------------------------*/
127 ComponentTransform::~ComponentTransform(void)
131 /*-------------------------------------------------------------------------*/
134 void ComponentTransform::initMethod(InitPhase ePhase
)
136 Inherited::initMethod(ePhase
);
138 if(ePhase
== TypeObject::SystemPost
)
140 RenderAction::registerEnterDefault(
141 ComponentTransform::getClassType(),
142 reinterpret_cast<Action::Callback
>(
143 &ComponentTransform::renderEnter
));
145 RenderAction::registerLeaveDefault(
146 ComponentTransform::getClassType(),
147 reinterpret_cast<Action::Callback
>(
148 &ComponentTransform::renderLeave
));
151 IntersectAction::registerEnterDefault(
153 reinterpret_cast<Action::Callback
>(
154 &ComponentTransform::intersectEnter
));
156 IntersectAction::registerLeaveDefault(
158 reinterpret_cast<Action::Callback
>(
159 &ComponentTransform::intersectLeave
));