1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2013 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, carsten_neumann@gmx.net *
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 /*****************************************************************************\
40 *****************************************************************************
42 ** This file is automatically generated. **
44 ** Any changes made to this file WILL be lost when it is **
45 ** regenerated, which can become necessary at any time. **
47 ** Do not change this file, changes should be done in the derived **
48 ** class PerspectiveCamera!
50 *****************************************************************************
51 \*****************************************************************************/
57 #pragma warning(disable: 4355) // turn off 'this' : used in base member initializer list warning
58 #pragma warning(disable: 4290) // disable exception specification warning
61 #include "OSGConfig.h"
66 #include "OSGPerspectiveCameraBase.h"
67 #include "OSGPerspectiveCamera.h"
69 #include <boost/bind.hpp>
73 /***************************************************************************\
75 \***************************************************************************/
77 /*! \class OSG::PerspectiveCamera
78 The Perspective Camera class, see \ref PageSystemWindowCameraPerspective for
81 The only new parameter is the _sfFov.
84 /***************************************************************************\
85 * Field Documentation *
86 \***************************************************************************/
88 /*! \var Real32 PerspectiveCameraBase::_sfFov
89 The vertical field of view, in radians.
92 /*! \var UInt32 PerspectiveCameraBase::_sfFovMode
93 Defines whether the field of view is measured vertically, horizontally or
94 in the smaller direction. See OSG::PerspectiveCamera::FovMode enum for
98 /*! \var Real32 PerspectiveCameraBase::_sfAspect
99 The aspect ratio (i.e. width / height) of a pixel.
103 /***************************************************************************\
104 * FieldType/FieldTrait Instantiation *
105 \***************************************************************************/
107 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
108 PointerType FieldTraits
<PerspectiveCamera
*, nsOSG
>::_type(
109 "PerspectiveCameraPtr",
111 PerspectiveCamera::getClassType(),
115 OSG_FIELDTRAITS_GETTYPE_NS(PerspectiveCamera
*, nsOSG
)
117 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
121 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
125 /***************************************************************************\
126 * Field Description *
127 \***************************************************************************/
129 void PerspectiveCameraBase::classDescInserter(TypeObject
&oType
)
131 FieldDescriptionBase
*pDesc
= NULL
;
134 pDesc
= new SFReal32::Description(
135 SFReal32::getClassType(),
137 "The vertical field of view, in radians.\n",
138 FovFieldId
, FovFieldMask
,
140 (Field::SFDefaultFlags
| Field::FStdAccess
),
141 static_cast<FieldEditMethodSig
>(&PerspectiveCamera::editHandleFov
),
142 static_cast<FieldGetMethodSig
>(&PerspectiveCamera::getHandleFov
));
144 oType
.addInitialDesc(pDesc
);
146 pDesc
= new SFUInt32::Description(
147 SFUInt32::getClassType(),
149 "Defines whether the field of view is measured vertically, horizontally or\n"
150 "in the smaller direction. See OSG::PerspectiveCamera::FovMode enum for\n"
151 "the actual values, \n",
152 FovModeFieldId
, FovModeFieldMask
,
154 (Field::SFDefaultFlags
| Field::FStdAccess
),
155 static_cast<FieldEditMethodSig
>(&PerspectiveCamera::editHandleFovMode
),
156 static_cast<FieldGetMethodSig
>(&PerspectiveCamera::getHandleFovMode
));
158 oType
.addInitialDesc(pDesc
);
160 pDesc
= new SFReal32::Description(
161 SFReal32::getClassType(),
163 "The aspect ratio (i.e. width / height) of a pixel.\n",
164 AspectFieldId
, AspectFieldMask
,
166 (Field::SFDefaultFlags
| Field::FStdAccess
),
167 static_cast<FieldEditMethodSig
>(&PerspectiveCamera::editHandleAspect
),
168 static_cast<FieldGetMethodSig
>(&PerspectiveCamera::getHandleAspect
));
170 oType
.addInitialDesc(pDesc
);
174 PerspectiveCameraBase::TypeObject
PerspectiveCameraBase::_type(
175 PerspectiveCameraBase::getClassname(),
176 Inherited::getClassname(),
179 reinterpret_cast<PrototypeCreateF
>(&PerspectiveCameraBase::createEmptyLocal
),
180 reinterpret_cast<InitContainerF
>(&PerspectiveCamera::initMethod
),
181 reinterpret_cast<ExitContainerF
>(&PerspectiveCamera::exitMethod
),
182 reinterpret_cast<InitalInsertDescFunc
>(
183 reinterpret_cast<void *>(&PerspectiveCamera::classDescInserter
)),
186 "<?xml version=\"1.0\" ?>\n"
189 " name=\"PerspectiveCamera\"\n"
190 " parent=\"Camera\"\n"
191 " library=\"System\"\n"
192 " structure=\"concrete\"\n"
193 " pointerfieldtypes=\"both\"\n"
194 " systemcomponent=\"true\"\n"
195 " parentsystemcomponent=\"true\"\n"
196 " docGroupBase=\"GrpSystemWindow\"\n"
199 "The Perspective Camera class, see \\ref PageSystemWindowCameraPerspective for \n"
202 "The only new parameter is the _sfFov.\n"
206 " cardinality=\"single\"\n"
207 " visibility=\"external\"\n"
209 " The vertical field of view, in radians.\n"
212 " name=\"fovMode\"\n"
214 " cardinality=\"single\"\n"
215 " visibility=\"external\"\n"
216 " defaultValue=\"0\"\n"
217 " access=\"public\"\n"
219 " Defines whether the field of view is measured vertically, horizontally or\n"
220 " in the smaller direction. See OSG::PerspectiveCamera::FovMode enum for\n"
221 " the actual values, \n"
226 " cardinality=\"single\"\n"
227 " visibility=\"external\"\n"
228 " defaultValue=\"1\"\n"
230 " The aspect ratio (i.e. width / height) of a pixel.\n"
232 "</FieldContainer>\n",
233 "The Perspective Camera class, see \\ref PageSystemWindowCameraPerspective for \n"
236 "The only new parameter is the _sfFov.\n"
239 /*------------------------------ get -----------------------------------*/
241 FieldContainerType
&PerspectiveCameraBase::getType(void)
246 const FieldContainerType
&PerspectiveCameraBase::getType(void) const
251 UInt32
PerspectiveCameraBase::getContainerSize(void) const
253 return sizeof(PerspectiveCamera
);
256 /*------------------------- decorator get ------------------------------*/
259 SFReal32
*PerspectiveCameraBase::editSFFov(void)
261 editSField(FovFieldMask
);
266 const SFReal32
*PerspectiveCameraBase::getSFFov(void) const
272 SFUInt32
*PerspectiveCameraBase::editSFFovMode(void)
274 editSField(FovModeFieldMask
);
279 const SFUInt32
*PerspectiveCameraBase::getSFFovMode(void) const
285 SFReal32
*PerspectiveCameraBase::editSFAspect(void)
287 editSField(AspectFieldMask
);
292 const SFReal32
*PerspectiveCameraBase::getSFAspect(void) const
302 /*------------------------------ access -----------------------------------*/
304 SizeT
PerspectiveCameraBase::getBinSize(ConstFieldMaskArg whichField
)
306 SizeT returnValue
= Inherited::getBinSize(whichField
);
308 if(FieldBits::NoField
!= (FovFieldMask
& whichField
))
310 returnValue
+= _sfFov
.getBinSize();
312 if(FieldBits::NoField
!= (FovModeFieldMask
& whichField
))
314 returnValue
+= _sfFovMode
.getBinSize();
316 if(FieldBits::NoField
!= (AspectFieldMask
& whichField
))
318 returnValue
+= _sfAspect
.getBinSize();
324 void PerspectiveCameraBase::copyToBin(BinaryDataHandler
&pMem
,
325 ConstFieldMaskArg whichField
)
327 Inherited::copyToBin(pMem
, whichField
);
329 if(FieldBits::NoField
!= (FovFieldMask
& whichField
))
331 _sfFov
.copyToBin(pMem
);
333 if(FieldBits::NoField
!= (FovModeFieldMask
& whichField
))
335 _sfFovMode
.copyToBin(pMem
);
337 if(FieldBits::NoField
!= (AspectFieldMask
& whichField
))
339 _sfAspect
.copyToBin(pMem
);
343 void PerspectiveCameraBase::copyFromBin(BinaryDataHandler
&pMem
,
344 ConstFieldMaskArg whichField
)
346 Inherited::copyFromBin(pMem
, whichField
);
348 if(FieldBits::NoField
!= (FovFieldMask
& whichField
))
350 editSField(FovFieldMask
);
351 _sfFov
.copyFromBin(pMem
);
353 if(FieldBits::NoField
!= (FovModeFieldMask
& whichField
))
355 editSField(FovModeFieldMask
);
356 _sfFovMode
.copyFromBin(pMem
);
358 if(FieldBits::NoField
!= (AspectFieldMask
& whichField
))
360 editSField(AspectFieldMask
);
361 _sfAspect
.copyFromBin(pMem
);
365 //! create a new instance of the class
366 PerspectiveCameraTransitPtr
PerspectiveCameraBase::createLocal(BitVector bFlags
)
368 PerspectiveCameraTransitPtr fc
;
370 if(getClassType().getPrototype() != NULL
)
372 FieldContainerTransitPtr tmpPtr
=
373 getClassType().getPrototype()-> shallowCopyLocal(bFlags
);
375 fc
= dynamic_pointer_cast
<PerspectiveCamera
>(tmpPtr
);
381 //! create a new instance of the class, copy the container flags
382 PerspectiveCameraTransitPtr
PerspectiveCameraBase::createDependent(BitVector bFlags
)
384 PerspectiveCameraTransitPtr fc
;
386 if(getClassType().getPrototype() != NULL
)
388 FieldContainerTransitPtr tmpPtr
=
389 getClassType().getPrototype()-> shallowCopyDependent(bFlags
);
391 fc
= dynamic_pointer_cast
<PerspectiveCamera
>(tmpPtr
);
397 //! create a new instance of the class
398 PerspectiveCameraTransitPtr
PerspectiveCameraBase::create(void)
400 PerspectiveCameraTransitPtr fc
;
402 if(getClassType().getPrototype() != NULL
)
404 FieldContainerTransitPtr tmpPtr
=
405 getClassType().getPrototype()-> shallowCopy();
407 fc
= dynamic_pointer_cast
<PerspectiveCamera
>(tmpPtr
);
413 PerspectiveCamera
*PerspectiveCameraBase::createEmptyLocal(BitVector bFlags
)
415 PerspectiveCamera
*returnValue
;
417 newPtr
<PerspectiveCamera
>(returnValue
, bFlags
);
419 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
424 //! create an empty new instance of the class, do not copy the prototype
425 PerspectiveCamera
*PerspectiveCameraBase::createEmpty(void)
427 PerspectiveCamera
*returnValue
;
429 newPtr
<PerspectiveCamera
>(returnValue
, Thread::getCurrentLocalFlags());
431 returnValue
->_pFieldFlags
->_bNamespaceMask
&=
432 ~Thread::getCurrentLocalFlags();
438 FieldContainerTransitPtr
PerspectiveCameraBase::shallowCopyLocal(
439 BitVector bFlags
) const
441 PerspectiveCamera
*tmpPtr
;
443 newPtr(tmpPtr
, dynamic_cast<const PerspectiveCamera
*>(this), bFlags
);
445 FieldContainerTransitPtr
returnValue(tmpPtr
);
447 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
452 FieldContainerTransitPtr
PerspectiveCameraBase::shallowCopyDependent(
453 BitVector bFlags
) const
455 PerspectiveCamera
*tmpPtr
;
457 newPtr(tmpPtr
, dynamic_cast<const PerspectiveCamera
*>(this), ~bFlags
);
459 FieldContainerTransitPtr
returnValue(tmpPtr
);
461 tmpPtr
->_pFieldFlags
->_bNamespaceMask
= bFlags
;
466 FieldContainerTransitPtr
PerspectiveCameraBase::shallowCopy(void) const
468 PerspectiveCamera
*tmpPtr
;
471 dynamic_cast<const PerspectiveCamera
*>(this),
472 Thread::getCurrentLocalFlags());
474 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~Thread::getCurrentLocalFlags();
476 FieldContainerTransitPtr
returnValue(tmpPtr
);
484 /*------------------------- constructors ----------------------------------*/
486 PerspectiveCameraBase::PerspectiveCameraBase(void) :
489 _sfFovMode (UInt32(0)),
490 _sfAspect (Real32(1))
494 PerspectiveCameraBase::PerspectiveCameraBase(const PerspectiveCameraBase
&source
) :
496 _sfFov (source
._sfFov
),
497 _sfFovMode (source
._sfFovMode
),
498 _sfAspect (source
._sfAspect
)
503 /*-------------------------- destructors ----------------------------------*/
505 PerspectiveCameraBase::~PerspectiveCameraBase(void)
510 GetFieldHandlePtr
PerspectiveCameraBase::getHandleFov (void) const
512 SFReal32::GetHandlePtr
returnValue(
513 new SFReal32::GetHandle(
515 this->getType().getFieldDesc(FovFieldId
),
516 const_cast<PerspectiveCameraBase
*>(this)));
521 EditFieldHandlePtr
PerspectiveCameraBase::editHandleFov (void)
523 SFReal32::EditHandlePtr
returnValue(
524 new SFReal32::EditHandle(
526 this->getType().getFieldDesc(FovFieldId
),
530 editSField(FovFieldMask
);
535 GetFieldHandlePtr
PerspectiveCameraBase::getHandleFovMode (void) const
537 SFUInt32::GetHandlePtr
returnValue(
538 new SFUInt32::GetHandle(
540 this->getType().getFieldDesc(FovModeFieldId
),
541 const_cast<PerspectiveCameraBase
*>(this)));
546 EditFieldHandlePtr
PerspectiveCameraBase::editHandleFovMode (void)
548 SFUInt32::EditHandlePtr
returnValue(
549 new SFUInt32::EditHandle(
551 this->getType().getFieldDesc(FovModeFieldId
),
555 editSField(FovModeFieldMask
);
560 GetFieldHandlePtr
PerspectiveCameraBase::getHandleAspect (void) const
562 SFReal32::GetHandlePtr
returnValue(
563 new SFReal32::GetHandle(
565 this->getType().getFieldDesc(AspectFieldId
),
566 const_cast<PerspectiveCameraBase
*>(this)));
571 EditFieldHandlePtr
PerspectiveCameraBase::editHandleAspect (void)
573 SFReal32::EditHandlePtr
returnValue(
574 new SFReal32::EditHandle(
576 this->getType().getFieldDesc(AspectFieldId
),
580 editSField(AspectFieldMask
);
586 #ifdef OSG_MT_CPTR_ASPECT
587 void PerspectiveCameraBase::execSyncV( FieldContainer
&oFrom
,
588 ConstFieldMaskArg whichField
,
589 AspectOffsetStore
&oOffsets
,
590 ConstFieldMaskArg syncMode
,
591 const UInt32 uiSyncInfo
)
593 PerspectiveCamera
*pThis
= static_cast<PerspectiveCamera
*>(this);
595 pThis
->execSync(static_cast<PerspectiveCamera
*>(&oFrom
),
604 #ifdef OSG_MT_CPTR_ASPECT
605 FieldContainer
*PerspectiveCameraBase::createAspectCopy(
606 const FieldContainer
*pRefAspect
) const
608 PerspectiveCamera
*returnValue
;
610 newAspectCopy(returnValue
,
611 dynamic_cast<const PerspectiveCamera
*>(pRefAspect
),
612 dynamic_cast<const PerspectiveCamera
*>(this));
618 void PerspectiveCameraBase::resolveLinks(void)
620 Inherited::resolveLinks();