Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

osg::MatrixCameraBase Class Reference

MatrixCamera Base Class.

#include <OSGMatrixCameraBase.h>

Inheritance diagram for osg::MatrixCameraBase:

osg::Camera osg::CameraBase osg::AttachmentContainer osg::FieldContainer osg::MatrixCamera List of all members.

Setup Rendering

*virtual void setup (DrawActionBase *action, const Viewport &port)
virtual void setupProjection (DrawActionBase *action, const Viewport &port)
virtual void draw (DrawAction *action, const Viewport &port)

Access Parameters

*virtual void getProjection (Matrix &result, UInt32 width, UInt32 height)
virtual void getProjectionTranslation (Matrix &result, UInt32 width, UInt32 height)
virtual void getViewing (Matrix &result, UInt32 width, UInt32 height)
virtual void getFrustum (FrustumVolume &result, const Viewport &port)
virtual void getWorldToScreen (Matrix &result, const Viewport &port)

Public Types

typedef MatrixCameraPtr Ptr
enum  { ProjectionMatrixFieldId = Inherited::NextFieldId, ModelviewMatrixFieldId = ProjectionMatrixFieldId + 1, NextFieldId = ModelviewMatrixFieldId + 1 }

Public Member Functions

FieldContainer Get
*virtual FieldContainerTypegetType (void)
virtual const FieldContainerTypegetType (void) const
virtual UInt32 getContainerSize (void) const
Field Get
*SFMatrixgetSFProjectionMatrix (void)
 Get the MatrixCamera::_sfProjectionMatrix field.
SFMatrixgetSFModelviewMatrix (void)
 Get the MatrixCamera::_sfModelviewMatrix field.
MatrixgetProjectionMatrix (void)
 Get the value of the MatrixCamera::_sfProjectionMatrix field.
const MatrixgetProjectionMatrix (void) const
 Get the value of the MatrixCamera::_sfProjectionMatrix field.
MatrixgetModelviewMatrix (void)
 Get the value of the MatrixCamera::_sfModelviewMatrix field.
const MatrixgetModelviewMatrix (void) const
 Get the value of the MatrixCamera::_sfModelviewMatrix field.
Field Set
*void setProjectionMatrix (const Matrix &value)
 Set the value of the MatrixCamera::_sfProjectionMatrix field.
void setModelviewMatrix (const Matrix &value)
 Set the value of the MatrixCamera::_sfModelviewMatrix field.
Binary Access
*virtual UInt32 getBinSize (const BitVector &whichField)
virtual void copyToBin (BinaryDataHandler &pMem, const BitVector &whichField)
virtual void copyFromBin (BinaryDataHandler &pMem, const BitVector &whichField)
Copy
*virtual FieldContainerPtr shallowCopy (void) const

Static Public Member Functions

Class Get
*static FieldContainerTypegetClassType (void)
 access the type of the class
static UInt32 getClassTypeId (void)
 access the numerical type of the class
Construction
*static MatrixCameraPtr create (void)
 create a new instance of the class
static MatrixCameraPtr createEmpty (void)
 create an empty new instance of the class, do not copy the prototype

Static Public Attributes

static const osg::BitVector ProjectionMatrixFieldMask
static const osg::BitVector ModelviewMatrixFieldMask
static const osg::BitVector MTInfluenceMask
static const osg::BitVector BeaconFieldMask
static const osg::BitVector NearFieldMask
static const osg::BitVector FarFieldMask
static const BitVector AttachmentsFieldMask
static const BitVector NextFieldMask

Protected Member Functions

Constructors
MatrixCameraBase (void)
 MatrixCameraBase (const MatrixCameraBase &source)
Destructors
*virtual ~MatrixCameraBase (void)
Sync
*void executeSyncImpl (MatrixCameraBase *pOther, const BitVector &whichField)
virtual void executeSync (FieldContainer &other, const BitVector &whichField)

Protected Attributes

Fields
*SFMatrix _sfProjectionMatrix
SFMatrix _sfModelviewMatrix

Private Types

typedef Camera Inherited

Private Member Functions

void operator= (const MatrixCameraBase &source)

Static Private Attributes

static FieldDescription_desc []
 MatrixCamera description.
static FieldContainerType _type

Friends

class FieldContainer

Detailed Description

Definition at line 82 of file OSGMatrixCameraBase.h.


Member Typedef Documentation

typedef Camera osg::MatrixCameraBase::Inherited [private]
 

Reimplemented from osg::Camera.

Reimplemented in osg::MatrixCamera.

Definition at line 86 of file OSGMatrixCameraBase.h.

typedef MatrixCameraPtr osg::MatrixCameraBase::Ptr
 

Reimplemented from osg::CameraBase.

Definition at line 91 of file OSGMatrixCameraBase.h.


Member Enumeration Documentation

anonymous enum
 

Enumerator:
ProjectionMatrixFieldId 
ModelviewMatrixFieldId 
NextFieldId 

Reimplemented from osg::CameraBase.

Definition at line 93 of file OSGMatrixCameraBase.h.

00094     {
00095         ProjectionMatrixFieldId = Inherited::NextFieldId,
00096         ModelviewMatrixFieldId  = ProjectionMatrixFieldId + 1,
00097         NextFieldId             = ModelviewMatrixFieldId  + 1
00098     };


Constructor & Destructor Documentation

MatrixCameraBase::MatrixCameraBase void   )  [protected]
 

Definition at line 175 of file OSGMatrixCameraBase.cpp.

00175                                        :
00176     _sfProjectionMatrix       (), 
00177     _sfModelviewMatrix        (), 
00178     Inherited() 
00179 {
00180 }

MatrixCameraBase::MatrixCameraBase const MatrixCameraBase source  )  [protected]
 

Definition at line 186 of file OSGMatrixCameraBase.cpp.

00186                                                                  :
00187     _sfProjectionMatrix       (source._sfProjectionMatrix       ), 
00188     _sfModelviewMatrix        (source._sfModelviewMatrix        ), 
00189     Inherited                 (source)
00190 {
00191 }

MatrixCameraBase::~MatrixCameraBase void   )  [protected, virtual]
 

Definition at line 195 of file OSGMatrixCameraBase.cpp.

00196 {
00197 }


Member Function Documentation

osg::FieldContainerType & osg::MatrixCameraBase::getClassType void   )  [inline, static]
 

Reimplemented from osg::CameraBase.

Definition at line 58 of file OSGMatrixCameraBase.inl.

References _type.

Referenced by create().

00059 {
00060     return _type; 
00061 } 

osg::UInt32 osg::MatrixCameraBase::getClassTypeId void   )  [inline, static]
 

Reimplemented from osg::CameraBase.

Definition at line 65 of file OSGMatrixCameraBase.inl.

References _type, and osg::TypeBase::getId().

00066 {
00067     return _type.getId(); 
00068 } 

FieldContainerType & MatrixCameraBase::getType void   )  [virtual]
 

Reimplemented from osg::CameraBase.

Definition at line 117 of file OSGMatrixCameraBase.cpp.

References _type.

00118 {
00119     return _type; 
00120 } 

const FieldContainerType & MatrixCameraBase::getType void   )  const [virtual]
 

Reimplemented from osg::CameraBase.

Definition at line 122 of file OSGMatrixCameraBase.cpp.

References _type.

00123 {
00124     return _type;
00125 } 

UInt32 MatrixCameraBase::getContainerSize void   )  const [virtual]
 

Reimplemented from osg::CameraBase.

Definition at line 137 of file OSGMatrixCameraBase.cpp.

00138 { 
00139     return sizeof(MatrixCamera); 
00140 }

SFMatrix * osg::MatrixCameraBase::getSFProjectionMatrix void   )  [inline]
 

Definition at line 101 of file OSGMatrixCameraBase.inl.

References _sfProjectionMatrix.

00102 {
00103     return &_sfProjectionMatrix;
00104 }

SFMatrix * osg::MatrixCameraBase::getSFModelviewMatrix void   )  [inline]
 

Definition at line 108 of file OSGMatrixCameraBase.inl.

References _sfModelviewMatrix.

00109 {
00110     return &_sfModelviewMatrix;
00111 }

Matrix & osg::MatrixCameraBase::getProjectionMatrix void   )  [inline]
 

Definition at line 116 of file OSGMatrixCameraBase.inl.

References _sfProjectionMatrix, and osg::SField< FieldTypeT, fieldNameSpace >::getValue().

Referenced by osg::MatrixCamera::getProjection().

00117 {
00118     return _sfProjectionMatrix.getValue();
00119 }

const Matrix & osg::MatrixCameraBase::getProjectionMatrix void   )  const [inline]
 

Definition at line 123 of file OSGMatrixCameraBase.inl.

References _sfProjectionMatrix, and osg::SField< FieldTypeT, fieldNameSpace >::getValue().

00124 {
00125     return _sfProjectionMatrix.getValue();
00126 }

Matrix & osg::MatrixCameraBase::getModelviewMatrix void   )  [inline]
 

Definition at line 137 of file OSGMatrixCameraBase.inl.

References _sfModelviewMatrix, and osg::SField< FieldTypeT, fieldNameSpace >::getValue().

Referenced by osg::MatrixCamera::getViewing().

00138 {
00139     return _sfModelviewMatrix.getValue();
00140 }

const Matrix & osg::MatrixCameraBase::getModelviewMatrix void   )  const [inline]
 

Definition at line 144 of file OSGMatrixCameraBase.inl.

References _sfModelviewMatrix, and osg::SField< FieldTypeT, fieldNameSpace >::getValue().

00145 {
00146     return _sfModelviewMatrix.getValue();
00147 }

void osg::MatrixCameraBase::setProjectionMatrix const Matrix value  )  [inline]
 

Definition at line 130 of file OSGMatrixCameraBase.inl.

References _sfProjectionMatrix, and osg::SField< FieldTypeT, fieldNameSpace >::setValue().

00131 {
00132     _sfProjectionMatrix.setValue(value);
00133 }

void osg::MatrixCameraBase::setModelviewMatrix const Matrix value  )  [inline]
 

Definition at line 151 of file OSGMatrixCameraBase.inl.

References _sfModelviewMatrix, and osg::SField< FieldTypeT, fieldNameSpace >::setValue().

00152 {
00153     _sfModelviewMatrix.setValue(value);
00154 }

UInt32 MatrixCameraBase::getBinSize const BitVector whichField  )  [virtual]
 

Reimplemented from osg::CameraBase.

Definition at line 201 of file OSGMatrixCameraBase.cpp.

References _sfModelviewMatrix, _sfProjectionMatrix, osg::SField< FieldTypeT, fieldNameSpace >::getBinSize(), osg::CameraBase::getBinSize(), ModelviewMatrixFieldMask, osg::FieldBits::NoField, and ProjectionMatrixFieldMask.

00202 {
00203     UInt32 returnValue = Inherited::getBinSize(whichField);
00204 
00205     if(FieldBits::NoField != (ProjectionMatrixFieldMask & whichField))
00206     {
00207         returnValue += _sfProjectionMatrix.getBinSize();
00208     }
00209 
00210     if(FieldBits::NoField != (ModelviewMatrixFieldMask & whichField))
00211     {
00212         returnValue += _sfModelviewMatrix.getBinSize();
00213     }
00214 
00215 
00216     return returnValue;
00217 }

void MatrixCameraBase::copyToBin BinaryDataHandler pMem,
const BitVector whichField
[virtual]
 

Reimplemented from osg::CameraBase.

Definition at line 219 of file OSGMatrixCameraBase.cpp.

References _sfModelviewMatrix, _sfProjectionMatrix, osg::SField< FieldTypeT, fieldNameSpace >::copyToBin(), osg::CameraBase::copyToBin(), ModelviewMatrixFieldMask, osg::FieldBits::NoField, and ProjectionMatrixFieldMask.

00221 {
00222     Inherited::copyToBin(pMem, whichField);
00223 
00224     if(FieldBits::NoField != (ProjectionMatrixFieldMask & whichField))
00225     {
00226         _sfProjectionMatrix.copyToBin(pMem);
00227     }
00228 
00229     if(FieldBits::NoField != (ModelviewMatrixFieldMask & whichField))
00230     {
00231         _sfModelviewMatrix.copyToBin(pMem);
00232     }
00233 
00234 
00235 }

void MatrixCameraBase::copyFromBin BinaryDataHandler pMem,
const BitVector whichField
[virtual]
 

Reimplemented from osg::CameraBase.

Definition at line 237 of file OSGMatrixCameraBase.cpp.

References _sfModelviewMatrix, _sfProjectionMatrix, osg::SField< FieldTypeT, fieldNameSpace >::copyFromBin(), osg::CameraBase::copyFromBin(), ModelviewMatrixFieldMask, osg::FieldBits::NoField, and ProjectionMatrixFieldMask.

00239 {
00240     Inherited::copyFromBin(pMem, whichField);
00241 
00242     if(FieldBits::NoField != (ProjectionMatrixFieldMask & whichField))
00243     {
00244         _sfProjectionMatrix.copyFromBin(pMem);
00245     }
00246 
00247     if(FieldBits::NoField != (ModelviewMatrixFieldMask & whichField))
00248     {
00249         _sfModelviewMatrix.copyFromBin(pMem);
00250     }
00251 
00252 
00253 }

MatrixCameraPtr osg::MatrixCameraBase::create void   )  [inline, static]
 

Definition at line 72 of file OSGMatrixCameraBase.inl.

References osg::AttachmentContainerPtr::dcast(), getClassType(), osg::FieldContainerType::getPrototype(), osg::NullFC, and shallowCopy().

Referenced by osg::DisplayCalibration::createCMViewports().

00073 {
00074     MatrixCameraPtr fc; 
00075 
00076     if(getClassType().getPrototype() != OSG::NullFC) 
00077     {
00078         fc = MatrixCameraPtr::dcast(
00079             getClassType().getPrototype()-> shallowCopy()); 
00080     }
00081     
00082     return fc; 
00083 }

MatrixCameraPtr osg::MatrixCameraBase::createEmpty void   )  [inline, static]
 

Definition at line 87 of file OSGMatrixCameraBase.inl.

References osg::FieldContainer::newPtr().

00088 { 
00089     MatrixCameraPtr returnValue; 
00090     
00091     newPtr(returnValue); 
00092 
00093     return returnValue; 
00094 }

FieldContainerPtr MatrixCameraBase::shallowCopy void   )  const [virtual]
 

Implements osg::FieldContainer.

Definition at line 128 of file OSGMatrixCameraBase.cpp.

References osg::FieldContainer::newPtr().

Referenced by create().

00129 { 
00130     MatrixCameraPtr returnValue; 
00131 
00132     newPtr(returnValue, dynamic_cast<const MatrixCamera *>(this)); 
00133 
00134     return returnValue; 
00135 }

void MatrixCameraBase::executeSyncImpl MatrixCameraBase pOther,
const BitVector whichField
[protected]
 

Definition at line 256 of file OSGMatrixCameraBase.cpp.

References _sfModelviewMatrix, _sfProjectionMatrix, osg::CameraBase::executeSyncImpl(), ModelviewMatrixFieldMask, osg::FieldBits::NoField, ProjectionMatrixFieldMask, and osg::SField< FieldTypeT, fieldNameSpace >::syncWith().

Referenced by executeSync().

00258 {
00259 
00260     Inherited::executeSyncImpl(pOther, whichField);
00261 
00262     if(FieldBits::NoField != (ProjectionMatrixFieldMask & whichField))
00263         _sfProjectionMatrix.syncWith(pOther->_sfProjectionMatrix);
00264 
00265     if(FieldBits::NoField != (ModelviewMatrixFieldMask & whichField))
00266         _sfModelviewMatrix.syncWith(pOther->_sfModelviewMatrix);
00267 
00268 
00269 }

void MatrixCameraBase::executeSync FieldContainer other,
const BitVector whichField
[protected, virtual]
 

Reimplemented from osg::CameraBase.

Definition at line 144 of file OSGMatrixCameraBase.cpp.

References executeSyncImpl().

00146 {
00147     this->executeSyncImpl((MatrixCameraBase *) &other, whichField);
00148 }

void osg::MatrixCameraBase::operator= const MatrixCameraBase source  )  [private]
 

* static const char* osg::Camera::getClassname void   )  [inline, static, inherited]
 

Reimplemented in osg::MatrixCamera, osg::OffCenterPerspectiveCamera, osg::PerspectiveCamera, and osg::TileCameraDecorator.

Definition at line 73 of file OSGCamera.h.

00073 { return "Camera"; };

void Camera::changed BitVector  whichField,
UInt32  origin
[virtual, inherited]
 

Reimplemented from osg::AttachmentContainer.

Reimplemented in osg::CameraDecorator, osg::MatrixCamera, osg::MatrixCameraDecorator, osg::OffCenterPerspectiveCamera, osg::PerspectiveCamera, osg::ProjectionCameraDecorator, osg::ShearedStereoCameraDecorator, osg::StereoCameraDecorator, and osg::TileCameraDecorator.

Definition at line 98 of file OSGCamera.cpp.

References osg::AttachmentContainer::changed().

Referenced by osg::PerspectiveCamera::changed(), osg::MatrixCamera::changed(), and osg::CameraDecorator::changed().

00099 {
00100     Inherited::changed(whichField, origin);
00101 }

void Camera::setup DrawActionBase action,
const Viewport port
[virtual, inherited]
 

Setup OpenGL for rendering, call all the necessary commands to start rendering with this camera.

Definition at line 109 of file OSGCamera.cpp.

References osg::Viewport::getPixelHeight(), osg::Viewport::getPixelWidth(), osg::Camera::getProjection(), osg::Camera::getProjectionTranslation(), osg::TransformationMatrix< ValueTypeT >::getValues(), osg::Camera::getViewing(), and osg::TransformationMatrix< ValueTypeT >::mult().

00111 {
00112     Matrix m, t;
00113 
00114     // set the projection
00115 
00116     getProjection           ( m, port.getPixelWidth(), port.getPixelHeight() );
00117     getProjectionTranslation( t, port.getPixelWidth(), port.getPixelHeight() );
00118 
00119     m.mult(t);
00120 
00121     //SDEBUG << "Projection matrix: " << m << std::endl;
00122 
00123     glMatrixMode( GL_PROJECTION );
00124     glLoadMatrixf( m.getValues() );
00125 
00126     // set the viewing
00127 
00128     getViewing( m, port.getPixelWidth(), port.getPixelHeight() );
00129 
00130     //SDEBUG << "Viewing matrix: " << m << std::endl;
00131     
00132     glMatrixMode( GL_MODELVIEW );
00133     glLoadMatrixf( m.getValues() );
00134 }

void Camera::setupProjection DrawActionBase action,
const Viewport port
[virtual, inherited]
 

Setup OpenGL projection for rendering.

Definition at line 138 of file OSGCamera.cpp.

References osg::Viewport::getPixelHeight(), osg::Viewport::getPixelWidth(), osg::Camera::getProjection(), osg::Camera::getProjectionTranslation(), osg::TransformationMatrix< ValueTypeT >::getValues(), and osg::TransformationMatrix< ValueTypeT >::mult().

Referenced by osg::RenderAction::start().

00140 {
00141     Matrix m, t;
00142 
00143     // set the projection
00144 
00145     getProjection           ( m, port.getPixelWidth(), port.getPixelHeight() );
00146     getProjectionTranslation( t, port.getPixelWidth(), port.getPixelHeight() );
00147 
00148     m.mult(t);
00149 
00150     //SDEBUG << "Projection matrix: " << m << std::endl;
00151 
00152     glMatrixMode( GL_PROJECTION );
00153     glLoadMatrixf( m.getValues() );
00154 }

void Camera::draw DrawAction action,
const Viewport port
[virtual, inherited]
 

Draw the camera's geometry (if any). Usually there is none.

Reimplemented in osg::CameraDecorator, osg::MatrixCamera, osg::OffCenterPerspectiveCamera, and osg::PerspectiveCamera.

Definition at line 158 of file OSGCamera.cpp.

00160 {
00161 }

void Camera::getProjection Matrix result,
UInt32  width,
UInt32  height
[virtual, inherited]
 

Get/calculate the projection matrix for this camera.

Reimplemented in osg::CameraDecorator, osg::MatrixCamera, osg::MatrixCameraDecorator, osg::OffCenterPerspectiveCamera, osg::PerspectiveCamera, osg::ProjectionCameraDecorator, osg::ShearedStereoCameraDecorator, and osg::TileCameraDecorator.

Definition at line 165 of file OSGCamera.cpp.

References SFATAL.

Referenced by osg::Camera::calcViewRay(), osg::SkyBackground::clear(), osg::DVRIsoShader::getCoveredScreenRect(), osg::Camera::getFrustum(), osg::Camera::getWorldToScreen(), osg::Camera::setup(), and osg::Camera::setupProjection().

00168 {
00169     SFATAL << "Camera::getProjection: NIY" << std::endl;
00170     abort();
00171 }

void Camera::getProjectionTranslation Matrix result,
UInt32  width,
UInt32  height
[virtual, inherited]
 

Get/calculate the projection translation matrix for this camera. The default is identity.

Reimplemented in osg::CameraDecorator, osg::MatrixCameraDecorator, and osg::ProjectionCameraDecorator.

Definition at line 176 of file OSGCamera.cpp.

References osg::TransformationMatrix< ValueTypeT >::setIdentity().

Referenced by osg::Camera::calcViewRay(), osg::SkyBackground::clear(), osg::DVRIsoShader::getCoveredScreenRect(), osg::Camera::getFrustum(), osg::Camera::getWorldToScreen(), osg::Camera::setup(), and osg::Camera::setupProjection().

00179 {
00180     result.setIdentity();
00181 }

void Camera::getViewing Matrix result,
UInt32  width,
UInt32  height
[virtual, inherited]
 

Get/calculate the viewing matrix for this camera. This is the inverse of the beacon's toWorld transformation.

Reimplemented in osg::CameraDecorator, osg::MatrixCamera, osg::MatrixCameraDecorator, and osg::ProjectionCameraDecorator.

Definition at line 186 of file OSGCamera.cpp.

References osg::CameraBase::getBeacon(), osg::TransformationMatrix< ValueTypeT >::invert(), osg::NullFC, and SWARNING.

Referenced by osg::TextureTransformChunk::activate(), osg::TexGenChunk::activate(), osg::Camera::calcViewRay(), osg::TextureTransformChunk::changeFrom(), osg::TexGenChunk::changeFrom(), osg::SkyBackground::clear(), osg::Camera::getFrustum(), osg::Camera::getWorldToScreen(), osg::Camera::setup(), osg::RenderAction::start(), osg::DrawActionBase::start(), osg::SHLChunk::updateCameraOrientation(), osg::SHLChunk::updateCameraPosition(), osg::SHLChunk::updateInvViewMatrix(), and osg::SHLChunk::updateViewMatrix().

00189 {
00190     if (getBeacon() == NullFC)
00191     {
00192         SWARNING << "Camera::setup: no beacon!" << std::endl;
00193         return;
00194     }   
00195 
00196     getBeacon()->getToWorld(result);  
00197     result.invert();
00198 }

void Camera::getFrustum FrustumVolume result,
const Viewport p
[virtual, inherited]
 

Calculate the frustum of this camera's visible area.

Definition at line 202 of file OSGCamera.cpp.

References osg::Viewport::getPixelHeight(), osg::Viewport::getPixelWidth(), osg::Camera::getProjection(), osg::Camera::getProjectionTranslation(), osg::Camera::getViewing(), osg::TransformationMatrix< ValueTypeT >::mult(), and osg::FrustumVolume::setPlanes().

Referenced by osg::DrawActionBase::start().

00203 {
00204     Matrix mv,prt,pr;
00205     
00206     getProjection           (pr , p.getPixelWidth(), p.getPixelHeight());
00207     getProjectionTranslation(prt, p.getPixelWidth(), p.getPixelHeight());
00208     getViewing              (mv , p.getPixelWidth(), p.getPixelHeight());
00209 
00210     pr.mult(prt);
00211     pr.mult(mv );
00212     
00213     result.setPlanes(pr);
00214 }

void Camera::getWorldToScreen Matrix result,
const Viewport p
[virtual, inherited]
 

Calculate the matrix that transforms world coordinates into the screen coordinate system for this camera.

Definition at line 219 of file OSGCamera.cpp.

References osg::Viewport::getPixelHeight(), osg::Viewport::getPixelWidth(), osg::Camera::getProjection(), osg::Camera::getProjectionTranslation(), osg::Camera::getViewing(), and osg::TransformationMatrix< ValueTypeT >::mult().

00220 {
00221     Matrix mv,prt,pr;
00222     
00223     getProjection           (result, p.getPixelWidth(), p.getPixelHeight());
00224     getProjectionTranslation(prt   , p.getPixelWidth(), p.getPixelHeight());
00225     getViewing              (mv    , p.getPixelWidth(), p.getPixelHeight());
00226 
00227     result.mult(prt);
00228     result.mult(mv );
00229 }

bool Camera::calcViewRay Line line,
Int32  x,
Int32  y,
const Viewport port
[inherited]
 

Calculate a ray that starts at the camera position and goes through the pixel x, y in the viewport port. x and y are relative to the viewport's lower left corner.

Definition at line 235 of file OSGCamera.cpp.

References osg::ViewportBase::getParent(), osg::Viewport::getPixelHeight(), osg::Viewport::getPixelLeft(), osg::Viewport::getPixelTop(), osg::Viewport::getPixelWidth(), osg::Camera::getProjection(), osg::Camera::getProjectionTranslation(), osg::Camera::getViewing(), osg::TransformationMatrix< ValueTypeT >::invert(), osg::TransformationMatrix< ValueTypeT >::invertFrom(), osg::TransformationMatrix< ValueTypeT >::mult(), osg::TransformationMatrix< ValueTypeT >::multFullMatrixPnt(), and osg::Line::setValue().

00236 {
00237     if(port.getPixelWidth() <= 0 || port.getPixelHeight() <= 0)
00238     {
00239         return false;
00240     }
00241     
00242     Matrix proj, projtrans, view;
00243 
00244     getProjection(proj, port.getPixelWidth(), port.getPixelHeight());
00245     getProjectionTranslation(projtrans, port.getPixelWidth(), 
00246                                 port.getPixelHeight());
00247     getViewing(view, port.getPixelWidth(), port.getPixelHeight());
00248     
00249     Matrix wctocc = proj;
00250     wctocc.mult(projtrans);
00251     wctocc.mult(view);
00252 
00253     Matrix cctowc;
00254     cctowc.invertFrom(wctocc);
00255        
00256     Real32  rx = (x - port.getPixelLeft()) / (Real32) port.getPixelWidth()
00257                     * 2.f - 1.f,
00258             ry = 1.f - ((y - (port.getParent()->getHeight() - 
00259                               port.getPixelTop())
00260                         ) / 
00261                         (Real32) port.getPixelHeight()
00262                        ) * 2.f;
00263     
00264     view.invert();
00265     Pnt3f from(view[3][0], view[3][1], view[3][2]);
00266             
00267     Pnt3f at;
00268     cctowc.multFullMatrixPnt(Pnt3f(rx, ry, 1), at);
00269     
00270     line.setValue(from, at-from);
00271     
00272     return true;
00273 }

void Camera::dump UInt32  uiIndent = 0,
const BitVector  bvFlags = 0
const [virtual, inherited]
 

Reimplemented from osg::AttachmentContainer.

Reimplemented in osg::CameraDecorator, osg::MatrixCamera, osg::MatrixCameraDecorator, osg::OffCenterPerspectiveCamera, osg::PerspectiveCamera, osg::ProjectionCameraDecorator, osg::ShearedStereoCameraDecorator, osg::StereoCameraDecorator, and osg::TileCameraDecorator.

Definition at line 277 of file