HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
drawItem.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef PXR_IMAGING_HD_DRAW_ITEM_H
25 #define PXR_IMAGING_HD_DRAW_ITEM_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hd/api.h"
29 #include "pxr/imaging/hd/version.h"
30 #include "pxr/imaging/hd/perfLog.h"
33 
34 #include "pxr/imaging/hf/perfLog.h"
35 
36 #include "pxr/base/gf/matrix4d.h"
37 #include "pxr/base/gf/bbox3d.h"
38 #include "pxr/base/gf/vec2i.h"
39 
41 
42 
43 /// \class HdDrawItem
44 ///
45 /// A draw item is a light-weight representation of an HdRprim's resources and
46 /// material to be used for rendering. The visual representation (HdRepr) of an
47 /// HdRprim might require multiple draw items.
48 ///
49 /// HdDrawItem(s) are created by the HdRprim (HdMesh, HdBasisCurve, ..) for each
50 /// HdRepr. The relevant compositional hierarchy is:
51 ///
52 /// HdRprim
53 /// |
54 /// +--HdRepr(s)
55 /// |
56 /// +--HdDrawItem(s)
57 ///
58 /// HdDrawItem(s) are consumed by HdRenderPass for its HdRprimCollection via
59 /// HdRenderIndex::GetDrawItems.
60 ///
61 /// \note
62 /// Rendering backends may choose to specialize this class.
63 ///
65 {
66 public:
67  HF_MALLOC_TAG_NEW("new HdDrawItem");
68 
69  HD_API
70  HdDrawItem(HdRprimSharedData const *sharedData);
71 
72  HD_API
73  virtual ~HdDrawItem();
74 
75  SdfPath const &GetRprimID() const { return _sharedData->rprimID; }
76 
77  GfBBox3d const & GetBounds() const { return _sharedData->bounds; }
78 
79  GfRange3d const& GetExtent() const {
80  return _sharedData->bounds.GetRange();
81  }
82 
83  GfMatrix4d const& GetMatrix() const {
84  return _sharedData->bounds.GetMatrix();
85  }
86 
88  return &_drawingCoord;
89  }
90 
91  /// Returns the authored visibility, expressed by the delegate.
92  bool GetVisible() const { return _sharedData->visible; }
93 
94  TfToken const& GetMaterialTag() const {
95  return _materialTag;
96  }
97 
98  void SetMaterialTag(TfToken const &materialTag) {
99  _materialTag = materialTag;
100  }
101 
102 protected:
103  /// Returns the drawingCoord
105  return _drawingCoord;
106  }
107 
108  /// Returns the shared data
110  return _sharedData;
111  }
112 
113 private:
114  // configuration of how to bundle the drawing coordinate for this draw item
115  // out of BARs in sharedData
116  HdDrawingCoord _drawingCoord;
117 
118  // pointer to shared data across reprs, owned by rprim:
119  // bufferArrayRanges, bounds, visibility
120  HdRprimSharedData const *_sharedData;
121 
122  /// The materialTag allows the draw items of rprims to be organized into
123  /// different collections based on properties of the prim's material.
124  /// E.g. A renderer may wish to organize opaque and translucent prims
125  /// into different collections so they can be rendered seperately.
126  TfToken _materialTag;
127 };
128 
129 
131 
132 #endif //PXR_IMAGING_HD_DRAW_ITEM_H
GfRange3d const & GetExtent() const
Definition: drawItem.h:79
GfBBox3d const & GetBounds() const
Definition: drawItem.h:77
#define HD_API
Definition: api.h:40
HdDrawingCoord const & _GetDrawingCoord() const
Returns the drawingCoord.
Definition: drawItem.h:104
bool GetVisible() const
Returns the authored visibility, expressed by the delegate.
Definition: drawItem.h:92
HdRprimSharedData const * _GetSharedData() const
Returns the shared data.
Definition: drawItem.h:109
TfToken const & GetMaterialTag() const
Definition: drawItem.h:94
virtual HD_API ~HdDrawItem()
Definition: token.h:87
HF_MALLOC_TAG_NEW("new HdDrawItem")
SdfPath const & GetRprimID() const
Definition: drawItem.h:75
const GfRange3d & GetRange() const
Returns the range of the axis-aligned untransformed box.
Definition: bbox3d.h:132
HdDrawingCoord * GetDrawingCoord()
Definition: drawItem.h:87
HD_API HdDrawItem(HdRprimSharedData const *sharedData)
Definition: path.h:291
void SetMaterialTag(TfToken const &materialTag)
Definition: drawItem.h:98
GfMatrix4d const & GetMatrix() const
Definition: drawItem.h:83
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1441
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
const GfMatrix4d & GetMatrix() const
Returns the transformation matrix.
Definition: bbox3d.h:143