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  /// Sets the collection expansion option when defining collections.
66  void setBindCollectionExpand( bool expand )
67  { myBindCollectionExpand = expand; }
69  { return myBindCollectionExpand; }
70 
71  /// For non-direct bindings, sets the USD primitive path on which the
72  /// collection-based binding is defined.
74  { myBindPrimPath = p; }
76  { return myBindPrimPath; }
77 
78  /// Enumeration of the material binding strength.
79  enum class Strength
80  {
81  DEFAULT, // fallback
82  STRONG, // stronger than descendents
83  WEAK // weaker than descendents
84  };
85 
86  /// Sets the strength preference for material assignments.
87  void setStrength( Strength strength )
88  { myStrength = strength; }
90  { return myStrength; }
91 
92  /// Sets the purpose for material assignments.
93  void setPurpose( const UT_StringHolder &purpose )
94  { myPurpose = purpose; }
95  const UT_StringHolder & getPurpose() const
96  { return myPurpose; }
97 
98 private:
99  HUSD_AutoWriteLock & myWriteLock;
100  BindMethod myBindMethod; // Collection based?
101  bool myBindCollectionExpand; // Expand collections
102  Strength myStrength; // Binding strength
103  UT_StringHolder myPurpose; // Binding purpose
104  UT_StringHolder myBindPrimPath; // Collection location
105 };
106 
107 #endif
108 
const UT_StringHolder & getBindPrimPath() const
BindMethod getBindMethod() const
#define HUSD_API
Definition: HUSD_API.h:32
const UT_StringHolder & getPurpose() const
void setBindCollectionExpand(bool expand)
Sets the collection expansion option when defining collections.
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
bool getBindCollectionExpand() const
Strength getStrength() const