changed: gcc8 base update
[opensg.git] / Source / System / Window / Camera / OSGShearedStereoCameraDecorator.cpp
blobe59a29b40cf49c97d908a6ea07016cf3c2a73c70
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 //---------------------------------------------------------------------------
40 // Includes
41 //---------------------------------------------------------------------------
43 #include <cstdlib>
44 #include <cstdio>
46 #include "OSGConfig.h"
48 #include "OSGMatrixUtility.h"
50 #include "OSGPerspectiveCamera.h"
51 #include "OSGShearedStereoCameraDecorator.h"
53 OSG_USING_NAMESPACE
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) :
63 Inherited()
67 ShearedStereoCameraDecorator::ShearedStereoCameraDecorator(
68 const ShearedStereoCameraDecorator &source) :
70 Inherited(source)
74 ShearedStereoCameraDecorator::~ShearedStereoCameraDecorator(void)
78 /*----------------------------- class specific ----------------------------*/
80 void ShearedStereoCameraDecorator::initMethod(InitPhase ePhase)
82 Inherited::initMethod(ePhase);
85 void ShearedStereoCameraDecorator::changed(ConstFieldMaskArg whichField,
86 UInt32 origin,
87 BitVector details)
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,
103 UInt32 width,
104 UInt32 height)
106 if(width == 0 || height == 0)
108 result.setIdentity();
109 return;
112 PerspectiveCamera *cam =
113 dynamic_cast<PerspectiveCamera *>(getDecoratee());
115 if(cam == NULL)
117 FFATAL(("ShearedStereoCameraDecorator::getProjection: can only"
118 " decorate PerspectiveCameras!\n"));
120 result.setIdentity();
121 return;
124 Matrix trans;
125 MatrixStereoPerspective(result, trans, cam->getFov(),
126 width / Real32(height) * cam->getAspect(),
127 cam->getNear(),
128 cam->getFar(),
129 getZeroParallaxDistance(),
130 getEyeSeparation(),
131 getLeftEye() ? 0.f : 1.f,
132 getOverlap());
134 result.mult(trans);
137 void ShearedStereoCameraDecorator::getDecoration(Matrix &result,
138 UInt32 width,
139 UInt32 height)
141 if(width == 0 || height == 0)
143 result.setIdentity();
144 return;
147 Camera *camera = getDecoratee();
149 if(camera == NULL)
151 FWARNING(("TileCameraDecorator::getProjection: no decoratee!\n"));
153 result.setIdentity();
155 return;
158 camera->getDecoration(result, width, height);