GtePicker.h
Go to the documentation of this file.
1 // David Eberly, Geometric Tools, Redmond WA 98052
2 // Copyright (c) 1998-2017
3 // Distributed under the Boost Software License, Version 1.0.
4 // http://www.boost.org/LICENSE_1_0.txt
5 // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
6 // File Version: 3.0.0 (2016/06/19)
7 
8 #pragma once
9 
10 #include <Mathematics/GteLine.h>
11 #include <Graphics/GteNode.h>
12 #include <Graphics/GtePickRecord.h>
13 #include <Graphics/GteVisual.h>
14 
15 namespace gte
16 {
17 
19 {
20 public:
21  // Construction and destruction.
22  ~Picker();
23  Picker();
24 
25  // Set the maximum distance when the 'scene' contains point or segment
26  // primitives. Such primitives are selected when they are within the
27  // specified distance of the pick line. The default is 0.0f.
28  void SetMaxDistance(float maxDistance);
29  float GetMaxDistance() const;
30 
31  // The linear component is parameterized by P + t*D, where P is a point on
32  // the component (the origin) and D is a unit-length direction vector.
33  // Both P and D must be in world coordinates. The interval [tmin,tmax] is
34  // line: tmin = -fmax, tmax = fmax
35  // ray: tmin = 0, tmax = fmax
36  // segment: tmin = 0, tmax > 0;
37  // where fmax is std::numeric_limits<float>::max(). A call to this
38  // function will automatically clear the 'records' array. If you need any
39  // information from this array obtained by a previous call to Execute, you
40  // must save it first.
41  void operator()(std::shared_ptr<Spatial> const& scene,
42  Vector4<float> const& origin, Vector4<float> const& direction,
43  float tmin, float tmax);
44 
45  // The following three functions return the record satisfying the
46  // constraints. They should be called only when records.size() > 0.
47 
48  // Locate the record whose t-value is smallest in absolute value.
49  PickRecord const& GetClosestToZero() const;
50 
51  // Locate the record with nonnegative t-value closest to zero.
52  PickRecord const& GetClosestNonnegative() const;
53 
54  // Locate the record with nonpositive t-value closest to zero.
55  PickRecord const& GetClosestNonpositive() const;
56 
57  // Access to all the records for the pick operation.
58  std::vector<PickRecord> records;
59 
60 private:
61  // The picking occurs recursively by traversing the input scene.
62  void ExecuteRecursive(std::shared_ptr<Spatial> const& object);
63 
64  void PickTriangles(std::shared_ptr<Visual> const& visual, char const* positions,
65  unsigned int vstride, IndexBuffer* ibuffer, Line3<float> const& line);
66 
67  void PickSegments(std::shared_ptr<Visual> const& visual, char const* positions,
68  unsigned int vstride, IndexBuffer* ibuffer, Line3<float> const& line);
69 
70  void PickPoints(std::shared_ptr<Visual> const& visual, char const* positions,
71  unsigned int vstride, IndexBuffer* ibuffer, Line3<float> const& line);
72 
73  // The maximum distance from the pick line used to select point or segment
74  // primitives.
75  float mMaxDistance;
76 
77  // The parameters for the linear component used to pick.
80  float mTMin, mTMax;
81 
82  // The value returned if the Get* functions are called when 'records' has
83  // no elements.
84  static PickRecord const msInvalid;
85 };
86 
87 }
float mMaxDistance
Definition: GtePicker.h:75
Vector4< float > mOrigin
Definition: GtePicker.h:78
static PickRecord const msInvalid
Definition: GtePicker.h:84
GLfixed GLfixed GLint GLint GLfixed GLfixed GLint vstride
Definition: glext.h:4928
std::vector< PickRecord > records
Definition: GtePicker.h:58
float mTMin
Definition: GtePicker.h:80
#define GTE_IMPEXP
Definition: GTEngineDEF.h:63
Vector4< float > mDirection
Definition: GtePicker.h:79


geometric_tools_engine
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 04:00:01