File: Wm5Spatial.h

package info (click to toggle)
libwildmagic 5.13-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch
  • size: 89,572 kB
  • ctags: 26,264
  • sloc: cpp: 210,924; csh: 637; sh: 95; makefile: 36
file content (105 lines) | stat: -rw-r--r-- 3,283 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// Geometric Tools, LLC
// Copyright (c) 1998-2014
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
// http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
//
// File Version: 5.0.1 (2010/10/01)

#ifndef WM5SPATIAL_H
#define WM5SPATIAL_H

#include "Wm5GraphicsLIB.h"
#include "Wm5ControlledObject.h"
#include "Wm5Bound.h"
#include "Wm5Transform.h"

namespace Wm5
{

class Culler;

class WM5_GRAPHICS_ITEM Spatial : public ControlledObject
{
    WM5_DECLARE_RTTI;
    WM5_DECLARE_NAMES;
    WM5_DECLARE_STREAM(Spatial);

protected:
    // Abstract base class.  Construction and destruction.
    Spatial ();
public:
    virtual ~Spatial ();

    // Local and world transforms.  In some situations you might need to set
    // the world transform directly and bypass the Spatial::Update()
    // mechanism.  If World is set directly, the mWorldIsCurrent flag should
    // be set to 'true'.
    Transform LocalTransform;
    Transform WorldTransform;
    bool WorldTransformIsCurrent;

    // World bound access.  In some situations you might want to set the
    // world bound directly and bypass the Spatial::Update() mechanism.  If
    // mWorldBound is set directly, the mWorldBoundIsCurrent flag should be
    // set to 'true'.
    Bound WorldBound;
    bool WorldBoundIsCurrent;

    // Culling parameters.
    enum WM5_GRAPHICS_ITEM CullingMode
    {
        // Determine visibility state by comparing the world bounding volume
        // to culling planes.
        CULL_DYNAMIC,

        // Force the object to be culled.  If a Node is culled, its entire
        // subtree is culled.
        CULL_ALWAYS,

        // Never cull the object.  If a Node is never culled, its entire
        // subtree is never culled.  To accomplish this, the first time such
        // a Node is encountered, the bNoCull parameter is set to 'true' in
        // the recursive chain GetVisibleSet/OnGetVisibleSet.
        CULL_NEVER
    };

    CullingMode Culling;

    // Update of geometric state and controllers.  The function computes world
    // transformations on the downward pass of the scene graph traversal and
    // world bounding volumes on the upward pass of the traversal.
    void Update (double applicationTime = -Mathd::MAX_REAL,
        bool initiator = true);

    // Access to the parent object.
    inline Spatial* GetParent ();

protected:
    // Support for the geometric update.
    virtual void UpdateWorldData (double applicationTime);
    virtual void UpdateWorldBound () = 0;
    void PropagateBoundToRoot ();

public_internal:
    // Support for hierarchical culling.
    void OnGetVisibleSet (Culler& culler, bool noCull);
    virtual void GetVisibleSet (Culler& culler, bool noCull) = 0;

    // Access to the parent object.  Node calls this during attach/detach of
    // children.
    inline void SetParent (Spatial* parent);

protected:
    // Support for a hierarchical scene graph.  Spatial provides the parent
    // pointer.  Node provides the child pointers.
    Spatial* mParent;
};

WM5_REGISTER_STREAM(Spatial);
typedef Pointer0<Spatial> SpatialPtr;
#include "Wm5Spatial.inl"

}

#endif