1 | #ifndef _VisibilityQueryManager_H__
|
---|
2 | #define _VisibilityQueryManager_H__
|
---|
3 |
|
---|
4 | #include <vector>
|
---|
5 |
|
---|
6 | #include "VisibilityInfo.h"
|
---|
7 | #include "VisibilityVector3.h"
|
---|
8 | #include "VisibilityCamera.h"
|
---|
9 | #include "VisibilityRay.h"
|
---|
10 |
|
---|
11 | namespace GtpVisibility {
|
---|
12 |
|
---|
13 | typedef std::vector<OcclusionQuery *> QueryList;
|
---|
14 |
|
---|
15 | /** This abstract class defines interface for a specific visibility query
|
---|
16 | algorithm. The interface supports two from point visibility queries and
|
---|
17 | the ray shooting query. The output of the queries consists of list of
|
---|
18 | visible meshes and hierarchy nodes. The from point queries will be implemented
|
---|
19 | either with item bufferring or based purelly on occlusion queries. Note that
|
---|
20 | the actuall implementation can also exploit the
|
---|
21 | output of the visibility preprocessor.
|
---|
22 | */
|
---|
23 | class QueryManager
|
---|
24 | {
|
---|
25 | public:
|
---|
26 | /** Constructor taking a hierarchy interface as an argument. This allows to operate
|
---|
27 | on different hierarchy types, while reusing the implementation of the query methods.
|
---|
28 | */
|
---|
29 | QueryManager(HierarchyInterface *hierarchyInterface, int queryModes);
|
---|
30 |
|
---|
31 | /**
|
---|
32 | Computes restricted visibility from point by using an explicit camera to execute
|
---|
33 | the visibility query.
|
---|
34 | @param camera The camera to be used
|
---|
35 |
|
---|
36 | @param visibleNodes Pointer to the container where visible nodes should be added.
|
---|
37 | This set is formed of visible leafs or fully visible interior nodes.
|
---|
38 | If NULL no visible nodes are not evaluated.
|
---|
39 |
|
---|
40 | @param visibleGeometry Pointer to the container where visible meshes should be added.
|
---|
41 | If NULL no visible meshes are not evaluated.
|
---|
42 |
|
---|
43 | @param visiblePatches Pointer to the container where visible patches should be added.
|
---|
44 | If NULL no visible meshes are not evaluated.
|
---|
45 |
|
---|
46 | @param relativeVisibility If true the visibility member for
|
---|
47 | NodeInfo and MeshInfo represent relative visibility; i.e. the number of visible
|
---|
48 | pixels divided by the the number of projected pixels.
|
---|
49 |
|
---|
50 | @return true if the corresponding PVS exists.
|
---|
51 | */
|
---|
52 | virtual void
|
---|
53 | ComputeCameraVisibility(const Camera &camera,
|
---|
54 | NodeInfoContainer *visibleNodes,
|
---|
55 | MeshInfoContainer *visibleGeometry,
|
---|
56 | PatchInfoContainer *visiblePatches,
|
---|
57 | const bool relativeVisibility,
|
---|
58 | const bool approximateVisibility
|
---|
59 | ) = 0;
|
---|
60 |
|
---|
61 | /**
|
---|
62 | Uses the specified point to execute the visibility query in all directions.
|
---|
63 | @sa ComputeCameraVisibility()
|
---|
64 | */
|
---|
65 | virtual void
|
---|
66 | ComputeFromPointVisibility(const Vector3 &point,
|
---|
67 | NodeInfoContainer *visibleNodes,
|
---|
68 | MeshInfoContainer *visibleGeometry,
|
---|
69 | PatchInfoContainer *visiblePatches,
|
---|
70 | const bool relativeVisibility,
|
---|
71 | const bool approximateVisibility
|
---|
72 | ) = 0;
|
---|
73 |
|
---|
74 | /**
|
---|
75 | Ray shooting interface: finds an intersection with objects in the scene.
|
---|
76 |
|
---|
77 | @param ray The given input ray (assuming the ray direction is normalized)
|
---|
78 |
|
---|
79 | @param visibleMeshes List of meshes intersecting the ray
|
---|
80 |
|
---|
81 | @param isGlobalLine If false only first intersection with opaque object is returned.
|
---|
82 | Otherwise all intersections of the ray with the scene are found.
|
---|
83 |
|
---|
84 | @return true if there is any intersection.
|
---|
85 | */
|
---|
86 | virtual bool
|
---|
87 | ShootRay(const Ray &ray,
|
---|
88 | std::vector<Mesh *> *visibleMeshes,
|
---|
89 | bool isGlobalLine = false
|
---|
90 | );
|
---|
91 |
|
---|
92 | /** Sets the hierarchy interface.
|
---|
93 | @remark the traversal depends on the type of hierarchyInterface the scene consists of.
|
---|
94 | */
|
---|
95 | void SetHierarchyInterface(HierarchyInterface *hierarchyInterface);
|
---|
96 |
|
---|
97 | enum {PATCH_VISIBILITY = 2,
|
---|
98 | GEOMETRY_VISIBILITY = 4,
|
---|
99 | NODE_VISIBILITY = 8};
|
---|
100 |
|
---|
101 | protected:
|
---|
102 |
|
---|
103 | HierarchyInterface *mHierarchyInterface;
|
---|
104 | int mQueryModes;
|
---|
105 | };
|
---|
106 |
|
---|
107 | };
|
---|
108 |
|
---|
109 | #endif // VisibilityQueryManager
|
---|