TrueReality  v0.1.1912
trCore/Nodes/NodeVisitor.h
Go to the documentation of this file.
1 /*
2 * True Reality Open Source Game and Simulation Engine
3 * Copyright © 2021 Acid Rain Studios LLC
4 *
5 * This library is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU Lesser General Public License as published by the Free
7 * Software Foundation; either version 3.0 of the License, or (at your option)
8 * any later version.
9 *
10 * This library is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this library; if not, write to the Free Software Foundation, Inc.,
17 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * @author Maxim Serebrennik
20 */
21 #pragma once
22 
23 #include <trCore/Export.h>
24 
25 #include <trBase/Base.h>
26 #include <trBase/SmrtPtr.h>
27 #include <trBase/Vec3.h>
29 #include <trCore/Nodes/Node.h>
30 #include <trUtil/RefStr.h>
31 
32 namespace osg
33 {
34  class NodeVisitor;
35 }
36 
37 namespace trCore::Nodes
38 {
56  {
57  public:
58 
60  {
61  TRAVERSE_NONE = 0,
62  TRAVERSE_PARENTS = 1,
63  TRAVERSE_ALL_CHILDREN = 2,
64  TRAVERSE_ACTIVE_CHILDREN = 3
65  };
66 
68  {
69  NODE_VISITOR = 0,
70  UPDATE_VISITOR = 1,
71  EVENT_VISITOR = 2,
72  COLLECT_OCCLUDER_VISITOR = 3,
73  CULL_VISITOR = 4,
74  INTERSECTION_VISITOR = 5
75  };
76 
78 
79  const static trUtil::RefStr CLASS_TYPE;
80 
89  NodeVisitor(TraversalMode tm = TRAVERSE_NONE, const std::string name = CLASS_TYPE);
90 
100  NodeVisitor(VisitorType type, TraversalMode tm = TRAVERSE_NONE, const std::string name = CLASS_TYPE);
101 
109  virtual const std::string& GetType() const override;
110 
118  virtual void SetName(const std::string& name);
119 
127  virtual osg::NodeVisitor* AsOSGVisitor();
128 
136  virtual const osg::NodeVisitor* AsOSGVisitor() const;
137 
145  virtual void Reset();
146 
156  inline void SetVisitorType(VisitorType type);
157 
165  inline VisitorType GetVisitorType() const;
166 
174  inline void SetTraversalNumber(unsigned int fn);
175 
183  inline unsigned int GetTraversalNumber() const;
184 
192  inline void SetFrameStamp(FrameStamp* fs);
193 
202  inline const FrameStamp* GetFrameStamp() const;
203 
218  inline void SetTraversalMask(Node::NodeMask mask);
219 
227  inline Node::NodeMask GetTraversalMask() const;
228 
239  inline void SetNodeMaskOverride(Node::NodeMask mask);
240 
248  inline Node::NodeMask GetNodeMaskOverride() const;
249 
264  inline bool ValidNodeMask(const Nodes::Node& node) const;
265 
276  inline void SetTraversalMode(TraversalMode mode);
277 
285  inline TraversalMode GetTraversalMode() const;
286 
296  inline void Traverse(Node& node);
297 
310  inline void PushOntoNodePath(Node* node);
311 
319  inline void PopFromNodePath();
320 
330  NodePath* GetNodePath();
331 
341  const NodePath* GetNodePath() const;
342 
351  virtual trBase::Vec3 GetEyePoint() const { return trBase::Vec3(0.0f, 0.0f, 0.0f); }
352 
361  virtual trBase::Vec3 GetViewPoint() const { return GetEyePoint(); }
362 
376  virtual float GetDistanceToEyePoint(const trBase::Vec3& /*pos*/, bool /*useLODScale*/) const { return 0.0f; }
377 
391  virtual float GetDistanceFromEyePoint(const trBase::Vec3& /*pos*/, bool /*useLODScale*/) const { return 0.0f; }
392 
406  virtual float GetDistanceToViewPoint(const trBase::Vec3& /*pos*/, bool /*useLODScale*/) const { return 0.0f; }
407 
408  protected:
409 
412 
418  ~NodeVisitor();
419  };
420 }
virtual float GetDistanceToEyePoint(const trBase::Vec3 &, bool) const
Get the distance from a point to the eye point, distance value in local coordinate system...
#define TR_CORE_EXPORT
Definition: trCore/Export.h:33
std::vector< trBase::SmrtPtr< Node > > NodePath
A vector of Nodes pointers which is used to describe the path from a root node to a descendant...
unsigned int NodeMask
Holds the class type name for efficient comparisons.
Class which encapsulates the frame number, reference time and calendar time of specific frame...
Definition: FrameStamp.h:54
A string wrapper that will make sure that all of the strings with the same value will point to the sa...
Definition: RefStr.h:50
Visitor for type safe operations on trCore::Nodes.
This class is part of the internal garbage collection system.
Definition: SmrtClass.h:38
This is a Base class that carries the Class name and Unique ID of all the derived classes...
Definition: trBase/Base.h:36
Class for wrapping the osg node Internally it contains an OSG Group, that can be accessed by user if ...
Vec3f Vec3
General purpose 3D Vector.
Definition: Vec3.h:38
Definition: FrameStamp.h:37
static const trUtil::RefStr CLASS_TYPE
Adds an easy and swappable access to the base class.
virtual trBase::Vec3 GetViewPoint() const
Get the view point in local coordinates.
trBase::SmrtPtr< osg::NodeVisitor > mNodeVisitor
The node visitor.
virtual trBase::Vec3 GetEyePoint() const
Get the eye point in local coordinates.
virtual float GetDistanceToViewPoint(const trBase::Vec3 &, bool) const
Get the distance from a point to the view point, distance value in local coordinate system...
virtual float GetDistanceFromEyePoint(const trBase::Vec3 &, bool) const
Get the distance of a point from the eye point, distance value in the eye coordinate system...
General purpose 3D float Vector.
Definition: Vec3f.h:47