Coin Logo http://www.sim.no
http://www.coin3d.org

Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions

SoOrthographicCamera Class Reference

The SoOrthographicCamera class defines a camera node with orthographic rendering.Orthographic rendering will not give a particularly realistic impression of the scene, but non-realistic rendering is for various reasons widely used in applications for e.g. Computer Aided Design. More...

#include <Inventor/nodes/SoOrthographicCamera.h>

Inheritance diagram for SoOrthographicCamera:
SoCamera SoNode SoFieldContainer SoBase

List of all members.

Public Member Functions

 SoOrthographicCamera (void)
virtual void scaleHeight (float scalefactor)
virtual SbViewVolume getViewVolume (float useaspectratio=0.0f) const

Static Public Member Functions

static void initClass (void)

Public Attributes

SoSFFloat height

Protected Member Functions

virtual ~SoOrthographicCamera ()
virtual void viewBoundingBox (const SbBox3f &box, float aspect, float slack)

Detailed Description

The SoOrthographicCamera class defines a camera node with orthographic rendering.

Orthographic rendering will not give a particularly realistic impression of the scene, but non-realistic rendering is for various reasons widely used in applications for e.g. Computer Aided Design.

Also, a simple technique for drawing overlay / HUD style graphics (often appearing to be in 2D) can be implemented by setting up a "sub scene graph" with an SoOrthographicCamera and the geometry. As a simple demonstration of this concept, load this file into e.g. the ExaminerViewer:

  #Inventor V2.1 ascii
  
  Separator {
     PerspectiveCamera { position 0 0 5 }
     Cone { }
  
     Separator {
        OrthographicCamera {
           position -0.75 -0.75 2
        }
        BaseColor { rgb 1 1 0 }
        Sphere { radius 0.2 }
     }
  }
  

You will likely encounter Z-buffer issues with this technique which makes the overlay / HUD graphics end up interspersed with the "real" geometry. If so, this can be solved by e.g. inserting an SoCallback node in the sub-scene, where you let the callback disable the depth buffer with glDisable(GL_DEPTH_TEST).

FILE FORMAT/DEFAULTS:

    OrthographicCamera {
        viewportMapping ADJUST_CAMERA
        position 0 0 1
        orientation 0 0 1  0
        nearDistance 1
        farDistance 10
        aspectRatio 1
        focalDistance 5
        height 2
    }

Constructor & Destructor Documentation

SoOrthographicCamera::SoOrthographicCamera ( void  )

Constructor.

References height.

SoOrthographicCamera::~SoOrthographicCamera ( ) [protected, virtual]

Destructor.


Member Function Documentation

void SoOrthographicCamera::initClass ( void  ) [static]

Sets up initialization for data common to all instances of this class, like submitting necessary information to the Coin type system.

Reimplemented from SoCamera.

References SoNode::VRML1.

void SoOrthographicCamera::scaleHeight ( float  scalefactor) [virtual]

Scale SoOrthographicCamera::height by multiplying with scalefactor.

Implements SoCamera.

References height.

SbViewVolume SoOrthographicCamera::getViewVolume ( float  useaspectratio = 0.0f) const [virtual]

Returns total view volume covered by the camera under the current settings.

This view volume is not adjusted to account for viewport mapping. If you want the same view volume as the one used during rendering, you should do something like this:


  SbViewVolume vv;
  float aspectratio = myviewport.getViewportAspectRatio();

  switch (camera->viewportMapping.getValue()) {
  case SoCamera::CROP_VIEWPORT_FILL_FRAME:
  case SoCamera::CROP_VIEWPORT_LINE_FRAME:
  case SoCamera::CROP_VIEWPORT_NO_FRAME:
    vv = camera->getViewVolume(0.0f);
    break;
  case SoCamera::ADJUST_CAMERA:
    vv = camera->getViewVolume(aspectratio);
    if (aspectratio < 1.0f) vv.scale(1.0f / aspectratio);
    break;
  case SoCamera::LEAVE_ALONE:
    vv = camera->getViewVolume(0.0f);
    break;
  default:
    assert(0 && "unknown viewport mapping");
    break;
  }

  

Also, for the CROPPED viewport mappings, the viewport might be changed if the viewport aspect ratio is not equal to the camera aspect ratio. See SoCamera::getView() to see how this is done.

Implements SoCamera.

References SoCamera::aspectRatio, SoCamera::farDistance, height, SoCamera::nearDistance, SoCamera::orientation, SbViewVolume::ortho(), SoCamera::position, SbViewVolume::rotateCamera(), and SbViewVolume::translateCamera().

void SoOrthographicCamera::viewBoundingBox ( const SbBox3f box,
float  aspect,
float  slack 
) [protected, virtual]

Convenience method for setting up the camera definition to cover the given bounding box with the given aspect ratio. Multiplies the exact dimensions with a slack factor to have some space between the rendered model and the borders of the rendering area.

If you define your own camera node class, be aware that this method should not set the orientation field of the camera, only the position, focal distance and near and far clipping planes.

Implements SoCamera.

References SbSphere::circumscribe(), SoCamera::farDistance, SoCamera::focalDistance, SbBox3f::getCenter(), SbSphere::getRadius(), height, SbBox3f::isEmpty(), SbRotation::multVec(), SoCamera::nearDistance, SbVec3f::normalize(), SoCamera::orientation, SoCamera::position, and SoDebugError::postWarning().


Member Data Documentation

Height of viewport in world-space scale. Defaults to 2.0 units.

Referenced by getViewVolume(), scaleHeight(), SoOrthographicCamera(), and viewBoundingBox().


The documentation for this class was generated from the following files:

Copyright © 1998-2007 by Systems in Motion AS. All rights reserved.

Generated on Mon Feb 28 2011 10:12:17 for Coin by Doxygen. 1.7.3