MaterialX 1.38.2
Look.h
Go to the documentation of this file.
1//
2// TM & (c) 2017 Lucasfilm Entertainment Company Ltd. and Lucasfilm Ltd.
3// All rights reserved. See LICENSE.txt for license.
4//
5
6#ifndef MATERIALX_LOOK_H
7#define MATERIALX_LOOK_H
8
11
13
17
18namespace MaterialX
19{
20
21class Look;
22class LookGroup;
23class LookInherit;
24class MaterialAssign;
25class Visibility;
26
28using LookPtr = shared_ptr<Look>;
30using ConstLookPtr = shared_ptr<const Look>;
31
33using LookGroupPtr = shared_ptr<LookGroup>;
35using ConstLookGroupPtr = shared_ptr<const LookGroup>;
36
38using MaterialAssignPtr = shared_ptr<MaterialAssign>;
40using ConstMaterialAssignPtr = shared_ptr<const MaterialAssign>;
41
43using VisibilityPtr = shared_ptr<Visibility>;
45using ConstVisibilityPtr = shared_ptr<const Visibility>;
46
49class MX_CORE_API Look : public Element
50{
51 public:
52 Look(ElementPtr parent, const string& name) :
53 Element(parent, CATEGORY, name)
54 {
55 }
56 virtual ~Look() { }
57
60
68 MaterialAssignPtr addMaterialAssign(const string& name = EMPTY_STRING,
69 const string& material = EMPTY_STRING);
70
72 MaterialAssignPtr getMaterialAssign(const string& name) const
73 {
74 return getChildOfType<MaterialAssign>(name);
75 }
76
78 vector<MaterialAssignPtr> getMaterialAssigns() const
79 {
80 return getChildrenOfType<MaterialAssign>();
81 }
82
85 vector<MaterialAssignPtr> getActiveMaterialAssigns() const;
86
88 void removeMaterialAssign(const string& name)
89 {
90 removeChildOfType<MaterialAssign>(name);
91 }
92
96
102 PropertyAssignPtr addPropertyAssign(const string& name = EMPTY_STRING)
103 {
104 return addChild<PropertyAssign>(name);
105 }
106
108 PropertyAssignPtr getPropertyAssign(const string& name) const
109 {
110 return getChildOfType<PropertyAssign>(name);
111 }
112
114 vector<PropertyAssignPtr> getPropertyAssigns() const
115 {
116 return getChildrenOfType<PropertyAssign>();
117 }
118
121 vector<PropertyAssignPtr> getActivePropertyAssigns() const;
122
124 void removePropertyAssign(const string& name)
125 {
126 removeChildOfType<PropertyAssign>(name);
127 }
128
132
138 PropertySetAssignPtr addPropertySetAssign(const string& name = EMPTY_STRING)
139 {
140 return addChild<PropertySetAssign>(name);
141 }
142
145 {
146 return getChildOfType<PropertySetAssign>(name);
147 }
148
150 vector<PropertySetAssignPtr> getPropertySetAssigns() const
151 {
152 return getChildrenOfType<PropertySetAssign>();
153 }
154
157 vector<PropertySetAssignPtr> getActivePropertySetAssigns() const;
158
160 void removePropertySetAssign(const string& name)
161 {
162 removeChildOfType<PropertySetAssign>(name);
163 }
164
168
174 VariantAssignPtr addVariantAssign(const string& name = EMPTY_STRING)
175 {
176 return addChild<VariantAssign>(name);
177 }
178
180 VariantAssignPtr getVariantAssign(const string& name) const
181 {
182 return getChildOfType<VariantAssign>(name);
183 }
184
186 vector<VariantAssignPtr> getVariantAssigns() const
187 {
188 return getChildrenOfType<VariantAssign>();
189 }
190
193 vector<VariantAssignPtr> getActiveVariantAssigns() const;
194
196 void removeVariantAssign(const string& name)
197 {
198 removeChildOfType<VariantAssign>(name);
199 }
200
204
210 VisibilityPtr addVisibility(const string& name = EMPTY_STRING)
211 {
212 return addChild<Visibility>(name);
213 }
214
216 VisibilityPtr getVisibility(const string& name) const
217 {
218 return getChildOfType<Visibility>(name);
219 }
220
222 vector<VisibilityPtr> getVisibilities() const
223 {
224 return getChildrenOfType<Visibility>();
225 }
226
229 vector<VisibilityPtr> getActiveVisibilities() const;
230
232 void removeVisibility(const string& name)
233 {
234 removeChildOfType<Visibility>(name);
235 }
236
238
239 public:
240 static const string CATEGORY;
241};
242
245class MX_CORE_API LookGroup : public Element
246{
247 public:
248 LookGroup(ElementPtr parent, const string& name) :
249 Element(parent, CATEGORY, name)
250 {
251 }
252 virtual ~LookGroup() { }
253
255 void setLooks(const string& looks)
256 {
257 setAttribute(LOOKS_ATTRIBUTE, looks);
258 }
259
261 const string& getLooks() const
262 {
263 return getAttribute(LOOKS_ATTRIBUTE);
264 }
265
267 void setActiveLook(const string& look)
268 {
269 setAttribute(ACTIVE_ATTRIBUTE, look);
270 }
271
273 const string& getActiveLook() const
274 {
275 return getAttribute(ACTIVE_ATTRIBUTE);
276 }
277
278 public:
279 static const string CATEGORY;
280 static const string LOOKS_ATTRIBUTE;
281 static const string ACTIVE_ATTRIBUTE;
282};
283
286class MX_CORE_API MaterialAssign : public GeomElement
287{
288 public:
289 MaterialAssign(ElementPtr parent, const string& name) :
290 GeomElement(parent, CATEGORY, name)
291 {
292 }
293 virtual ~MaterialAssign() { }
294
297
299 void setMaterial(const string& material)
300 {
301 setAttribute(MATERIAL_ATTRIBUTE, material);
302 }
303
305 bool hasMaterial() const
306 {
307 return hasAttribute(MATERIAL_ATTRIBUTE);
308 }
309
311 const string& getMaterial() const
312 {
313 return getAttribute(MATERIAL_ATTRIBUTE);
314 }
315
319
321 void setExclusive(bool value)
322 {
323 setTypedAttribute<bool>(EXCLUSIVE_ATTRIBUTE, value);
324 }
325
327 bool getExclusive() const
328 {
329 return getTypedAttribute<bool>(EXCLUSIVE_ATTRIBUTE);
330 }
331
335
337 NodePtr getReferencedMaterial() const;
338
342
348 VariantAssignPtr addVariantAssign(const string& name = EMPTY_STRING)
349 {
350 return addChild<VariantAssign>(name);
351 }
352
354 VariantAssignPtr getVariantAssign(const string& name) const
355 {
356 return getChildOfType<VariantAssign>(name);
357 }
358
360 vector<VariantAssignPtr> getVariantAssigns() const
361 {
362 return getChildrenOfType<VariantAssign>();
363 }
364
367 vector<VariantAssignPtr> getActiveVariantAssigns() const;
368
370 void removeVariantAssign(const string& name)
371 {
372 removeChildOfType<VariantAssign>(name);
373 }
374 public:
375 static const string CATEGORY;
376 static const string MATERIAL_ATTRIBUTE;
377 static const string EXCLUSIVE_ATTRIBUTE;
378};
379
388class MX_CORE_API Visibility : public GeomElement
389{
390 public:
391 Visibility(ElementPtr parent, const string& name) :
392 GeomElement(parent, CATEGORY, name)
393 {
394 }
395 virtual ~Visibility() { }
396
399
401 void setViewerGeom(const string& geom)
402 {
403 setAttribute(VIEWER_GEOM_ATTRIBUTE, geom);
404 }
405
407 bool hasViewerGeom() const
408 {
409 return hasAttribute(VIEWER_GEOM_ATTRIBUTE);
410 }
411
413 const string& getViewerGeom() const
414 {
415 return getAttribute(VIEWER_GEOM_ATTRIBUTE);
416 }
417
421
423 void setViewerCollection(const string& collection)
424 {
425 setAttribute(VIEWER_COLLECTION_ATTRIBUTE, collection);
426 }
427
430 {
431 return hasAttribute(VIEWER_COLLECTION_ATTRIBUTE);
432 }
433
435 const string& getViewerCollection() const
436 {
437 return getAttribute(VIEWER_COLLECTION_ATTRIBUTE);
438 }
439
443
445 void setVisibilityType(const string& type)
446 {
447 setAttribute(VISIBILITY_TYPE_ATTRIBUTE, type);
448 }
449
451 bool hasVisibilityType() const
452 {
453 return hasAttribute(VISIBILITY_TYPE_ATTRIBUTE);
454 }
455
457 const string& getVisibilityType() const
458 {
459 return getAttribute(VISIBILITY_TYPE_ATTRIBUTE);
460 }
461
465
467 void setVisible(bool visible)
468 {
469 setTypedAttribute<bool>(VISIBLE_ATTRIBUTE, visible);
470 }
471
473 bool getVisible() const
474 {
475 return getTypedAttribute<bool>(VISIBLE_ATTRIBUTE);
476 }
477
479
480 public:
481 static const string CATEGORY;
482 static const string VIEWER_GEOM_ATTRIBUTE;
483 static const string VIEWER_COLLECTION_ATTRIBUTE;
484 static const string VISIBILITY_TYPE_ATTRIBUTE;
485 static const string VISIBLE_ATTRIBUTE;
486};
487
495MX_CORE_API vector<MaterialAssignPtr> getGeometryBindings(const NodePtr& materialNode, const string& geom);
496
497} // namespace MaterialX
498
499#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:35
shared_ptr< MaterialAssign > MaterialAssignPtr
A shared pointer to a MaterialAssign.
Definition: Look.h:38
shared_ptr< LookGroup > LookGroupPtr
A shared pointer to a LookGroup.
Definition: Look.h:33
shared_ptr< const MaterialAssign > ConstMaterialAssignPtr
A shared pointer to a const MaterialAssign.
Definition: Look.h:40
shared_ptr< const Visibility > ConstVisibilityPtr
A shared pointer to a const Visibility.
Definition: Look.h:45
shared_ptr< const Look > ConstLookPtr
A shared pointer to a const Look.
Definition: Look.h:30
shared_ptr< Visibility > VisibilityPtr
A shared pointer to a Visibility.
Definition: Look.h:43
shared_ptr< Look > LookPtr
A shared pointer to a Look.
Definition: Look.h:28
Material node helper functions.
Import and export declarations for the Core library.
shared_ptr< Node > NodePtr
A shared pointer to a Node.
Definition: Node.h:25
Property element subclasses.
shared_ptr< PropertySetAssign > PropertySetAssignPtr
A shared pointer to a PropertySetAssign.
Definition: Property.h:40
shared_ptr< PropertyAssign > PropertyAssignPtr
A shared pointer to a PropertyAssign.
Definition: Property.h:30
Variant element subclasses.
shared_ptr< VariantAssign > VariantAssignPtr
A shared pointer to a VariantAssign.
Definition: Variant.h:34
The base class for MaterialX elements.
Definition: Element.h:75
The base class for geometric elements, which support bindings to geometries and geometric collections...
Definition: Geom.h:154
A look group element within a Document.
Definition: Look.h:246
void setLooks(const string &looks)
Set comma-separated list of looks.
Definition: Look.h:255
const string & getLooks() const
Get comma-separated list of looks.
Definition: Look.h:261
void setActiveLook(const string &look)
Set the active look.
Definition: Look.h:267
const string & getActiveLook() const
Return the active look, if any.
Definition: Look.h:273
A look element within a Document.
Definition: Look.h:50
VariantAssignPtr getVariantAssign(const string &name) const
Return the VariantAssign, if any, with the given name.
Definition: Look.h:180
void removeMaterialAssign(const string &name)
Remove the MaterialAssign, if any, with the given name.
Definition: Look.h:88
vector< MaterialAssignPtr > getMaterialAssigns() const
Return a vector of all MaterialAssign elements in the look.
Definition: Look.h:78
PropertySetAssignPtr getPropertySetAssign(const string &name) const
Return the PropertySetAssign, if any, with the given name.
Definition: Look.h:144
VisibilityPtr getVisibility(const string &name) const
Return the Visibility, if any, with the given name.
Definition: Look.h:216
vector< PropertyAssignPtr > getPropertyAssigns() const
Return a vector of all PropertyAssign elements in the look.
Definition: Look.h:114
vector< PropertySetAssignPtr > getPropertySetAssigns() const
Return a vector of all PropertySetAssign elements in the look.
Definition: Look.h:150
void removeVisibility(const string &name)
Remove the Visibility, if any, with the given name.
Definition: Look.h:232
PropertyAssignPtr addPropertyAssign(const string &name=EMPTY_STRING)
Add a PropertyAssign to the look.
Definition: Look.h:102
void removePropertyAssign(const string &name)
Remove the PropertyAssign, if any, with the given name.
Definition: Look.h:124
PropertyAssignPtr getPropertyAssign(const string &name) const
Return the PropertyAssign, if any, with the given name.
Definition: Look.h:108
void removeVariantAssign(const string &name)
Remove the VariantAssign, if any, with the given name.
Definition: Look.h:196
MaterialAssignPtr getMaterialAssign(const string &name) const
Return the MaterialAssign, if any, with the given name.
Definition: Look.h:72
void removePropertySetAssign(const string &name)
Remove the PropertySetAssign, if any, with the given name.
Definition: Look.h:160
VisibilityPtr addVisibility(const string &name=EMPTY_STRING)
Add a Visibility to the look.
Definition: Look.h:210
vector< VisibilityPtr > getVisibilities() const
Return a vector of all Visibility elements in the look.
Definition: Look.h:222
VariantAssignPtr addVariantAssign(const string &name=EMPTY_STRING)
Add a VariantAssign to the look.
Definition: Look.h:174
PropertySetAssignPtr addPropertySetAssign(const string &name=EMPTY_STRING)
Add a PropertySetAssign to the look.
Definition: Look.h:138
vector< VariantAssignPtr > getVariantAssigns() const
Return a vector of all VariantAssign elements in the look.
Definition: Look.h:186
A material assignment element within a Look.
Definition: Look.h:287
const string & getMaterial() const
Return the material string for the MaterialAssign.
Definition: Look.h:311
VariantAssignPtr getVariantAssign(const string &name) const
Return the VariantAssign, if any, with the given name.
Definition: Look.h:354
void setExclusive(bool value)
Set the exclusive boolean for the MaterialAssign.
Definition: Look.h:321
void setMaterial(const string &material)
Set the material string for the MaterialAssign.
Definition: Look.h:299
bool getExclusive() const
Return the exclusive boolean for the MaterialAssign.
Definition: Look.h:327
void removeVariantAssign(const string &name)
Remove the VariantAssign, if any, with the given name.
Definition: Look.h:370
VariantAssignPtr addVariantAssign(const string &name=EMPTY_STRING)
Add a VariantAssign to the look.
Definition: Look.h:348
bool hasMaterial() const
Return true if the given MaterialAssign has a material string.
Definition: Look.h:305
vector< VariantAssignPtr > getVariantAssigns() const
Return a vector of all VariantAssign elements in the look.
Definition: Look.h:360
A visibility element within a Look.
Definition: Look.h:389
const string & getVisibilityType() const
Return the visibility type string of the element.
Definition: Look.h:457
void setVisible(bool visible)
Set the visible boolean of the element.
Definition: Look.h:467
bool hasVisibilityType() const
Return true if the given element has a visibility type string.
Definition: Look.h:451
const string & getViewerCollection() const
Return the viewer collection string of the element.
Definition: Look.h:435
bool getVisible() const
Return the visible boolean of the element.
Definition: Look.h:473
void setVisibilityType(const string &type)
Set the visibility type string of the element.
Definition: Look.h:445
bool hasViewerGeom() const
Return true if the given element has a viewer geom string.
Definition: Look.h:407
void setViewerGeom(const string &geom)
Set the viewer geom string of the element.
Definition: Look.h:401
bool hasViewerCollection() const
Return true if the given element has a viewer collection string.
Definition: Look.h:429
const string & getViewerGeom() const
Return the viewer geom string of the element.
Definition: Look.h:413
void setViewerCollection(const string &collection)
Set the viewer geom string of the element.
Definition: Look.h:423