HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HUSD_BindMaterial.h
Go to the documentation of this file.
1 /*
2  * Copyright 2019 Side Effects Software Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 #ifndef __HUSD_BindMaterial__
19 #define __HUSD_BindMaterial__
20 
21 #include "HUSD_API.h"
22 #include "HUSD_DataHandle.h"
23 
24 
26 {
27 public:
28  /// Standard constructor.
30 
31  /// Assigns the given material to the given geometry primitive(s).
32  bool bind(const UT_StringRef &mat_prim_path,
33  const UT_StringRef &geo_prim_path) const;
34  bool bind(const UT_StringRef &mat_prim_path,
35  const HUSD_FindPrims &find_geo_prims) const;
36 
37  /// Performs a collection based binding with explicit values for the
38  /// collection path, binding prim path, and binding name. The bind
39  /// method and bind prim path set on this object are ignored.
40  bool bindAsCollection(const UT_StringRef &mat_prim_path,
41  const UT_StringRef &collection_path,
42  const UT_StringRef &binding_prim_path,
43  const UT_StringRef &binding_name) const;
44 
45  /// Assigns the given material a subset of the geometry primitive. This
46  /// method creates the geometry subset. If a geometry subset already
47  /// exists, it can be bound using the regular bind methods above.
48  bool bindSubset(const UT_StringRef &mat_prim_path,
49  const UT_StringRef &geo_prim_path,
50  const UT_ExintArray *face_indices) const;
51 
52  /// Enumeration of the ways in which a binding can be performed.
53  enum class BindMethod
54  {
55  DIRECT, // direct binding
56  COLLECTION // collection-based binding
57  };
58 
59  /// Sets the method of defining bindings.
60  void setBindMethod( BindMethod method )
61  { myBindMethod = method; }
63  { return myBindMethod; }
64 
65  /// For non-direct bindings, sets the USD primitive path on which the
66  /// collection-based binding is defined.
68  { myBindPrimPath = p; }
70  { return myBindPrimPath; }
71 
72  /// Enumeration of the material binding strength.
73  enum class Strength
74  {
75  DEFAULT, // fallback
76  STRONG, // stronger than descendents
77  WEAK // weaker than descendents
78  };
79 
80  /// Sets the strength preference for material assignments.
81  void setStrength( Strength strength )
82  { myStrength = strength; }
84  { return myStrength; }
85 
86  /// Sets the purpose for material assignments.
87  void setPurpose( const UT_StringHolder &purpose )
88  { myPurpose = purpose; }
89  const UT_StringHolder & getPurpose() const
90  { return myPurpose; }
91 
92 private:
93  HUSD_AutoWriteLock & myWriteLock;
94  BindMethod myBindMethod; // Collection based?
95  Strength myStrength; // Binding strength
96  UT_StringHolder myPurpose; // Binding purpose
97  UT_StringHolder myBindPrimPath; // Collection location
98 };
99 
100 #endif
101 
const UT_StringHolder & getBindPrimPath() const
BindMethod getBindMethod() const
#define HUSD_API
Definition: HUSD_API.h:32
const UT_StringHolder & getPurpose() const
void setPurpose(const UT_StringHolder &purpose)
Sets the purpose for material assignments.
simple inheritance: W = L * pW
BindMethod
Enumeration of the ways in which a binding can be performed.
void setBindPrimPath(const UT_StringRef &p)
Strength
Enumeration of the material binding strength.
void setBindMethod(BindMethod method)
Sets the method of defining bindings.
void setStrength(Strength strength)
Sets the strength preference for material assignments.
GLfloat GLfloat p
Definition: glew.h:16321
Strength getStrength() const