HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
flatNormals.h
Go to the documentation of this file.
1 //
2 // Copyright 2018 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_FLAT_NORMALS_H
25 #define PXR_IMAGING_HD_FLAT_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 class HdMeshTopology;
41 
42 /// \class Hd_FlatNormals
43 ///
44 /// Hd_FlatNormals encapsulates mesh flat normals information.
45 /// It uses passed-in face index data and points data to compute
46 /// flat per-face normals. It does this by breaking each face into
47 /// a triangle fan centered at vertex 0, and averaging triangle normals.
48 ///
49 class Hd_FlatNormals final {
50 public:
51  /// Computes the flat normals result using the supplied face coord
52  /// information and points data. Returns an array of the same size and
53  /// type as the source points, with optional packing.
54  HD_API
56  HdMeshTopology const * topology,
57  GfVec3f const * pointsPtr);
58  HD_API
60  HdMeshTopology const * topology,
61  GfVec3d const * pointsPtr);
62  HD_API
64  HdMeshTopology const * topology,
65  GfVec3f const * pointsPtr);
66  HD_API
68  HdMeshTopology const * topology,
69  GfVec3d const * pointsPtr);
70 
71 private:
72  Hd_FlatNormals() = delete;
73  ~Hd_FlatNormals() = delete;
74 };
75 
76 /// \class Hd_FlatNormalsComputation
77 ///
78 /// Flat normal computation CPU.
79 ///
81 public:
82  HD_API
85  TfToken const &dstName,
86  bool packed);
87 
88  /// overrides
89  HD_API
90  virtual void GetBufferSpecs(HdBufferSpecVector *specs) const override;
91  HD_API
92  virtual bool Resolve() override;
93  HD_API
94  virtual TfToken const &GetName() const override;
95 
96 protected:
97  HD_API
98  virtual bool _CheckValid() const override;
99 
100 private:
101  HdMeshTopology const *_topology;
102  HdBufferSourceSharedPtr const _points;
103  TfToken _dstName;
104  bool _packed;
105 };
106 
108 
109 #endif // PXR_IMAGING_HD_FLAT_NORMALS_H
virtual HD_API void GetBufferSpecs(HdBufferSpecVector *specs) const override
overrides
static HD_API VtArray< HdVec4f_2_10_10_10_REV > ComputeFlatNormalsPacked(HdMeshTopology const *topology, GfVec3f const *pointsPtr)
Definition: vec3f.h:63
#define HD_API
Definition: api.h:40
virtual HD_API bool _CheckValid() const override
Definition: token.h:87
GT_API const UT_StringHolder topology
static HD_API VtArray< GfVec3f > ComputeFlatNormals(HdMeshTopology const *topology, GfVec3f const *pointsPtr)
GLuint GLenum GLsizei GLsizei GLboolean packed
Definition: glew.h:12964
std::vector< struct HdBufferSpec > HdBufferSpecVector
GLuint GLdouble GLdouble GLint GLint const GLdouble * points
Definition: glew.h:3460
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1375
virtual HD_API bool Resolve() override
Definition: vec3d.h:63
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
GLenum GLint GLint GLint GLint GLuint dstName
Definition: glcorearb.h:2509
virtual HD_API TfToken const & GetName() const override
Return the name of this buffer source.
std::shared_ptr< class HdBufferSource > HdBufferSourceSharedPtr
HD_API Hd_FlatNormalsComputation(HdMeshTopology const *topology, HdBufferSourceSharedPtr const &points, TfToken const &dstName, bool packed)