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

SbViewVolume.h

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

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

Generated on Mon Feb 28 2011 10:11:53 for Coin by Doxygen. 1.7.3