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

SbViewVolume.h
1 #ifndef COIN_SBVIEWVOLUME_H
2 #define COIN_SBVIEWVOLUME_H
3 
4 /**************************************************************************\
5  *
6  * This file is part of the Coin 3D visualization library.
7  * Copyright (C) 1998-2007 by Systems in Motion. All rights reserved.
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * ("GPL") version 2 as published by the Free Software Foundation.
12  * See the file LICENSE.GPL at the root directory of this source
13  * distribution for additional information about the GNU GPL.
14  *
15  * For using Coin with software that can not be combined with the GNU
16  * GPL, and for taking advantage of the additional benefits of our
17  * support services, please contact Systems in Motion about acquiring
18  * a Coin Professional Edition License.
19  *
20  * See http://www.coin3d.org/ for more information.
21  *
22  * Systems in Motion, Postboks 1283, Pirsenteret, 7462 Trondheim, NORWAY.
23  * http://www.sim.no/ sales@sim.no coin-support@coin3d.org
24  *
25 \**************************************************************************/
26 
27 #include <stdio.h>
28 
29 #include <Inventor/SbBasic.h>
30 #include <Inventor/SbVec3f.h>
31 #include <Inventor/SbDPViewVolume.h>
32 
33 class SbBox3f;
34 class SbLine;
35 class SbMatrix;
36 class SbPlane;
37 class SbRotation;
38 class SbVec2f;
39 class SbVec3f;
40 
41 class COIN_DLL_API SbViewVolume {
42 public:
43  enum ProjectionType { ORTHOGRAPHIC = 0, PERSPECTIVE = 1 };
44 
45 public:
46  SbViewVolume(void);
47  ~SbViewVolume(void);
48  void getMatrices(SbMatrix& affine, SbMatrix& proj) const;
49  SbMatrix getMatrix(void) const;
50  SbMatrix getCameraSpaceMatrix(void) const;
51  void projectPointToLine(const SbVec2f& pt, SbLine& line) const;
52  void projectPointToLine(const SbVec2f& pt,
53  SbVec3f& line0, SbVec3f& line1) const;
54  void projectToScreen(const SbVec3f& src, SbVec3f& dst) const;
55  SbPlane getPlane(const float distFromEye) const;
56  SbVec3f getSightPoint(const float distFromEye) const;
57  SbVec3f getPlanePoint(const float distFromEye,
58  const SbVec2f& normPoint) const;
59  SbRotation getAlignRotation(SbBool rightAngleOnly = FALSE) const;
60  float getWorldToScreenScale(const SbVec3f& worldCenter,
61  float normRadius) const;
62  SbVec2f projectBox(const SbBox3f& box) const;
63  SbViewVolume narrow(float left, float bottom,
64  float right, float top) const;
65  SbViewVolume narrow(const SbBox3f& box) const;
66  void ortho(float left, float right,
67  float bottom, float top,
68  float nearval, float farval);
69  void perspective(float fovy, float aspect,
70  float nearval, float farval);
71  void frustum(float left, float right,
72  float bottom, float top,
73  float nearval, float farval);
74  void rotateCamera(const SbRotation& q);
75  void translateCamera(const SbVec3f& v);
76  SbVec3f zVector(void) const;
77  SbViewVolume zNarrow(float nearval, float farval) const;
78  void scale(float factor);
79  void scaleWidth(float ratio);
80  void scaleHeight(float ratio);
81  ProjectionType getProjectionType(void) const;
82  const SbVec3f& getProjectionPoint(void) const;
83  const SbVec3f& getProjectionDirection(void) const;
84  float getNearDist(void) const;
85  float getWidth(void) const;
86  float getHeight(void) const;
87  float getDepth(void) const;
88 
89  void print(FILE * fp) const;
90  void getViewVolumePlanes(SbPlane planes[6]) const;
91  void transform(const SbMatrix &matrix);
92  SbVec3f getViewUp(void) const;
93 
94  SbBool intersect(const SbVec3f & p) const;
95  SbBool intersect(const SbVec3f & p0, const SbVec3f & p1,
96  SbVec3f & closestpoint) const;
97  SbBool intersect(const SbBox3f & box) const;
98 
99  SbBool outsideTest(const SbPlane & p,
100  const SbVec3f & bmin, const SbVec3f & bmax) const;
101 
102 public:
103  // Warning! It's extremely bad design to keep these data members
104  // public, but we have no choice since this is how it's done in
105  // the original SGI Open Inventor. We've seen example code that
106  // use these variables directly so we'll have to be compatible
107  // here. Please don't use these variables directly unless you're
108  // very sure about what you're doing.
112  float nearDist;
113  float nearToFar;
117 
118 private:
119 
120  SbDPViewVolume dpvv;
121 };
122 
123 #endif // !COIN_SBVIEWVOLUME_H
The SbVec2f class is a 2 dimensional vector with floating point coordinates.
Definition: SbVec2f.h:36
The SbBox3f class is an abstraction for an axis aligned 3 dimensional box.This box abstraction class ...
Definition: SbBox3f.h:37
SbVec3f ulf
Definition: SbViewVolume.h:116
SbVec3f projPoint
Definition: SbViewVolume.h:110
SbVec3f llf
Definition: SbViewVolume.h:114
The SbRotation class represents a rotation in 3D space.SbRotation is used extensively throughout the ...
Definition: SbRotation.h:33
SbVec3f projDir
Definition: SbViewVolume.h:111
The SbVec3f class is a 3 dimensional vector with floating point coordinates.
Definition: SbVec3f.h:37
ProjectionType
Definition: SbViewVolume.h:43
The SbLine class represents a line in 3D space.SbLine provides a way of specifying a directed line...
Definition: SbLine.h:32
The SbMatrix class is a 4x4 dimensional representation of a matrix.SbMatrix is used by many other cla...
Definition: SbMatrix.h:37
ProjectionType type
Definition: SbViewVolume.h:109
float nearDist
Definition: SbViewVolume.h:112
The SbViewVolume class is a viewing volume in 3D space.This class contains the necessary information ...
Definition: SbViewVolume.h:41
The SbPlane class represents a plane in 3D space.SbPlane is used by many other classes in Coin...
Definition: SbPlane.h:34
SbVec3f lrf
Definition: SbViewVolume.h:115
float nearToFar
Definition: SbViewVolume.h:113

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

Generated on Fri Feb 17 2017 for Coin by Doxygen. 1.8.13