MaterialX 1.38.10
Loading...
Searching...
No Matches
Look.h
Go to the documentation of this file.
1//
2// Copyright Contributors to the MaterialX Project
3// SPDX-License-Identifier: Apache-2.0
4//
5
6#ifndef MATERIALX_LOOK_H
7#define MATERIALX_LOOK_H
8
11
13
17
18MATERIALX_NAMESPACE_BEGIN
19
20class Look;
21class LookGroup;
22class LookInherit;
23class MaterialAssign;
24class Visibility;
25
27using LookPtr = shared_ptr<Look>;
29using ConstLookPtr = shared_ptr<const Look>;
30
32using LookGroupPtr = shared_ptr<LookGroup>;
34using ConstLookGroupPtr = shared_ptr<const LookGroup>;
35
37using MaterialAssignPtr = shared_ptr<MaterialAssign>;
39using ConstMaterialAssignPtr = shared_ptr<const MaterialAssign>;
40
42using VisibilityPtr = shared_ptr<Visibility>;
44using ConstVisibilityPtr = shared_ptr<const Visibility>;
45
48class MX_CORE_API Look : public Element
49{
50 public:
51 Look(ElementPtr parent, const string& name) :
52 Element(parent, CATEGORY, name)
53 {
54 }
55 virtual ~Look() { }
56
59
67 MaterialAssignPtr addMaterialAssign(const string& name = EMPTY_STRING,
68 const string& material = EMPTY_STRING);
69
71 MaterialAssignPtr getMaterialAssign(const string& name) const
72 {
73 return getChildOfType<MaterialAssign>(name);
74 }
75
77 vector<MaterialAssignPtr> getMaterialAssigns() const
78 {
79 return getChildrenOfType<MaterialAssign>();
80 }
81
84 vector<MaterialAssignPtr> getActiveMaterialAssigns() const;
85
87 void removeMaterialAssign(const string& name)
88 {
89 removeChildOfType<MaterialAssign>(name);
90 }
91
95
101 PropertyAssignPtr addPropertyAssign(const string& name = EMPTY_STRING)
102 {
103 return addChild<PropertyAssign>(name);
104 }
105
107 PropertyAssignPtr getPropertyAssign(const string& name) const
108 {
109 return getChildOfType<PropertyAssign>(name);
110 }
111
113 vector<PropertyAssignPtr> getPropertyAssigns() const
114 {
115 return getChildrenOfType<PropertyAssign>();
116 }
117
120 vector<PropertyAssignPtr> getActivePropertyAssigns() const;
121
123 void removePropertyAssign(const string& name)
124 {
125 removeChildOfType<PropertyAssign>(name);
126 }
127
131
137 PropertySetAssignPtr addPropertySetAssign(const string& name = EMPTY_STRING)
138 {
139 return addChild<PropertySetAssign>(name);
140 }
141
144 {
145 return getChildOfType<PropertySetAssign>(name);
146 }
147
149 vector<PropertySetAssignPtr> getPropertySetAssigns() const
150 {
151 return getChildrenOfType<PropertySetAssign>();
152 }
153
156 vector<PropertySetAssignPtr> getActivePropertySetAssigns() const;
157
159 void removePropertySetAssign(const string& name)
160 {
161 removeChildOfType<PropertySetAssign>(name);
162 }
163
167
173 VariantAssignPtr addVariantAssign(const string& name = EMPTY_STRING)
174 {
175 return addChild<VariantAssign>(name);
176 }
177
179 VariantAssignPtr getVariantAssign(const string& name) const
180 {
181 return getChildOfType<VariantAssign>(name);
182 }
183
185 vector<VariantAssignPtr> getVariantAssigns() const
186 {
187 return getChildrenOfType<VariantAssign>();
188 }
189
192 vector<VariantAssignPtr> getActiveVariantAssigns() const;
193
195 void removeVariantAssign(const string& name)
196 {
197 removeChildOfType<VariantAssign>(name);
198 }
199
203
209 VisibilityPtr addVisibility(const string& name = EMPTY_STRING)
210 {
211 return addChild<Visibility>(name);
212 }
213
215 VisibilityPtr getVisibility(const string& name) const
216 {
217 return getChildOfType<Visibility>(name);
218 }
219
221 vector<VisibilityPtr> getVisibilities() const
222 {
223 return getChildrenOfType<Visibility>();
224 }
225
228 vector<VisibilityPtr> getActiveVisibilities() const;
229
231 void removeVisibility(const string& name)
232 {
233 removeChildOfType<Visibility>(name);
234 }
235
237
238 public:
239 static const string CATEGORY;
240};
241
244class MX_CORE_API LookGroup : public Element
245{
246 public:
247 LookGroup(ElementPtr parent, const string& name) :
248 Element(parent, CATEGORY, name)
249 {
250 }
251 virtual ~LookGroup() { }
252
254 void setLooks(const string& looks)
255 {
256 setAttribute(LOOKS_ATTRIBUTE, looks);
257 }
258
260 const string& getLooks() const
261 {
262 return getAttribute(LOOKS_ATTRIBUTE);
263 }
264
266 void setActiveLook(const string& look)
267 {
268 setAttribute(ACTIVE_ATTRIBUTE, look);
269 }
270
272 const string& getActiveLook() const
273 {
274 return getAttribute(ACTIVE_ATTRIBUTE);
275 }
276
277 public:
278 static const string CATEGORY;
279 static const string LOOKS_ATTRIBUTE;
280 static const string ACTIVE_ATTRIBUTE;
281};
282
285class MX_CORE_API MaterialAssign : public GeomElement
286{
287 public:
288 MaterialAssign(ElementPtr parent, const string& name) :
289 GeomElement(parent, CATEGORY, name)
290 {
291 }
292 virtual ~MaterialAssign() { }
293
296
298 void setMaterial(const string& material)
299 {
300 setAttribute(MATERIAL_ATTRIBUTE, material);
301 }
302
304 bool hasMaterial() const
305 {
306 return hasAttribute(MATERIAL_ATTRIBUTE);
307 }
308
310 const string& getMaterial() const
311 {
312 return getAttribute(MATERIAL_ATTRIBUTE);
313 }
314
316 vector<OutputPtr> getMaterialOutputs() const;
317
321
323 void setExclusive(bool value)
324 {
325 setTypedAttribute<bool>(EXCLUSIVE_ATTRIBUTE, value);
326 }
327
329 bool getExclusive() const
330 {
331 return getTypedAttribute<bool>(EXCLUSIVE_ATTRIBUTE);
332 }
333
337
339 NodePtr getReferencedMaterial() const;
340
344
350 VariantAssignPtr addVariantAssign(const string& name = EMPTY_STRING)
351 {
352 return addChild<VariantAssign>(name);
353 }
354
356 VariantAssignPtr getVariantAssign(const string& name) const
357 {
358 return getChildOfType<VariantAssign>(name);
359 }
360
362 vector<VariantAssignPtr> getVariantAssigns() const
363 {
364 return getChildrenOfType<VariantAssign>();
365 }
366
369 vector<VariantAssignPtr> getActiveVariantAssigns() const;
370
372 void removeVariantAssign(const string& name)
373 {
374 removeChildOfType<VariantAssign>(name);
375 }
376
377 public:
378 static const string CATEGORY;
379 static const string MATERIAL_ATTRIBUTE;
380 static const string EXCLUSIVE_ATTRIBUTE;
381};
382
391class MX_CORE_API Visibility : public GeomElement
392{
393 public:
394 Visibility(ElementPtr parent, const string& name) :
395 GeomElement(parent, CATEGORY, name)
396 {
397 }
398 virtual ~Visibility() { }
399
402
404 void setViewerGeom(const string& geom)
405 {
406 setAttribute(VIEWER_GEOM_ATTRIBUTE, geom);
407 }
408
410 bool hasViewerGeom() const
411 {
412 return hasAttribute(VIEWER_GEOM_ATTRIBUTE);
413 }
414
416 const string& getViewerGeom() const
417 {
418 return getAttribute(VIEWER_GEOM_ATTRIBUTE);
419 }
420
424
426 void setViewerCollection(const string& collection)
427 {
428 setAttribute(VIEWER_COLLECTION_ATTRIBUTE, collection);
429 }
430
433 {
434 return hasAttribute(VIEWER_COLLECTION_ATTRIBUTE);
435 }
436
438 const string& getViewerCollection() const
439 {
440 return getAttribute(VIEWER_COLLECTION_ATTRIBUTE);
441 }
442
446
448 void setVisibilityType(const string& type)
449 {
450 setAttribute(VISIBILITY_TYPE_ATTRIBUTE, type);
451 }
452
454 bool hasVisibilityType() const
455 {
456 return hasAttribute(VISIBILITY_TYPE_ATTRIBUTE);
457 }
458
460 const string& getVisibilityType() const
461 {
462 return getAttribute(VISIBILITY_TYPE_ATTRIBUTE);
463 }
464
468
470 void setVisible(bool visible)
471 {
472 setTypedAttribute<bool>(VISIBLE_ATTRIBUTE, visible);
473 }
474
476 bool getVisible() const
477 {
478 return getTypedAttribute<bool>(VISIBLE_ATTRIBUTE);
479 }
480
482
483 public:
484 static const string CATEGORY;
485 static const string VIEWER_GEOM_ATTRIBUTE;
486 static const string VIEWER_COLLECTION_ATTRIBUTE;
487 static const string VISIBILITY_TYPE_ATTRIBUTE;
488 static const string VISIBLE_ATTRIBUTE;
489};
490
498MX_CORE_API vector<MaterialAssignPtr> getGeometryBindings(ConstNodePtr materialNode, const string& geom = UNIVERSAL_GEOM_NAME);
499
500MATERIALX_NAMESPACE_END
501
502#endif
shared_ptr< Element > ElementPtr
A shared pointer to an Element.
Definition: Element.h:31
shared_ptr< const LookGroup > ConstLookGroupPtr
A shared pointer to a const LookGroup.
Definition: Look.h:34
shared_ptr< MaterialAssign > MaterialAssignPtr
A shared pointer to a MaterialAssign.
Definition: Look.h:37
shared_ptr< LookGroup > LookGroupPtr
A shared pointer to a LookGroup.
Definition: Look.h:32
shared_ptr< const MaterialAssign > ConstMaterialAssignPtr
A shared pointer to a const MaterialAssign.
Definition: Look.h:39
shared_ptr< const Visibility > ConstVisibilityPtr
A shared pointer to a const Visibility.
Definition: Look.h:44
MX_CORE_API vector< MaterialAssignPtr > getGeometryBindings(ConstNodePtr materialNode, const string &geom=UNIVERSAL_GEOM_NAME)
Return a vector of all MaterialAssign elements that bind this material node to the given geometry str...
Definition: Look.cpp:23
shared_ptr< const Look > ConstLookPtr
A shared pointer to a const Look.
Definition: Look.h:29
shared_ptr< Visibility > VisibilityPtr
A shared pointer to a Visibility.
Definition: Look.h:42
shared_ptr< Look > LookPtr
A shared pointer to a Look.
Definition: Look.h:27
Material node helper functions.
Import and export declarations for the Core library.
shared_ptr< const Node > ConstNodePtr
A shared pointer to a const Node.
Definition: Node.h:26
shared_ptr< Node > NodePtr
A shared pointer to a Node.
Definition: Node.h:24
Property element subclasses.
shared_ptr< PropertySetAssign > PropertySetAssignPtr
A shared pointer to a PropertySetAssign.
Definition: Property.h:39
shared_ptr< PropertyAssign > PropertyAssignPtr
A shared pointer to a PropertyAssign.
Definition: Property.h:29
Variant element subclasses.
shared_ptr< VariantAssign > VariantAssignPtr
A shared pointer to a VariantAssign.
Definition: Variant.h:33
The base class for MaterialX elements.
Definition: Element.h:80
const string & getAttribute(const string &attrib) const
Return the value string of the given attribute.
Definition: Element.h:504
void setAttribute(const string &attrib, const string &value)
Set the value string of the given attribute.
Definition: Element.cpp:191
bool hasAttribute(const string &attrib) const
Return true if the given attribute is present.
Definition: Element.h:497
The base class for geometric elements, which support bindings to geometries and geometric collections...
Definition: Geom.h:144
A look group element within a Document.
Definition: Look.h:245
void setLooks(const string &looks)
Set comma-separated list of looks.
Definition: Look.h:254
const string & getLooks() const
Get comma-separated list of looks.
Definition: Look.h:260
void setActiveLook(const string &look)
Set the active look.
Definition: Look.h:266
const string & getActiveLook() const
Return the active look, if any.
Definition: Look.h:272
A look element within a Document.
Definition: Look.h:49
VariantAssignPtr getVariantAssign(const string &name) const
Return the VariantAssign, if any, with the given name.
Definition: Look.h:179
void removeMaterialAssign(const string &name)
Remove the MaterialAssign, if any, with the given name.
Definition: Look.h:87
vector< MaterialAssignPtr > getMaterialAssigns() const
Return a vector of all MaterialAssign elements in the look.
Definition: Look.h:77
PropertySetAssignPtr getPropertySetAssign(const string &name) const
Return the PropertySetAssign, if any, with the given name.
Definition: Look.h:143
VisibilityPtr getVisibility(const string &name) const
Return the Visibility, if any, with the given name.
Definition: Look.h:215
vector< PropertyAssignPtr > getPropertyAssigns() const
Return a vector of all PropertyAssign elements in the look.
Definition: Look.h:113
vector< PropertySetAssignPtr > getPropertySetAssigns() const
Return a vector of all PropertySetAssign elements in the look.
Definition: Look.h:149
void removeVisibility(const string &name)
Remove the Visibility, if any, with the given name.
Definition: Look.h:231
PropertyAssignPtr addPropertyAssign(const string &name=EMPTY_STRING)
Add a PropertyAssign to the look.
Definition: Look.h:101
void removePropertyAssign(const string &name)
Remove the PropertyAssign, if any, with the given name.
Definition: Look.h:123
PropertyAssignPtr getPropertyAssign(const string &name) const
Return the PropertyAssign, if any, with the given name.
Definition: Look.h:107
void removeVariantAssign(const string &name)
Remove the VariantAssign, if any, with the given name.
Definition: Look.h:195
MaterialAssignPtr getMaterialAssign(const string &name) const
Return the MaterialAssign, if any, with the given name.
Definition: Look.h:71
void removePropertySetAssign(const string &name)
Remove the PropertySetAssign, if any, with the given name.
Definition: Look.h:159
VisibilityPtr addVisibility(const string &name=EMPTY_STRING)
Add a Visibility to the look.
Definition: Look.h:209
vector< VisibilityPtr > getVisibilities() const
Return a vector of all Visibility elements in the look.
Definition: Look.h:221
VariantAssignPtr addVariantAssign(const string &name=EMPTY_STRING)
Add a VariantAssign to the look.
Definition: Look.h:173
PropertySetAssignPtr addPropertySetAssign(const string &name=EMPTY_STRING)
Add a PropertySetAssign to the look.
Definition: Look.h:137
vector< VariantAssignPtr > getVariantAssigns() const
Return a vector of all VariantAssign elements in the look.
Definition: Look.h:185
A material assignment element within a Look.
Definition: Look.h:286
const string & getMaterial() const
Return the material string for the MaterialAssign.
Definition: Look.h:310
VariantAssignPtr getVariantAssign(const string &name) const
Return the VariantAssign, if any, with the given name.
Definition: Look.h:356
void setExclusive(bool value)
Set the exclusive boolean for the MaterialAssign.
Definition: Look.h:323
void setMaterial(const string &material)
Set the material string for the MaterialAssign.
Definition: Look.h:298
bool getExclusive() const
Return the exclusive boolean for the MaterialAssign.
Definition: Look.h:329
void removeVariantAssign(const string &name)
Remove the VariantAssign, if any, with the given name.
Definition: Look.h:372
VariantAssignPtr addVariantAssign(const string &name=EMPTY_STRING)
Add a VariantAssign to the look.
Definition: Look.h:350
bool hasMaterial() const
Return true if the given MaterialAssign has a material string.
Definition: Look.h:304
vector< VariantAssignPtr > getVariantAssigns() const
Return a vector of all VariantAssign elements in the look.
Definition: Look.h:362
A visibility element within a Look.
Definition: Look.h:392
const string & getVisibilityType() const
Return the visibility type string of the element.
Definition: Look.h:460
void setVisible(bool visible)
Set the visible boolean of the element.
Definition: Look.h:470
bool hasVisibilityType() const
Return true if the given element has a visibility type string.
Definition: Look.h:454
const string & getViewerCollection() const
Return the viewer collection string of the element.
Definition: Look.h:438
bool getVisible() const
Return the visible boolean of the element.
Definition: Look.h:476
void setVisibilityType(const string &type)
Set the visibility type string of the element.
Definition: Look.h:448
bool hasViewerGeom() const
Return true if the given element has a viewer geom string.
Definition: Look.h:410
void setViewerGeom(const string &geom)
Set the viewer geom string of the element.
Definition: Look.h:404
bool hasViewerCollection() const
Return true if the given element has a viewer collection string.
Definition: Look.h:432
const string & getViewerGeom() const
Return the viewer geom string of the element.
Definition: Look.h:416
void setViewerCollection(const string &collection)
Set the viewer geom string of the element.
Definition: Look.h:426