From: Gerrit V. <vo...@us...> - 2014-06-30 07:37:42
|
Update of /cvsroot/opensg/OpenSG/Source/System/Window In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv13409/Source/System/Window Added Files: OSGParallelStereoCameraDecorator.cpp OSGParallelStereoCameraDecorator.fcd OSGParallelStereoCameraDecorator.h OSGParallelStereoCameraDecorator.inl OSGParallelStereoCameraDecoratorBase.cpp OSGParallelStereoCameraDecoratorBase.h OSGParallelStereoCameraDecoratorBase.inl OSGParallelStereoCameraDecoratorFields.h Log Message: added: parallel stereo camera decorator from OSG2 --- NEW FILE: OSGParallelStereoCameraDecorator.inl --- /*---------------------------------------------------------------------------*\ * OpenSG * * * * * * Copyright (C) 2000-2013 by the OpenSG Forum * * * * contact: di...@op..., ger...@vo..., car...@gm... * * * \*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*\ * License * * * * This library is free software; you can redistribute it and/or modify it * * under the terms of the GNU Library General Public License as published * * by the Free Software Foundation, version 2. * * * * This library is distributed in the hope that it will be useful, but * * WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Library General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this library; if not, write to the Free Software * * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * * \*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*\ * Changes * * * * * * * * * * * * * \*---------------------------------------------------------------------------*/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- OSG_BEGIN_NAMESPACE OSG_END_NAMESPACE --- NEW FILE: OSGParallelStereoCameraDecoratorFields.h --- /*---------------------------------------------------------------------------*\ * OpenSG * * * * * * Copyright (C) 2000-2002 by the OpenSG Forum * * * * www.opensg.org * * * * contact: di...@op..., ger...@vo..., jb...@zg... * * * \*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*\ * License * * * * This library is free software; you can redistribute it and/or modify it * * under the terms of the GNU Library General Public License as published * * by the Free Software Foundation, version 2. * * * * This library is distributed in the hope that it will be useful, but * * WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Library General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this library; if not, write to the Free Software * * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * * \*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*\ * Changes * * * * * * * * * * * * * \*---------------------------------------------------------------------------*/ /*****************************************************************************\ ***************************************************************************** ** ** ** This file is automatically generated. ** ** ** ** Any changes made to this file WILL be lost when it is ** ** regenerated, which can become necessary at any time. ** ** ** ***************************************************************************** \*****************************************************************************/ #ifndef _OSGPARALLELSTEREOCAMERADECORATORFIELDS_H_ #define _OSGPARALLELSTEREOCAMERADECORATORFIELDS_H_ #ifdef __sgi #pragma once #endif #include <OSGConfig.h> #include <OSGFieldContainerPtr.h> #include <OSGNodeCoreFieldDataType.h> #include <OSGSystemDef.h> #include <OSGStereoCameraDecoratorFields.h> OSG_BEGIN_NAMESPACE class ParallelStereoCameraDecorator; #if !defined(OSG_DO_DOC) // created as a dummy class, remove to prevent doubles //! ParallelStereoCameraDecoratorPtr typedef FCPtr<StereoCameraDecoratorPtr, ParallelStereoCameraDecorator> ParallelStereoCameraDecoratorPtr; #endif #if !defined(OSG_DO_DOC) || (OSG_DOC_LEVEL >= 3) /*! \ingroup GrpSystemFieldTraits */ #if !defined(OSG_DOC_DEV_TRAITS) /*! \hideinhierarchy */ #endif template <> struct FieldDataTraits<ParallelStereoCameraDecoratorPtr> : public FieldTraitsRecurseMapper<ParallelStereoCameraDecoratorPtr, true> { static DataType _type; enum { StringConvertable = 0x00 }; enum { bHasParent = 0x01 }; static DataType &getType (void) { return _type; } static const char *getSName(void) { return "SFParallelStereoCameraDecoratorPtr"; } static const char *getMName(void) { return "MFParallelStereoCameraDecoratorPtr"; } }; #if !defined(OSG_DOC_DEV_TRAITS) /*! \class FieldTraitsRecurseMapper<ParallelStereoCameraDecoratorPtr, true> \hideinhierarchy */ #endif #endif // !defined(OSG_DO_DOC) || (OSG_DOC_LEVEL >= 3) #if !defined(OSG_DO_DOC) || defined(OSG_DOC_FIELD_TYPEDEFS) /*! \ingroup GrpSystemFieldSingle */ typedef SField<ParallelStereoCameraDecoratorPtr> SFParallelStereoCameraDecoratorPtr; #endif #ifndef OSG_COMPILEPARALLELSTEREOCAMERADECORATORINST OSG_DLLEXPORT_DECL1(SField, ParallelStereoCameraDecoratorPtr, OSG_SYSTEMLIB_DLLTMPLMAPPING) #endif #if !defined(OSG_DO_DOC) || defined(OSG_DOC_FIELD_TYPEDEFS) /*! \ingroup GrpSystemFieldMulti */ typedef MField<ParallelStereoCameraDecoratorPtr> MFParallelStereoCameraDecoratorPtr; #endif #ifndef OSG_COMPILEPARALLELSTEREOCAMERADECORATORINST OSG_DLLEXPORT_DECL1(MField, ParallelStereoCameraDecoratorPtr, OSG_SYSTEMLIB_DLLTMPLMAPPING) #endif OSG_END_NAMESPACE #define OSGPARALLELSTEREOCAMERADECORATORFIELDS_HEADER_CVSID "@(#)$Id: OSGParallelStereoCameraDecoratorFields.h,v 1.1 2014/06/30 07:37:39 vossg Exp $" #endif /* _OSGPARALLELSTEREOCAMERADECORATORFIELDS_H_ */ --- NEW FILE: OSGParallelStereoCameraDecorator.fcd --- <?xml version="1.0"?> <FieldContainer name="ParallelStereoCameraDecorator" parent="StereoCameraDecorator" library="System" pointerfieldtypes="both" structure="concrete" systemcomponent="true" parentsystemcomponent="true" decoratable="false" > The OSG::CameraDecorator for parallel stereo projections <Field name="user" type="NodePtr" cardinality="single" visibility="external" access="public" > The coordinate system relative to the camera (only rotation!). </Field> <Field name="eyeToScreenDistance" type="Real32" cardinality="single" visibility="external" defaultValue="0.041" access="public" > The distance from the eye to the screen. </Field> <Field name="lensSeparationDistance" type="Real32" cardinality="single" visibility="external" defaultValue="0.0635" access="public" > Physical distance between the lens centers, in meters. </Field> <Field name="vScreenSize" type="Real32" cardinality="single" visibility="external" defaultValue="0.0935" access="public" > The vertical size of the screen. </Field> <Field name="hScreenSize" type="Real32" cardinality="single" visibility="external" defaultValue="0.14976" access="public" > The horizontal size of the screen. </Field> <Field name="distortionK" type="Vec4f" cardinality="single" visibility="external" defaultValue="1.0" access="public" > The radial distortion correction coefficients coming from oculus. </Field> <Field name="foVScale" type="Real32" cardinality="single" visibility="external" defaultValue="1.0" access="protected" > The scale of fov, as described in the oculus doc. </Field> </FieldContainer> --- NEW FILE: OSGParallelStereoCameraDecoratorBase.h --- /*---------------------------------------------------------------------------*\ * OpenSG * * * * * * Copyright (C) 2000-2002 by the OpenSG Forum * * * * www.opensg.org * * * * contact: di...@op..., ger...@vo..., jb...@zg... * * * \*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*\ * License * * * * This library is free software; you can redistribute it and/or modify it * * under the terms of the GNU Library General Public License as published * * by the Free Software Foundation, version 2. * * * * This library is distributed in the hope that it will be useful, but * * WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Library General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this library; if not, write to the Free Software * * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * * \*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*\ * Changes * * * * * * * * * * * * * \*---------------------------------------------------------------------------*/ /*****************************************************************************\ ***************************************************************************** ** ** ** This file is automatically generated. ** ** ** ** Any changes made to this file WILL be lost when it is ** ** regenerated, which can become necessary at any time. ** ** ** ** Do not change this file, changes should be done in the derived ** ** class ParallelStereoCameraDecorator ** ** ***************************************************************************** \*****************************************************************************/ #ifndef _OSGPARALLELSTEREOCAMERADECORATORBASE_H_ #define _OSGPARALLELSTEREOCAMERADECORATORBASE_H_ #ifdef __sgi #pragma once #endif #include <OSGConfig.h> #include <OSGSystemDef.h> #include <OSGBaseTypes.h> #include <OSGRefPtr.h> #include <OSGCoredNodePtr.h> #include <OSGStereoCameraDecorator.h> // Parent #include <OSGNodeFields.h> // User type #include <OSGReal32Fields.h> // EyeToScreenDistance type #include <OSGReal32Fields.h> // LensSeparationDistance type #include <OSGReal32Fields.h> // VScreenSize type #include <OSGReal32Fields.h> // HScreenSize type #include <OSGVec4fFields.h> // DistortionK type #include <OSGReal32Fields.h> // FoVScale type #include <OSGParallelStereoCameraDecoratorFields.h> OSG_BEGIN_NAMESPACE class ParallelStereoCameraDecorator; class BinaryDataHandler; //! \brief ParallelStereoCameraDecorator Base Class. class OSG_SYSTEMLIB_DLLMAPPING ParallelStereoCameraDecoratorBase : public StereoCameraDecorator { private: typedef StereoCameraDecorator Inherited; /*========================== PUBLIC =================================*/ public: typedef ParallelStereoCameraDecoratorPtr Ptr; enum { UserFieldId = Inherited::NextFieldId, EyeToScreenDistanceFieldId = UserFieldId + 1, LensSeparationDistanceFieldId = EyeToScreenDistanceFieldId + 1, VScreenSizeFieldId = LensSeparationDistanceFieldId + 1, HScreenSizeFieldId = VScreenSizeFieldId + 1, DistortionKFieldId = HScreenSizeFieldId + 1, FoVScaleFieldId = DistortionKFieldId + 1, NextFieldId = FoVScaleFieldId + 1 }; static const OSG::BitVector UserFieldMask; static const OSG::BitVector EyeToScreenDistanceFieldMask; static const OSG::BitVector LensSeparationDistanceFieldMask; static const OSG::BitVector VScreenSizeFieldMask; static const OSG::BitVector HScreenSizeFieldMask; static const OSG::BitVector DistortionKFieldMask; static const OSG::BitVector FoVScaleFieldMask; static const OSG::BitVector MTInfluenceMask; /*---------------------------------------------------------------------*/ /*! \name Class Get */ /*! \{ */ static FieldContainerType &getClassType (void); static UInt32 getClassTypeId (void); /*! \} */ /*---------------------------------------------------------------------*/ /*! \name FieldContainer Get */ /*! \{ */ virtual FieldContainerType &getType (void); virtual const FieldContainerType &getType (void) const; virtual UInt32 getContainerSize(void) const; /*! \} */ /*---------------------------------------------------------------------*/ /*! \name Field Get */ /*! \{ */ SFNodePtr *editSFUser (void); const SFNodePtr *getSFUser (void) const; #ifndef OSG_2_PREP SFNodePtr *getSFUser (void); #endif SFReal32 *editSFEyeToScreenDistance(void); const SFReal32 *getSFEyeToScreenDistance(void) const; #ifndef OSG_2_PREP SFReal32 *getSFEyeToScreenDistance(void); #endif SFReal32 *editSFLensSeparationDistance(void); const SFReal32 *getSFLensSeparationDistance(void) const; #ifndef OSG_2_PREP SFReal32 *getSFLensSeparationDistance(void); #endif SFReal32 *editSFVScreenSize (void); const SFReal32 *getSFVScreenSize (void) const; #ifndef OSG_2_PREP SFReal32 *getSFVScreenSize (void); #endif SFReal32 *editSFHScreenSize (void); const SFReal32 *getSFHScreenSize (void) const; #ifndef OSG_2_PREP SFReal32 *getSFHScreenSize (void); #endif SFVec4f *editSFDistortionK (void); const SFVec4f *getSFDistortionK (void) const; #ifndef OSG_2_PREP SFVec4f *getSFDistortionK (void); #endif NodePtr &editUser (void); const NodePtr &getUser (void) const; #ifndef OSG_2_PREP NodePtr &getUser (void); #endif Real32 &editEyeToScreenDistance(void); const Real32 &getEyeToScreenDistance(void) const; #ifndef OSG_2_PREP Real32 &getEyeToScreenDistance(void); #endif Real32 &editLensSeparationDistance(void); const Real32 &getLensSeparationDistance(void) const; #ifndef OSG_2_PREP Real32 &getLensSeparationDistance(void); #endif Real32 &editVScreenSize (void); const Real32 &getVScreenSize (void) const; #ifndef OSG_2_PREP Real32 &getVScreenSize (void); #endif Real32 &editHScreenSize (void); const Real32 &getHScreenSize (void) const; #ifndef OSG_2_PREP Real32 &getHScreenSize (void); #endif Vec4f &editDistortionK (void); const Vec4f &getDistortionK (void) const; #ifndef OSG_2_PREP Vec4f &getDistortionK (void); #endif /*! \} */ /*---------------------------------------------------------------------*/ /*! \name Field Set */ /*! \{ */ void setUser ( const NodePtr &value ); void setEyeToScreenDistance( const Real32 &value ); void setLensSeparationDistance( const Real32 &value ); void setVScreenSize ( const Real32 &value ); void setHScreenSize ( const Real32 &value ); void setDistortionK ( const Vec4f &value ); /*! \} */ /*---------------------------------------------------------------------*/ /*! \name Sync */ /*! \{ */ /*! \} */ /*---------------------------------------------------------------------*/ /*! \name Binary Access */ /*! \{ */ virtual UInt32 getBinSize (const BitVector &whichField); virtual void copyToBin ( BinaryDataHandler &pMem, const BitVector &whichField); virtual void copyFromBin( BinaryDataHandler &pMem, const BitVector &whichField); /*! \} */ /*---------------------------------------------------------------------*/ /*! \name Construction */ /*! \{ */ static ParallelStereoCameraDecoratorPtr create (void); static ParallelStereoCameraDecoratorPtr createEmpty (void); /*! \} */ /*---------------------------------------------------------------------*/ /*! \name Copy */ /*! \{ */ virtual FieldContainerPtr shallowCopy (void) const; /*! \} */ /*========================= PROTECTED ===============================*/ protected: /*---------------------------------------------------------------------*/ /*! \name Fields */ /*! \{ */ SFNodePtr _sfUser; SFReal32 _sfEyeToScreenDistance; SFReal32 _sfLensSeparationDistance; SFReal32 _sfVScreenSize; SFReal32 _sfHScreenSize; SFVec4f _sfDistortionK; SFReal32 _sfFoVScale; /*! \} */ /*---------------------------------------------------------------------*/ /*! \name Constructors */ /*! \{ */ ParallelStereoCameraDecoratorBase(void); ParallelStereoCameraDecoratorBase(const ParallelStereoCameraDecoratorBase &source); /*! \} */ /*---------------------------------------------------------------------*/ /*! \name Destructors */ /*! \{ */ virtual ~ParallelStereoCameraDecoratorBase(void); /*! \} */ /*---------------------------------------------------------------------*/ /*! \name Field Get */ /*! \{ */ SFReal32 *editSFFoVScale (void); const SFReal32 *getSFFoVScale (void) const; #ifndef OSG_2_PREP SFReal32 *getSFFoVScale (void); #endif Real32 &editFoVScale (void); const Real32 &getFoVScale (void) const; #ifndef OSG_2_PREP Real32 &getFoVScale (void); #endif /*! \} */ /*---------------------------------------------------------------------*/ /*! \name Field Set */ /*! \{ */ void setFoVScale (const Real32 &value); /*! \} */ /*---------------------------------------------------------------------*/ /*! \name Sync */ /*! \{ */ #if !defined(OSG_FIXED_MFIELDSYNC) void executeSyncImpl( ParallelStereoCameraDecoratorBase *pOther, const BitVector &whichField); virtual void executeSync( FieldContainer &other, const BitVector &whichField); #else void executeSyncImpl( ParallelStereoCameraDecoratorBase *pOther, const BitVector &whichField, const SyncInfo &sInfo ); virtual void executeSync( FieldContainer &other, const BitVector &whichField, const SyncInfo &sInfo); virtual void execBeginEdit (const BitVector &whichField, UInt32 uiAspect, UInt32 uiContainerSize); void execBeginEditImpl (const BitVector &whichField, UInt32 uiAspect, UInt32 uiContainerSize); virtual void onDestroyAspect(UInt32 uiId, UInt32 uiAspect); #endif /*! \} */ /*========================== PRIVATE ================================*/ private: friend class FieldContainer; static FieldDescription *_desc[]; static FieldContainerType _type; // prohibit default functions (move to 'public' if you need one) void operator =(const ParallelStereoCameraDecoratorBase &source); }; //--------------------------------------------------------------------------- // Exported Types //--------------------------------------------------------------------------- typedef ParallelStereoCameraDecoratorBase *ParallelStereoCameraDecoratorBaseP; typedef osgIF<ParallelStereoCameraDecoratorBase::isNodeCore, CoredNodePtr<ParallelStereoCameraDecorator>, FieldContainer::attempt_to_create_CoredNodePtr_on_non_NodeCore_FC >::_IRet ParallelStereoCameraDecoratorNodePtr; typedef RefPtr<ParallelStereoCameraDecoratorPtr> ParallelStereoCameraDecoratorRefPtr; OSG_END_NAMESPACE #define OSGPARALLELSTEREOCAMERADECORATORBASE_HEADER_CVSID "@(#)$Id: OSGParallelStereoCameraDecoratorBase.h,v 1.1 2014/06/30 07:37:39 vossg Exp $" #endif /* _OSGPARALLELSTEREOCAMERADECORATORBASE_H_ */ --- NEW FILE: OSGParallelStereoCameraDecorator.h --- /*---------------------------------------------------------------------------*\ * OpenSG * * * * * * Copyright (C) 2000-2013 by the OpenSG Forum * * * * www.opensg.org * * * * contact: di...@op..., ger...@vo..., car...@gm... * * * \*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*\ * License * * * * This library is free software; you can redistribute it and/or modify it * * under the terms of the GNU Library General Public License as published * * by the Free Software Foundation, version 2. * * * * This library is distributed in the hope that it will be useful, but * * WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Library General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this library; if not, write to the Free Software * * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * * \*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*\ * Changes * * * * * * * * * * * * * \*---------------------------------------------------------------------------*/ #ifndef _OSGPARALLELSTEREOCAMERADECORATOR_H_ #define _OSGPARALLELSTEREOCAMERADECORATOR_H_ #ifdef __sgi #pragma once #endif #include "OSGParallelStereoCameraDecoratorBase.h" OSG_BEGIN_NAMESPACE /*! \brief ParallelStereoCameraDecorator class. See \ref PageWindowParallelStereoCameraDecorator for a description. */ class OSG_SYSTEMLIB_DLLMAPPING ParallelStereoCameraDecorator : public ParallelStereoCameraDecoratorBase { protected: /*========================== PUBLIC =================================*/ public: typedef ParallelStereoCameraDecoratorBase Inherited; typedef ParallelStereoCameraDecorator Self; /*---------------------------------------------------------------------*/ /*! \name Sync */ /*! \{ */ virtual void changed(BitVector whichField, UInt32 origin ); /*! \} */ /*---------------------------------------------------------------------*/ /*! \name access */ /*! \{ */ virtual void getViewing (Matrix &result, UInt32 width, UInt32 height); virtual void getProjection(Matrix &result, UInt32 width, UInt32 height); virtual void getDecoration(Matrix &result, UInt32 width, UInt32 height); /*! \} */ /*---------------------------------------------------------------------*/ /*! \name Output */ /*! \{ */ virtual void dump( UInt32 uiIndent = 0, const BitVector bvFlags = 0) const; /*! \} */ /*========================= PROTECTED ===============================*/ protected: // Variables should all be in ParallelStereoCameraDecoratorBase. /*---------------------------------------------------------------------*/ /*! \name Constructors */ /*! \{ */ ParallelStereoCameraDecorator(void); ParallelStereoCameraDecorator(const ParallelStereoCameraDecorator &source); /*! \} */ /*---------------------------------------------------------------------*/ /*! \name Destructors */ /*! \{ */ virtual ~ParallelStereoCameraDecorator(void); /*! \} */ /*---------------------------------------------------------------------*/ /*! \name Init */ /*! \{ */ static void initMethod(void); /*! \} */ /*========================== PRIVATE ================================*/ private: friend class FieldContainer; friend class ParallelStereoCameraDecoratorBase; // prohibit default functions (move to 'public' if you need one) void operator =(const ParallelStereoCameraDecorator &source); }; typedef ParallelStereoCameraDecorator *ParallelStereoCameraDecoratorP; OSG_END_NAMESPACE #include "OSGParallelStereoCameraDecoratorBase.inl" #include "OSGParallelStereoCameraDecorator.inl" #endif /* _OSGPARALLELSTEREOCAMERADECORATOR_H_ */ --- NEW FILE: OSGParallelStereoCameraDecorator.cpp --- /*---------------------------------------------------------------------------*\ * OpenSG * * * * * * Copyright (C) 2000-2013 by the OpenSG Forum * * * * www.opensg.org * * * * contact: di...@op..., ger...@vo..., car...@gm... * * * \*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*\ * License * * * * This library is free software; you can redistribute it and/or modify it * * under the terms of the GNU Library General Public License as published * * by the Free Software Foundation, version 2. * * * * This library is distributed in the hope that it will be useful, but * * WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Library General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this library; if not, write to the Free Software * * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * * \*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*\ * Changes * * * * * * * * * * * * * \*---------------------------------------------------------------------------*/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- #include <cstdlib> #include <cstdio> #include "OSGConfig.h" #include "OSGMatrixUtility.h" #include "OSGQuaternion.h" #include "OSGNode.h" #include "OSGCamera.h" #include "OSGPerspectiveCamera.h" #include "OSGParallelStereoCameraDecorator.h" OSG_BEGIN_NAMESPACE // Documentation for this class is emitted in the // OSGParallelStereoCameraDecoratorBase.cpp file. // To modify it, please change the .fcd file (OSGParallelStereoCameraDecorator.fcd) and // regenerate the base file. /***************************************************************************\ * Class variables * \***************************************************************************/ /***************************************************************************\ * Class methods * \***************************************************************************/ void ParallelStereoCameraDecorator::initMethod(void) { } /***************************************************************************\ * Instance methods * \***************************************************************************/ /*-------------------------------------------------------------------------*\ - private - \*-------------------------------------------------------------------------*/ /*----------------------- constructors & destructors ----------------------*/ ParallelStereoCameraDecorator::ParallelStereoCameraDecorator(void) : Inherited() { } ParallelStereoCameraDecorator::ParallelStereoCameraDecorator(const ParallelStereoCameraDecorator &source) : Inherited(source) { } ParallelStereoCameraDecorator::~ParallelStereoCameraDecorator(void) { } /*----------------------------- class specific ----------------------------*/ void ParallelStereoCameraDecorator::changed(BitVector whichField, UInt32 origin) { Inherited::changed(whichField, origin); } void ParallelStereoCameraDecorator::dump( UInt32 , const BitVector ) const { SLOG << "Dump ParallelStereoCameraDecorator NI" << std::endl; } float distortionFn( Vec4f d, float r ) { float r2 = r * r; return r * (d[0] + (d[1] + (d[2] + d[3] * r2) * r2) * r2); } /*! Get the projection matrix, as described in OculusSDK doc */ void ParallelStereoCameraDecorator::getProjection(Matrix &result, UInt32 width, UInt32 height) { if(width == 0 || height == 0) { result.setIdentity(); SLOG << "ParallelStereoCameraDecorator::getProjection(wxh): " << width << "x" << height << std::endl; return; } #if 0 PerspectiveCamera *cam = dynamic_cast<PerspectiveCamera *>(getDecoratee()); #endif PerspectiveCameraPtr cam = PerspectiveCameraPtr::dcast(getDecoratee()); if(cam == NullFC) { FFATAL(("ParallelStereoCameraDecorator::getProjection: can only" " decorate PerspectiveCameras!\n")); result.setIdentity(); return; } float LensCenterx = 1.f - (2.f * getLensSeparationDistance() / getHScreenSize()); float fovscale = 1.0; // compute scale { // Convert fit value to distortion-centered coordinates before fit radius // calculation. float dx = 0.5f + LensCenterx; float dy = 0.5f / cam->getAspect(); float fitRadius = sqrt(dx * dx + dy * dy); fovscale = distortionFn( getDistortionK(), fitRadius ) / fitRadius; //SLOG << "fovscale: " << fovscale << std::endl; } setFoVScale(fovscale); // Compute Vertical FOV based on distance. float fov = 2.0f * atan(fovscale*getVScreenSize()/(2.0f*getEyeToScreenDistance())); Matrix P = Matrix( 1.0f / (cam->getAspect() * tan(fov/2.0f)), 0.f, 0.f, 0.f, 0.f, 1.0f / tan(fov/2.0f), 0.f, 0.f, 0.f, 0.f, cam->getFar()/(cam->getNear()-cam->getFar()), cam->getFar()*cam->getNear()/(cam->getNear()-cam->getFar()), 0.f, 0.f, -1.0f, 0.f); result = P; if (!getLeftEye()) LensCenterx*=-1.f; Matrix trans; trans.setTranslate(Vec3f(LensCenterx,0,0)); result.multLeft(trans); } void ParallelStereoCameraDecorator::getViewing(Matrix &result, UInt32 OSG_CHECK_ARG(width ), UInt32 OSG_CHECK_ARG(height)) { NodePtr pUser = getUser(); if(pUser == NULL) { FWARNING(("ParallelStereoCameraDecorator::getViewing: no user!\n")); CameraPtr pCamera = getDecoratee(); if(pCamera == NULL) { result.setIdentity(); return; } pCamera->getBeacon()->getToWorld(result); result.invert(); } else { pUser->getToWorld(result); result.invert(); } float halfIPD = getEyeSeparation() * 0.5f; if (!getLeftEye()) halfIPD*=-1.f; Matrix trans; trans.setTranslate(Vec3f(halfIPD,0,0)); result.multLeft(trans); } void ParallelStereoCameraDecorator::getDecoration(Matrix &result, UInt32 width, UInt32 height) { if(width == 0 || height == 0) { result.setIdentity(); return; } CameraPtr camera = getDecoratee(); if(camera == NULL) { FWARNING(("ParallelStereoCameraDecorator::getDecoration: no decoratee!\n")); result.setIdentity(); return; } camera->getDecoration(result, width, height); } OSG_END_NAMESPACE --- NEW FILE: OSGParallelStereoCameraDecoratorBase.inl --- /*---------------------------------------------------------------------------*\ * OpenSG * * * * * * Copyright (C) 2000-2002 by the OpenSG Forum * * * * contact: di...@op..., ger...@vo..., jb...@zg... * * * \*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*\ * License * * * * This library is free software; you can redistribute it and/or modify it * * under the terms of the GNU Library General Public License as published * * by the Free Software Foundation, version 2. * * * * This library is distributed in the hope that it will be useful, but * * WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Library General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this library; if not, write to the Free Software * * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * * \*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*\ * Changes * * * * * * * * * * * * * \*---------------------------------------------------------------------------*/ /*****************************************************************************\ ***************************************************************************** ** ** ** This file is automatically generated. ** ** ** ** Any changes made to this file WILL be lost when it is ** ** regenerated, which can become necessary at any time. ** ** ** ** Do not change this file, changes should be done in the derived ** ** class ParallelStereoCameraDecorator! ** ** ***************************************************************************** \*****************************************************************************/ #include <OSGConfig.h> OSG_BEGIN_NAMESPACE //! access the type of the class inline OSG::FieldContainerType &ParallelStereoCameraDecoratorBase::getClassType(void) { return _type; } //! access the numerical type of the class inline OSG::UInt32 ParallelStereoCameraDecoratorBase::getClassTypeId(void) { return _type.getId(); } //! create a new instance of the class inline ParallelStereoCameraDecoratorPtr ParallelStereoCameraDecoratorBase::create(void) { ParallelStereoCameraDecoratorPtr fc; if(getClassType().getPrototype() != OSG::NullFC) { fc = ParallelStereoCameraDecoratorPtr::dcast( getClassType().getPrototype()-> shallowCopy()); } return fc; } //! create an empty new instance of the class, do not copy the prototype inline ParallelStereoCameraDecoratorPtr ParallelStereoCameraDecoratorBase::createEmpty(void) { ParallelStereoCameraDecoratorPtr returnValue; newPtr(returnValue); return returnValue; } /*------------------------------ get -----------------------------------*/ //! Get the ParallelStereoCameraDecorator::_sfUser field. inline const SFNodePtr *ParallelStereoCameraDecoratorBase::getSFUser(void) const { return &_sfUser; } //! Get the ParallelStereoCameraDecorator::_sfUser field. inline SFNodePtr *ParallelStereoCameraDecoratorBase::editSFUser(void) { return &_sfUser; } #ifndef OSG_2_PREP //! Get the ParallelStereoCameraDecorator::_sfUser field. inline SFNodePtr *ParallelStereoCameraDecoratorBase::getSFUser(void) { return &_sfUser; } #endif //! Get the ParallelStereoCameraDecorator::_sfEyeToScreenDistance field. inline const SFReal32 *ParallelStereoCameraDecoratorBase::getSFEyeToScreenDistance(void) const { return &_sfEyeToScreenDistance; } //! Get the ParallelStereoCameraDecorator::_sfEyeToScreenDistance field. inline SFReal32 *ParallelStereoCameraDecoratorBase::editSFEyeToScreenDistance(void) { return &_sfEyeToScreenDistance; } #ifndef OSG_2_PREP //! Get the ParallelStereoCameraDecorator::_sfEyeToScreenDistance field. inline SFReal32 *ParallelStereoCameraDecoratorBase::getSFEyeToScreenDistance(void) { return &_sfEyeToScreenDistance; } #endif //! Get the ParallelStereoCameraDecorator::_sfLensSeparationDistance field. inline const SFReal32 *ParallelStereoCameraDecoratorBase::getSFLensSeparationDistance(void) const { return &_sfLensSeparationDistance; } //! Get the ParallelStereoCameraDecorator::_sfLensSeparationDistance field. inline SFReal32 *ParallelStereoCameraDecoratorBase::editSFLensSeparationDistance(void) { return &_sfLensSeparationDistance; } #ifndef OSG_2_PREP //! Get the ParallelStereoCameraDecorator::_sfLensSeparationDistance field. inline SFReal32 *ParallelStereoCameraDecoratorBase::getSFLensSeparationDistance(void) { return &_sfLensSeparationDistance; } #endif //! Get the ParallelStereoCameraDecorator::_sfVScreenSize field. inline const SFReal32 *ParallelStereoCameraDecoratorBase::getSFVScreenSize(void) const { return &_sfVScreenSize; } //! Get the ParallelStereoCameraDecorator::_sfVScreenSize field. inline SFReal32 *ParallelStereoCameraDecoratorBase::editSFVScreenSize(void) { return &_sfVScreenSize; } #ifndef OSG_2_PREP //! Get the ParallelStereoCameraDecorator::_sfVScreenSize field. inline SFReal32 *ParallelStereoCameraDecoratorBase::getSFVScreenSize(void) { return &_sfVScreenSize; } #endif //! Get the ParallelStereoCameraDecorator::_sfHScreenSize field. inline const SFReal32 *ParallelStereoCameraDecoratorBase::getSFHScreenSize(void) const { return &_sfHScreenSize; } //! Get the ParallelStereoCameraDecorator::_sfHScreenSize field. inline SFReal32 *ParallelStereoCameraDecoratorBase::editSFHScreenSize(void) { return &_sfHScreenSize; } #ifndef OSG_2_PREP //! Get the ParallelStereoCameraDecorator::_sfHScreenSize field. inline SFReal32 *ParallelStereoCameraDecoratorBase::getSFHScreenSize(void) { return &_sfHScreenSize; } #endif //! Get the ParallelStereoCameraDecorator::_sfDistortionK field. inline const SFVec4f *ParallelStereoCameraDecoratorBase::getSFDistortionK(void) const { return &_sfDistortionK; } //! Get the ParallelStereoCameraDecorator::_sfDistortionK field. inline SFVec4f *ParallelStereoCameraDecoratorBase::editSFDistortionK(void) { return &_sfDistortionK; } #ifndef OSG_2_PREP //! Get the ParallelStereoCameraDecorator::_sfDistortionK field. inline SFVec4f *ParallelStereoCameraDecoratorBase::getSFDistortionK(void) { return &_sfDistortionK; } #endif //! Get the ParallelStereoCameraDecorator::_sfFoVScale field. inline const SFReal32 *ParallelStereoCameraDecoratorBase::getSFFoVScale(void) const { return &_sfFoVScale; } //! Get the ParallelStereoCameraDecorator::_sfFoVScale field. inline SFReal32 *ParallelStereoCameraDecoratorBase::editSFFoVScale(void) { return &_sfFoVScale; } #ifndef OSG_2_PREP //! Get the ParallelStereoCameraDecorator::_sfFoVScale field. inline SFReal32 *ParallelStereoCameraDecoratorBase::getSFFoVScale(void) { return &_sfFoVScale; } #endif //! Get the value of the ParallelStereoCameraDecorator::_sfUser field. inline NodePtr &ParallelStereoCameraDecoratorBase::editUser(void) { return _sfUser.getValue(); } //! Get the value of the ParallelStereoCameraDecorator::_sfUser field. inline const NodePtr &ParallelStereoCameraDecoratorBase::getUser(void) const { return _sfUser.getValue(); } #ifndef OSG_2_PREP //! Get the value of the ParallelStereoCameraDecorator::_sfUser field. inline NodePtr &ParallelStereoCameraDecoratorBase::getUser(void) { return _sfUser.getValue(); } #endif //! Set the value of the ParallelStereoCameraDecorator::_sfUser field. inline void ParallelStereoCameraDecoratorBase::setUser(const NodePtr &value) { _sfUser.setValue(value); } //! Get the value of the ParallelStereoCameraDecorator::_sfEyeToScreenDistance field. inline Real32 &ParallelStereoCameraDecoratorBase::editEyeToScreenDistance(void) { return _sfEyeToScreenDistance.getValue(); } //! Get the value of the ParallelStereoCameraDecorator::_sfEyeToScreenDistance field. inline const Real32 &ParallelStereoCameraDecoratorBase::getEyeToScreenDistance(void) const { return _sfEyeToScreenDistance.getValue(); } #ifndef OSG_2_PREP //! Get the value of the ParallelStereoCameraDecorator::_sfEyeToScreenDistance field. inline Real32 &ParallelStereoCameraDecoratorBase::getEyeToScreenDistance(void) { return _sfEyeToScreenDistance.getValue(); } #endif //! Set the value of the ParallelStereoCameraDecorator::_sfEyeToScreenDistance field. inline void ParallelStereoCameraDecoratorBase::setEyeToScreenDistance(const Real32 &value) { _sfEyeToScreenDistance.setValue(value); } //! Get the value of the ParallelStereoCameraDecorator::_sfLensSeparationDistance field. inline Real32 &ParallelStereoCameraDecoratorBase::editLensSeparationDistance(void) { return _sfLensSeparationDistance.getValue(); } //! Get the value of the ParallelStereoCameraDecorator::_sfLensSeparationDistance field. inline const Real32 &ParallelStereoCameraDecoratorBase::getLensSeparationDistance(void) const { return _sfLensSeparationDistance.getValue(); } #ifndef OSG_2_PREP //! Get the value of the ParallelStereoCameraDecorator::_sfLensSeparationDistance field. inline Real32 &ParallelStereoCameraDecoratorBase::getLensSeparationDistance(void) { return _sfLensSeparationDistance.getValue(); } #endif //! Set the value of the ParallelStereoCameraDecorator::_sfLensSeparationDistance field. inline void ParallelStereoCameraDecoratorBase::setLensSeparationDistance(const Real32 &value) { _sfLensSeparationDistance.setValue(value); } //! Get the value of the ParallelStereoCameraDecorator::_sfVScreenSize field. inline Real32 &ParallelStereoCameraDecoratorBase::editVScreenSize(void) { return _sfVScreenSize.getValue(); } //! Get the value of the ParallelStereoCameraDecorator::_sfVScreenSize field. inline const Real32 &ParallelStereoCameraDecoratorBase::getVScreenSize(void) const { return _sfVScreenSize.getValue(); } #ifndef OSG_2_PREP //! Get the value of the ParallelStereoCameraDecorator::_sfVScreenSize field. inline Real32 &ParallelStereoCameraDecoratorBase::getVScreenSize(void) { return _sfVScreenSize.getValue(); } #endif //! Set the value of the ParallelStereoCameraDecorator::_sfVScreenSize field. inline void ParallelStereoCameraDecoratorBase::setVScreenSize(const Real32 &value) { _sfVScreenSize.setValue(value); } //! Get the value of the ParallelStereoCameraDecorator::_sfHScreenSize field. inline Real32 &ParallelStereoCameraDecoratorBase::editHScreenSize(void) { return _sfHScreenSize.getValue(); } //! Get the value of the ParallelStereoCameraDecorator::_sfHScreenSize field. inline const Real32 &ParallelStereoCameraDecoratorBase::getHScreenSize(void) const { return _sfHScreenSize.getValue(); } #ifndef OSG_2_PREP //! Get the value of the ParallelStereoCameraDecorator::_sfHScreenSize field. inline Real32 &ParallelStereoCameraDecoratorBase::getHScreenSize(void) { return _sfHScreenSize.getValue(); } #endif //! Set the value of the ParallelStereoCameraDecorator::_sfHScreenSize field. inline void ParallelStereoCameraDecoratorBase::setHScreenSize(const Real32 &value) { _sfHScreenSize.setValue(value); } //! Get the value of the ParallelStereoCameraDecorator::_sfDistortionK field. inline Vec4f &ParallelStereoCameraDecoratorBase::editDistortionK(void) { return _sfDistortionK.getValue(); } //! Get the value of the ParallelStereoCameraDecorator::_sfDistortionK field. inline const Vec4f &ParallelStereoCameraDecoratorBase::getDistortionK(void) const { return _sfDistortionK.getValue(); } #ifndef OSG_2_PREP //! Get the value of the ParallelStereoCameraDecorator::_sfDistortionK field. inline Vec4f &ParallelStereoCameraDecoratorBase::getDistortionK(void) { return _sfDistortionK.getValue(); } #endif //! Set the value of the ParallelStereoCameraDecorator::_sfDistortionK field. inline void ParallelStereoCameraDecoratorBase::setDistortionK(const Vec4f &value) { _sfDistortionK.setValue(value); } //! Get the value of the ParallelStereoCameraDecorator::_sfFoVScale field. inline Real32 &ParallelStereoCameraDecoratorBase::editFoVScale(void) { return _sfFoVScale.getValue(); } //! Get the value of the ParallelStereoCameraDecorator::_sfFoVScale field. inline const Real32 &ParallelStereoCameraDecoratorBase::getFoVScale(void) const { return _sfFoVScale.getValue(); } #ifndef OSG_2_PREP //! Get the value of the ParallelStereoCameraDecorator::_sfFoVScale field. inline Real32 &ParallelStereoCameraDecoratorBase::getFoVScale(void) { return _sfFoVScale.getValue(); } #endif //! Set the value of the ParallelStereoCameraDecorator::_sfFoVScale field. inline void ParallelStereoCameraDecoratorBase::setFoVScale(const Real32 &value) { _sfFoVScale.setValue(value); } OSG_END_NAMESPACE #define OSGPARALLELSTEREOCAMERADECORATORBASE_INLINE_CVSID "@(#)$Id: OSGParallelStereoCameraDecoratorBase.inl,v 1.1 2014/06/30 07:37:39 vossg Exp $" --- NEW FILE: OSGParallelStereoCameraDecoratorBase.cpp --- /*---------------------------------------------------------------------------*\ * OpenSG * * ... [truncated message content] |