HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GEO_Normal.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: GEO_Normal.h (GEO Library, C++)
7  *
8  * COMMENTS: Functions for computing normals
9  */
10 
11 #pragma once
12 
13 #ifndef __GEO_Normal__
14 #define __GEO_Normal__
15 
16 #include "GEO_API.h"
17 #include <GA/GA_Handle.h>
18 #include <stddef.h>
19 
20 class GEO_Detail;
21 class GA_Group;
22 
23 #define GEO_DEFAULT_CUSP_ANGLE 60.0
24 
25 /// Magic tolerance factor of 1.001 on GEO_DEFAULT_CUSP_ANGLE so that
26 /// hexagonal tubes will be smooth by default, even with a bit of roundoff
27 /// or slight deformation.
28 #define GEO_DEFAULT_ADJUSTED_CUSP_ANGLE 60.06
29 
30 /// This determines how contributions from multiple vertices around a point
31 /// get weighted when computing a normal for that point.
32 enum class GEO_NormalMethod
33 {
34  UNIFORM_WEIGHTED, // Each vertex gets equal weight
35  ANGLE_WEIGHTED, // Each vertex is weighted by angle (usually best results)
36  AREA_WEIGHTED // Each vertex is weighted by total face area
37 };
38 
39 /// Computes normals into given attribute using detail->getP().
40 /// If group is specified, only the associated elements are updated.
41 /// If normalattrib is a detail attribute and group is given,
42 /// it is only computed based on the primitives associated with the group.
43 /// If vertex normals, a cusp angle of 0 or less cusps everything, and
44 /// a cusp angle of 180 or more cusps nothing.
46  const GEO_Detail &detail,
47  const GA_RWHandleV3 &normalattrib,
48  const GA_Group *group = NULL,
49  const float cuspangledegrees = GEO_DEFAULT_ADJUSTED_CUSP_ANGLE,
51  const bool copy_orig_if_zero = false);
53  const GEO_Detail &detail,
54  const GA_RWHandleV3D &normalattrib,
55  const GA_Group *group = NULL,
56  const float cuspangledegrees = GEO_DEFAULT_ADJUSTED_CUSP_ANGLE,
58  const bool copy_orig_if_zero = false);
60  const GEO_Detail &detail,
61  GA_Attribute *normalattrib,
62  const GA_Group *group = NULL,
63  const float cuspangledegrees = GEO_DEFAULT_ADJUSTED_CUSP_ANGLE,
65  const bool copy_orig_if_zero = false);
66 
67 /// Computes normals into given attribute using pos_attrib (owned by detail).
68 /// If group is specified, only the associated elements are updated.
69 /// If normalattrib is a detail attribute and group is given,
70 /// it is only computed based on the primitives associated with the group.
71 /// If vertex normals, a cusp angle of 0 or less cusps everything, and
72 /// a cusp angle of 180 or more cusps nothing.
74  const GEO_Detail &detail,
75  const GA_ROHandleV3 &posattrib,
76  const GA_RWHandleV3 &normalattrib,
77  const GA_Group *group = NULL,
78  const float cuspangledegrees = GEO_DEFAULT_ADJUSTED_CUSP_ANGLE,
80  const bool copy_orig_if_zero = false);
82  const GEO_Detail &detail,
83  const GA_ROHandleV3D &posattrib,
84  const GA_RWHandleV3D &normalattrib,
85  const GA_Group *group = NULL,
86  const float cuspangledegrees = GEO_DEFAULT_ADJUSTED_CUSP_ANGLE,
88  const bool copy_orig_if_zero = false);
89 
90 #endif
Definition of a geometry attribute.
Definition: GA_Attribute.h:198
void GEO_API GEOcomputeNormals(const GEO_Detail &detail, const GA_RWHandleV3 &normalattrib, const GA_Group *group=NULL, const float cuspangledegrees=GEO_DEFAULT_ADJUSTED_CUSP_ANGLE, const GEO_NormalMethod method=GEO_NormalMethod::ANGLE_WEIGHTED, const bool copy_orig_if_zero=false)
GEO_NormalMethod
Definition: GEO_Normal.h:32
#define GEO_DEFAULT_ADJUSTED_CUSP_ANGLE
Definition: GEO_Normal.h:28
#define GEO_API
Definition: GEO_API.h:14