GteSpatial.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 
11 #include <Graphics/GteCuller.h>
12 #include <string>
13 
14 namespace gte
15 {
16 
17 // Support for a spatial hierarchy of objects. Class Spatial has a parent
18 // pointer. Class Node derives from Spatial has an array of child pointers.
19 // The leaf nodes of the hierarchy are either graphical or audial. Class
20 // Visual derives from Spatial and represents graphical data. Class Audial
21 // derives from Spatial and represents sound data.
22 
23 class Camera;
24 
26 {
27 public:
28  // Abstract base class.
29  virtual ~Spatial();
30 
31  // Update of geometric state. The function computes world transformations
32  // on the downward pass of the scene graph traversal and world bounding
33  // volumes on the upward pass of the traversal. The object that calls the
34  // update is the initiator. Other objects visited during the update are
35  // not initiators. The application time is in milliseconds.
36  void Update(double applicationTime = 0.0, bool initiator = true);
37 
38  // Access to the parent object, which is null for the root of the
39  // hierarchy.
40  inline Spatial* GetParent();
41 
42  // Allow user-readable names for nodes in a scene graph.
44 
45  // Local and world transforms. In some situations you might need to set
46  // the world transform directly and bypass the Spatial::Update()
47  // mechanism, in which case worldTransformIsCurrent should be set to
48  // 'true'.
52 
53  // World bound access. In some situations you might want to set the
54  // world bound directly and bypass the Spatial::Update() mechanism, in
55  // which case worldBoundIsCurrent flag should be set to 'true'.
57  CullingMode culling;
59 
60 public:
61  // Support for hierarchical culling.
62  void OnGetVisibleSet(Culler& culler, std::shared_ptr<Camera> const& camera,
63  bool noCull);
64  virtual void GetVisibleSet(Culler& culler,
65  std::shared_ptr<Camera> const& camera, bool noCull) = 0;
66 
67  // Access to the parent object. Node calls this during attach/detach of
68  // children.
69  void SetParent(Spatial* parent);
70 
71 protected:
72  // Constructor accessible by Node, Visual, and Audial.
73  Spatial();
74 
75  // Support for geometric updates.
76  virtual void UpdateWorldData(double applicationTime);
77  virtual void UpdateWorldBound() = 0;
78  void PropagateBoundToRoot();
79 
80 private:
81  // Support for a hierarchical scene graph. Spatial provides the parent
82  // pointer. Node provides the child pointers. The parent pointer is not
83  // shared to avoid reference-count cycles between mParent and 'this.
84  // Because the pointer links are set internally rather than by an external
85  // manager, it is not possible to use std::weak_ptr to avoid the cycle
86  // because we do not know the shared_ptr object that owns mParent.
88 };
89 
90 
92 {
93  return mParent;
94 }
95 
96 inline void Spatial::SetParent(Spatial* parent)
97 {
98  mParent = parent;
99 }
100 
101 }
Spatial * mParent
Definition: GteSpatial.h:87
void SetParent(Spatial *parent)
Definition: GteSpatial.h:96
std::string name
Definition: GteSpatial.h:43
bool worldTransformIsCurrent
Definition: GteSpatial.h:51
CullingMode culling
Definition: GteSpatial.h:57
Transform worldTransform
Definition: GteSpatial.h:50
GLsizei const GLchar *const * string
Definition: glcorearb.h:809
bool worldBoundIsCurrent
Definition: GteSpatial.h:58
BoundingSphere worldBound
Definition: GteSpatial.h:56
Spatial * GetParent()
Definition: GteSpatial.h:91
#define GTE_IMPEXP
Definition: GTEngineDEF.h:63
Transform localTransform
Definition: GteSpatial.h:49


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