Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

vrj::CameraProjection Class Reference

Projection class that simply takes a matrix for the camera position. More...

#include <CameraProjection.h>

Inheritance diagram for vrj::CameraProjection:

Inheritance graph
[legend]
Collaboration diagram for vrj::CameraProjection:

Collaboration graph
[legend]
List of all members.

Public Methods

 CameraProjection ()
virtual void config (jccl::ConfigElementPtr element)
 Configures the projection. More...

void setVerticalFOV (const float fov)
virtual void calcViewMatrix (gmtl::Matrix44f &cameraPos, const float scaleFactor)
 Calculate the viewmatrix and frustum for the camera Calculates a perspective transform for the given settings. More...

virtual std::ostream & outStream (std::ostream &out, const unsigned int indentLevel=0)
 Virtual output oporators. More...


Public Attributes

float mVertFOV

Detailed Description

Projection class that simply takes a matrix for the camera position.

Definition at line 50 of file CameraProjection.h.


Constructor & Destructor Documentation

vrj::CameraProjection::CameraProjection   [inline]
 

Definition at line 53 of file CameraProjection.h.

00053                       : mVertFOV(60.0f)
00054    {
00055       //mType = Projection::SIM;
00056    }


Member Function Documentation

void vrj::CameraProjection::config jccl::ConfigElementPtr    element [virtual]
 

Configures the projection.

Default implementation does nothing.

Reimplemented from vrj::Projection.

Definition at line 49 of file CameraProjection.cpp.

00050 {
00051    Projection::config(element);
00052 }

void vrj::CameraProjection::setVerticalFOV const float    fov [inline]
 

Definition at line 60 of file CameraProjection.h.

00061    {
00062       mVertFOV = fov;
00063    }

void vrj::CameraProjection::calcViewMatrix gmtl::Matrix44f &    cameraPos,
const float    scaleFactor
[virtual]
 

Calculate the viewmatrix and frustum for the camera Calculates a perspective transform for the given settings.

Auto-calculates aspect ratio from the current size of the window and viewport

Implements vrj::Projection.

Definition at line 58 of file CameraProjection.cpp.

References vrj::Projection::getViewport, and mVertFOV.

00059 {
00060    boost::ignore_unused_variable_warning(scaleFactor);
00061    mViewMat = cameraPos;
00062 
00063    gmtl::Vec3f camera_trans = gmtl::makeTrans<gmtl::Vec3f>(cameraPos);
00064    vprDEBUG(vprDBG_ALL, vprDBG_DETAILED_LVL) << "calcView: Cam pos:" << camera_trans << std::endl << vprDEBUG_FLUSH;
00065 
00066    int win_xo, win_yo, win_xs, win_ys;  // origin and size of display window
00067    float vp_xo, vp_yo, vp_xs, vp_ys;  // origin and size of viewport
00068    float width, height;
00069    float aspect_ratio;
00070 
00071    getViewport()->getDisplay()->getOriginAndSize(win_xo,win_yo, win_xs, win_ys);
00072    getViewport()->getOriginAndSize( vp_xo, vp_yo, vp_xs, vp_ys );
00073    width = float(win_xs) * vp_xs;
00074    height = float(win_ys) * vp_ys;
00075 
00076    aspect_ratio = (width/height);
00077 
00078    // Calculate frustum
00079    float top, right;
00080    top = gmtl::Math::tan( gmtl::Math::deg2Rad(mVertFOV/2.0f) ) * mNearDist;     // Calculate the top based on fovy
00081    right = aspect_ratio * top;
00082 
00083    // Calculate the frustum to use for the camera
00084    mFrustum.set(-right, right, -top, top, mNearDist, mFarDist);
00085 }

std::ostream & vrj::CameraProjection::outStream std::ostream &    out,
const unsigned int    indentLevel = 0
[virtual]
 

Virtual output oporators.

Every class derived from us shoudl just define this, and the opertetor<< will "just work".

Reimplemented from vrj::Projection.

Definition at line 87 of file CameraProjection.cpp.

00089 {
00090 //   const int pad_width_dot(20 - indentLevel);
00091    out.setf(std::ios::left);
00092 
00093    const std::string indent_text(indentLevel, ' ');
00094 
00095    out << indent_text << "vrj::CameraProjection:\n";
00096 
00097    return Projection::outStream(out, indentLevel);
00098 }


Member Data Documentation

float vrj::CameraProjection::mVertFOV
 

Definition at line 76 of file CameraProjection.h.

Referenced by calcViewMatrix.


The documentation for this class was generated from the following files:
Generated on Sun May 2 15:11:05 2004 for VR Juggler by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002