changed: gcc8 base update
[opensg.git] / Source / System / NodeCores / Groups / Misc / OSGComponentTransform.cpp
blob6d33712f14c0a240918b82a92eeb4e35d355064e
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 #include <cstdlib>
40 #include <cstdio>
42 #include "OSGConfig.h"
44 #include "OSGComponentTransform.h"
45 #include "OSGRenderAction.h"
46 #include "OSGIntersectAction.h"
48 OSG_USING_NAMESPACE
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 /*-------------------------------------------------------------------------*/
56 /* Changed */
58 void ComponentTransform::changed(ConstFieldMaskArg whichField,
59 UInt32 origin,
60 BitVector details)
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 (),
71 getRotation (),
72 getScale (),
73 getScaleOrientation(),
74 getCenter ());
76 invalidateVolume();
78 else if(whichField & Inherited::MatrixFieldMask)
80 Vec3f translation;
81 Quaternion rotation;
82 Vec3f scale;
83 Quaternion scaleOrientation;
84 Vec3f center;
86 _sfMatrix.getValue().getTransform(translation,
87 rotation,
88 scale,
89 scaleOrientation,
90 center );
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 /*-------------------------------------------------------------------------*/
111 /* Constructors */
113 ComponentTransform::ComponentTransform(void) :
114 Inherited()
116 _sfScale.getValue().setValues(1.f, 1.f, 1.f);
119 ComponentTransform::ComponentTransform(const ComponentTransform &source) :
120 Inherited(source)
124 /*-------------------------------------------------------------------------*/
125 /* Destructor */
127 ComponentTransform::~ComponentTransform(void)
131 /*-------------------------------------------------------------------------*/
132 /* Init */
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(
152 getClassType(),
153 reinterpret_cast<Action::Callback>(
154 &ComponentTransform::intersectEnter));
156 IntersectAction::registerLeaveDefault(
157 getClassType(),
158 reinterpret_cast<Action::Callback>(
159 &ComponentTransform::intersectLeave));