changed: gcc8 base update
[opensg.git] / Source / Contrib / ComplexSceneManager / OSGCSMSceneParameter.cpp
blobaee2e1ffcbbd5663c1f242e174667c7fab0a2644
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2006 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 <cstdlib>
44 #include <cstdio>
46 #include "OSGConfig.h"
48 #include "OSGCSMSceneParameter.h"
49 #include "OSGNode.h"
51 OSG_BEGIN_NAMESPACE
53 // Documentation for this class is emitted in the
54 // OSGCSMSceneParameterBase.cpp file.
55 // To modify it, please change the .fcd file (OSGCSMSceneParameter.fcd) and
56 // regenerate the base file.
58 /***************************************************************************\
59 * Class variables *
60 \***************************************************************************/
62 /***************************************************************************\
63 * Class methods *
64 \***************************************************************************/
66 void CSMSceneParameter::initMethod(InitPhase ePhase)
68 Inherited::initMethod(ePhase);
70 if(ePhase == TypeObject::SystemPost)
76 /***************************************************************************\
77 * Instance methods *
78 \***************************************************************************/
80 /*-------------------------------------------------------------------------*\
81 - private -
82 \*-------------------------------------------------------------------------*/
84 /*----------------------- constructors & destructors ----------------------*/
86 CSMSceneParameter::CSMSceneParameter(void) :
87 Inherited()
89 Inherited::_bNoFrameFunction = true;
92 CSMSceneParameter::CSMSceneParameter(const CSMSceneParameter &source) :
93 Inherited(source)
95 Inherited::_bNoFrameFunction = true;
98 CSMSceneParameter::~CSMSceneParameter(void)
102 /*----------------------------- class specific ----------------------------*/
104 void CSMSceneParameter::changed(ConstFieldMaskArg whichField,
105 UInt32 origin,
106 BitVector details)
108 Inherited::changed(whichField, origin, details);
110 if(0x0000 != (whichField & (SceneRefFieldMask | ResetFieldMask)))
112 reset();
116 bool CSMSceneParameter::init(void)
118 reset();
120 return true;
123 void CSMSceneParameter::frame(Time oTime, UInt32 uiFrame)
125 OSG_ASSERT(false);
128 void CSMSceneParameter::reset(void)
130 fprintf(stderr, "CSMSceneParameter::reset %p\n",
131 static_cast<void *>(_sfSceneRef.getValue()));
133 if(_sfSceneRef.getValue() != NULL)
135 Vec3f vVolMin;
136 Vec3f vVolMax;
138 _sfSceneRef.getValue()->editVolume(true).getBounds(vVolMin,
139 vVolMax);
141 std::cerr << "Volume: from "
142 << vVolMin << " to "
143 << vVolMax << std::endl;
145 editSFSceneDiag()->setValue(vVolMax - vVolMin);
147 editSFSceneCenter()->setValue(
148 Pnt3f((vVolMin[0] + vVolMax[0]) * .5,
149 (vVolMin[1] + vVolMax[1]) * .5,
150 (vVolMin[2] + vVolMax[2]) * .5));
152 Real32 rDist =
153 osgMax(_sfSceneDiag.getValue()[0],
154 _sfSceneDiag.getValue()[1]) * _sfDistScale.getValue();
156 editSFInitViewPos()->setValue(
157 Pnt3f(_sfSceneCenter.getValue()[0],
158 _sfSceneCenter.getValue()[1],
159 _sfSceneCenter.getValue()[2] + rDist));
161 std::cerr << "Center: " << getSceneCenter()
162 << std::endl;
164 setSceneNear(
165 osgPow(10.f,
166 Int32(
167 log10f(_sfSceneDiag.getValue().length())) - 2));
168 setSceneFar (
169 osgPow(10.f,
170 Int32(osgCeil(
171 log10f(_sfSceneDiag.getValue().length()))) + 1));
173 std::cerr << "clipping (" << _sfSceneDiag.getValue().length()
174 << ": from "
175 << getSceneNear() << " to "
176 << getSceneFar () << std::endl;
180 void CSMSceneParameter::dump( UInt32 ,
181 const BitVector ) const
183 SLOG << "Dump CSMSceneParameter NI" << std::endl;
186 OSG_END_NAMESPACE