Coin  4.0.3
Coin3D core library
Loading...
Searching...
No Matches
SbViewVolume.h
1#ifndef COIN_SBVIEWVOLUME_H
2#define COIN_SBVIEWVOLUME_H
3
4/**************************************************************************\
5 * Copyright (c) Kongsberg Oil & Gas Technologies AS
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
10 * met:
11 *
12 * Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
14 *
15 * Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * Neither the name of the copyright holder nor the names of its
20 * contributors may be used to endorse or promote products derived from
21 * this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34\**************************************************************************/
35
36#include <cstdio>
37
38#include <Inventor/SbBasic.h>
39#include <Inventor/SbVec3f.h>
40#include <Inventor/SbDPViewVolume.h>
41
42class SbBox3f;
43class SbLine;
44class SbMatrix;
45class SbPlane;
46class SbRotation;
47class SbVec2f;
48class SbVec3f;
49
51public:
52 enum ProjectionType { ORTHOGRAPHIC = 0, PERSPECTIVE = 1 };
53
54public:
55 SbViewVolume(void);
56 ~SbViewVolume(void);
57 void getMatrices(SbMatrix& affine, SbMatrix& proj) const;
58 SbMatrix getMatrix(void) const;
59 SbMatrix getCameraSpaceMatrix(void) const;
60 void projectPointToLine(const SbVec2f& pt, SbLine& line) const;
61 void projectPointToLine(const SbVec2f& pt,
62 SbVec3f& line0, SbVec3f& line1) const;
63 void projectToScreen(const SbVec3f& src, SbVec3f& dst) const;
64 SbPlane getPlane(const float distFromEye) const;
65 SbVec3f getSightPoint(const float distFromEye) const;
66 SbVec3f getPlanePoint(const float distFromEye,
67 const SbVec2f& normPoint) const;
68 SbRotation getAlignRotation(SbBool rightAngleOnly = FALSE) const;
69 float getWorldToScreenScale(const SbVec3f& worldCenter,
70 float normRadius) const;
71 SbVec2f projectBox(const SbBox3f& box) const;
72 SbViewVolume narrow(float left, float bottom,
73 float right, float top) const;
74 SbViewVolume narrow(const SbBox3f& box) const;
75 void ortho(float left, float right,
76 float bottom, float top,
77 float nearval, float farval);
78 void perspective(float fovy, float aspect,
79 float nearval, float farval);
80 void frustum(float left, float right,
81 float bottom, float top,
82 float nearval, float farval);
83 void rotateCamera(const SbRotation& q);
84 void translateCamera(const SbVec3f& v);
85 SbVec3f zVector(void) const;
86 SbViewVolume zNarrow(float nearval, float farval) const;
87 void scale(float factor);
88 void scaleWidth(float ratio);
89 void scaleHeight(float ratio);
90 ProjectionType getProjectionType(void) const;
91 const SbVec3f& getProjectionPoint(void) const;
92 const SbVec3f& getProjectionDirection(void) const;
93 float getNearDist(void) const;
94 float getWidth(void) const;
95 float getHeight(void) const;
96 float getDepth(void) const;
97
98 void print(FILE * fp) const;
99 void getViewVolumePlanes(SbPlane planes[6]) const;
100 void transform(const SbMatrix &matrix);
101 SbVec3f getViewUp(void) const;
102
103 SbBool intersect(const SbVec3f & p) const;
104 SbBool intersect(const SbVec3f & p0, const SbVec3f & p1,
105 SbVec3f & closestpoint) const;
106 SbBool intersect(const SbBox3f & box) const;
107 SbBox3f intersectionBox(const SbBox3f & box) const;
108
109 SbBool outsideTest(const SbPlane & p,
110 const SbVec3f & bmin, const SbVec3f & bmax) const;
111 const SbDPViewVolume & getDPViewVolume(void) const;
112
113public:
114 // Warning! It's extremely bad design to keep these data members
115 // public, but we have no choice since this is how it's done in
116 // the original SGI Open Inventor. We've seen example code that
117 // use these variables directly so we'll have to be compatible
118 // here. Please don't use these variables directly unless you're
119 // very sure about what you're doing.
123 float nearDist;
128
129private:
130 void getPlaneRectangle(const float depth, SbVec3f & lowerleft,
132 SbVec3f & upperright) const;
133
134 SbDPViewVolume dpvv;
135};
136
137#endif // !COIN_SBVIEWVOLUME_H
The SbBox3f class is an abstraction for an axis aligned 3 dimensional box.
Definition SbBox3f.h:46
The SbDPViewVolume class is a double precision viewing volume in 3D space.
Definition SbDPViewVolume.h:49
The SbLine class represents a line in 3D space.
Definition SbLine.h:41
The SbList class is a template container class for lists.
Definition SbList.h:70
The SbMatrix class is a 4x4 dimensional representation of a matrix.
Definition SbMatrix.h:47
The SbPlane class represents a plane in 3D space.
Definition SbPlane.h:43
The SbRotation class represents a rotation in 3D space.
Definition SbRotation.h:44
The SbVec2f class is a 2 dimensional vector with floating point coordinates.
Definition SbVec2f.h:49
The SbVec3f class is a 3 dimensional vector with floating point coordinates.
Definition SbVec3f.h:51
The SbViewVolume class is a viewing volume in 3D space.
Definition SbViewVolume.h:50
float nearDist
Definition SbViewVolume.h:123
SbVec3f lrf
Definition SbViewVolume.h:126
SbVec3f projDir
Definition SbViewVolume.h:122
float nearToFar
Definition SbViewVolume.h:124
ProjectionType
Definition SbViewVolume.h:52
ProjectionType type
Definition SbViewVolume.h:120
SbVec3f projPoint
Definition SbViewVolume.h:121
SbVec3f ulf
Definition SbViewVolume.h:127
SbVec3f llf
Definition SbViewVolume.h:125