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 \*---------------------------------------------------------------------------*/
39 //---------------------------------------------------------------------------
41 //---------------------------------------------------------------------------
46 #include "OSGConfig.h"
48 #include "OSGMatrixUtility.h"
50 #include "OSGPerspectiveCamera.h"
51 #include "OSGShearedStereoCameraDecorator.h"
55 // Documentation for this class is emited in the
56 // OSGShearedStereoCameraDecoratorBase.cpp file.
57 // To modify it, please change the .fcd file (OSGShearedStereoCameraDecorator.fcd) and
58 // regenerate the base file.
60 /*----------------------- constructors & destructors ----------------------*/
62 ShearedStereoCameraDecorator::ShearedStereoCameraDecorator(void) :
67 ShearedStereoCameraDecorator::ShearedStereoCameraDecorator(
68 const ShearedStereoCameraDecorator
&source
) :
74 ShearedStereoCameraDecorator::~ShearedStereoCameraDecorator(void)
78 /*----------------------------- class specific ----------------------------*/
80 void ShearedStereoCameraDecorator::initMethod(InitPhase ePhase
)
82 Inherited::initMethod(ePhase
);
85 void ShearedStereoCameraDecorator::changed(ConstFieldMaskArg whichField
,
89 Inherited::changed(whichField
, origin
, details
);
92 void ShearedStereoCameraDecorator::dump( UInt32
,
93 const BitVector
) const
95 SLOG
<< "Dump ShearedStereoCameraDecorator NI" << std::endl
;
99 /*! Get the projection matrix, uses MatrixStereoPerspective to generate it.
102 void ShearedStereoCameraDecorator::getProjection(Matrix
&result
,
106 if(width
== 0 || height
== 0)
108 result
.setIdentity();
112 PerspectiveCamera
*cam
=
113 dynamic_cast<PerspectiveCamera
*>(getDecoratee());
117 FFATAL(("ShearedStereoCameraDecorator::getProjection: can only"
118 " decorate PerspectiveCameras!\n"));
120 result
.setIdentity();
125 MatrixStereoPerspective(result
, trans
, cam
->getFov(),
126 width
/ Real32(height
) * cam
->getAspect(),
129 getZeroParallaxDistance(),
131 getLeftEye() ? 0.f
: 1.f
,
137 void ShearedStereoCameraDecorator::getDecoration(Matrix
&result
,
141 if(width
== 0 || height
== 0)
143 result
.setIdentity();
147 Camera
*camera
= getDecoratee();
151 FWARNING(("TileCameraDecorator::getProjection: no decoratee!\n"));
153 result
.setIdentity();
158 camera
->getDecoration(result
, width
, height
);