00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
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
00088
00089
00090
00091
00092
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