HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
smoothNormals.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_SMOOTH_NORMALS_H
25 #define PXR_IMAGING_HD_SMOOTH_NORMALS_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hd/api.h"
29 #include "pxr/imaging/hd/version.h"
32 #include "pxr/imaging/hd/types.h"
33 
34 #include "pxr/base/gf/vec3d.h"
35 #include "pxr/base/gf/vec3f.h"
36 #include "pxr/base/tf/token.h"
37 
39 
40 
41 class Hd_VertexAdjacency;
42 
43 /// \class Hd_SmoothNormals
44 ///
45 /// Hd_SmoothNormals encapsulates mesh smooth normals information.
46 /// It uses passed-in adjacency information and points data to compute
47 /// smooth per-vertex normals. It does this by averaging face normals of
48 /// faces surrounding a vertex.
49 ///
50 class Hd_SmoothNormals final {
51 public:
52  /// Computes the smooth normals result using the supplied adjacency
53  /// information and points data. Returns an array of the same size and
54  /// type as the source points, with optional packing.
55  HD_API
57  Hd_VertexAdjacency const * adjacency,
58  int numPoints,
59  GfVec3f const * pointsPtr);
60  HD_API
62  Hd_VertexAdjacency const * adjacency,
63  int numPoints,
64  GfVec3d const * pointsPtr);
65  HD_API
67  Hd_VertexAdjacency const * adjacency,
68  int numPoints,
69  GfVec3f const * pointsPtr);
70  HD_API
72  Hd_VertexAdjacency const * adjacency,
73  int numPoints,
74  GfVec3d const * pointsPtr);
75 
76 private:
77  Hd_SmoothNormals() = delete;
78  ~Hd_SmoothNormals() = delete;
79 };
80 
81 /// \class Hd_SmoothNormalsComputation
82 ///
83 /// Smooth normal computation CPU.
84 ///
86 public:
87  HD_API
90  TfToken const &dstName,
91  HdBufferSourceSharedPtr const &adjacencyBuilder,
92  bool packed);
93 
94  /// overrides
95  HD_API
96  virtual void GetBufferSpecs(HdBufferSpecVector *specs) const override;
97  HD_API
98  virtual bool Resolve() override;
99  HD_API
100  virtual TfToken const &GetName() const override;
101 
102 protected:
103  HD_API
104  virtual bool _CheckValid() const override;
105 
106 private:
107  Hd_VertexAdjacency const *_adjacency;
108  HdBufferSourceSharedPtr _points;
109  TfToken _dstName;
110  HdBufferSourceSharedPtr _adjacencyBuilder;
111  bool _packed;
112 };
113 
115 
116 #endif // PXR_IMAGING_HD_SMOOTH_NORMALS_H
Definition: vec3f.h:63
#define HD_API
Definition: api.h:40
Definition: token.h:87
GLenum GLint GLint GLint GLint GLuint dstName
Definition: glew.h:3901
virtual HD_API void GetBufferSpecs(HdBufferSpecVector *specs) const override
overrides
virtual HD_API bool Resolve() override
static HD_API VtArray< GfVec3f > ComputeSmoothNormals(Hd_VertexAdjacency const *adjacency, int numPoints, GfVec3f const *pointsPtr)
virtual HD_API bool _CheckValid() const override
std::vector< struct HdBufferSpec > HdBufferSpecVector
HD_API Hd_SmoothNormalsComputation(Hd_VertexAdjacency const *adjacency, HdBufferSourceSharedPtr const &points, TfToken const &dstName, HdBufferSourceSharedPtr const &adjacencyBuilder, bool packed)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1346
static HD_API VtArray< HdVec4f_2_10_10_10_REV > ComputeSmoothNormalsPacked(Hd_VertexAdjacency const *adjacency, int numPoints, GfVec3f const *pointsPtr)
GLuint GLenum GLsizei GLsizei GLboolean packed
Definition: glew.h:12722
GLuint GLdouble GLdouble GLint GLint const GLdouble * points
Definition: glew.h:3446
Definition: vec3d.h:63
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
virtual HD_API TfToken const & GetName() const override
Return the name of this buffer source.
std::shared_ptr< class HdBufferSource > HdBufferSourceSharedPtr