Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

SbViewVolume.h

00001 /**************************************************************************\
00002  *
00003  *  This file is part of the Coin 3D visualization library.
00004  *  Copyright (C) 1998-2002 by Systems in Motion. All rights reserved.
00005  *
00006  *  This library is free software; you can redistribute it and/or
00007  *  modify it under the terms of the GNU Lesser General Public License
00008  *  version 2.1 as published by the Free Software Foundation. See the
00009  *  file LICENSE.LGPL at the root directory of the distribution for
00010  *  more details.
00011  *
00012  *  If you want to use Coin for applications not compatible with the
00013  *  LGPL, please contact SIM to acquire a Professional Edition license.
00014  *
00015  *  Systems in Motion, Prof Brochs gate 6, 7030 Trondheim, NORWAY
00016  *  http://www.sim.no support@sim.no Voice: +47 22114160 Fax: +47 22207097
00017  *
00018 \**************************************************************************/
00019 
00020 #ifndef COIN_SBVIEWVOLUME_H
00021 #define COIN_SBVIEWVOLUME_H
00022 
00023 #include <stdio.h>
00024 
00025 #include <Inventor/SbBasic.h>
00026 #include <Inventor/SbVec3f.h>
00027 
00028 class SbBox3f;
00029 class SbLine;
00030 class SbMatrix;
00031 class SbPlane;
00032 class SbRotation;
00033 class SbVec2f;
00034 class SbVec3f;
00035 
00036 class COIN_DLL_API SbViewVolume {
00037 public:
00038   enum ProjectionType { ORTHOGRAPHIC = 0, PERSPECTIVE = 1 };
00039 
00040 public:
00041   SbViewVolume(void);
00042   ~SbViewVolume(void);
00043   void getMatrices(SbMatrix& affine, SbMatrix& proj) const;
00044   SbMatrix getMatrix(void) const;
00045   SbMatrix getCameraSpaceMatrix(void) const;
00046   void projectPointToLine(const SbVec2f& pt, SbLine& line) const;
00047   void projectPointToLine(const SbVec2f& pt,
00048                           SbVec3f& line0, SbVec3f& line1) const;
00049   void projectToScreen(const SbVec3f& src, SbVec3f& dst) const;
00050   SbPlane getPlane(const float distFromEye) const;
00051   SbVec3f getSightPoint(const float distFromEye) const;
00052   SbVec3f getPlanePoint(const float distFromEye,
00053                         const SbVec2f& normPoint) const;
00054   SbRotation getAlignRotation(SbBool rightAngleOnly = FALSE) const;
00055   float getWorldToScreenScale(const SbVec3f& worldCenter,
00056                               float normRadius) const;
00057   SbVec2f projectBox(const SbBox3f& box) const;
00058   SbViewVolume narrow(float left, float bottom,
00059                       float right, float top) const;
00060   SbViewVolume narrow(const SbBox3f& box) const;
00061   void ortho(float left, float right,
00062              float bottom, float top,
00063              float nearval, float farval);
00064   void perspective(float fovy, float aspect,
00065                    float nearval, float farval);
00066   void rotateCamera(const SbRotation& q);
00067   void translateCamera(const SbVec3f& v);
00068   SbVec3f zVector(void) const;
00069   SbViewVolume zNarrow(float nearval, float farval) const;
00070   void scale(float factor);
00071   void scaleWidth(float ratio);
00072   void scaleHeight(float ratio);
00073   ProjectionType getProjectionType(void) const;
00074   const SbVec3f& getProjectionPoint(void) const;
00075   const SbVec3f& getProjectionDirection(void) const;
00076   float getNearDist(void) const;
00077   float getWidth(void) const;
00078   float getHeight(void) const;
00079   float getDepth(void) const;
00080 
00081   void print(FILE * fp) const;
00082   void getViewVolumePlanes(SbPlane planes[6]) const;
00083   void transform(const SbMatrix &matrix);
00084   SbVec3f getViewUp(void) const;
00085 
00086 public:
00087   // Warning! It's extremely bad design to keep these data members
00088   // public, but we have no choice since this is how it's done in
00089   // the original SGI Open Inventor. We've seen example code that
00090   // use these variables directly so we'll have to be compatible
00091   // here. Please don't use these variables directly unless you're
00092   // very sure about what you're doing.
00093   ProjectionType type;
00094   SbVec3f projPoint;
00095   SbVec3f projDir;
00096   float nearDist;
00097   float nearToFar;
00098   SbVec3f llf;
00099   SbVec3f lrf;
00100   SbVec3f ulf;
00101 
00102 private:
00103 
00104   static SbMatrix getOrthoProjection(const float left, const float right,
00105                                      const float bottom, const float top,
00106                                      const float nearval, const float farval);
00107   static SbMatrix getPerspectiveProjection(const float left, const float right,
00108                                            const float bottom, const float top,
00109                                            const float nearval, const float farval);
00110 
00111   void getPlaneRectangle(const float depth, SbVec3f & lowerleft, 
00112                          SbVec3f & lowerright, SbVec3f & upperleft, 
00113                          SbVec3f & upperright) const;
00114 };
00115 
00116 #endif // !COIN_SBVIEWVOLUME_H

Generated at Tue Mar 5 03:31:11 2002 for Coin by doxygen1.2.9 written by Dimitri van Heesch, © 1997-2001