ZeBoxx2
07-30-2008, 04:15 PM
so given...
myMat = meditmaterials[1]
01 - Default:Standard
myMap = Noise()
Noise:Noise
myMat.diffuseMap = myMap
Noise:Noise
You want to know how, if you have 'myMap', to get to 'myMat'?
dependentRefs = refs.dependents myMap
#(ReferenceTarget:ReferenceTarget, 01 - Default:Standard, ReferenceTarget:Material_Editor, ReferenceTarget:Scene)
mats = for ref in dependentRefs where (superClassOf ref == material) collect ( ref )
#(01 - Default:Standard)
mats[1]
01 - Default:Standard
Even if you nest the map inside other maps, that should still work:
myMat.diffuseMap = Mix()
Mix:Mix
myMat.diffuseMap.map1 = myMap
Noise:Noise
dependentRefs = refs.dependents myMap
#(Mix:Mix, ReferenceTarget:ReferenceTarget, 01 - Default:Standard, ReferenceTarget:Material_Editor, ReferenceTarget:Scene)
mats = for ref in dependentRefs where (superClassOf ref == material) collect ( ref )
#(01 - Default:Standard)
mats[1]
01 - Default:Standard
If it's inside a nested material, you basically hit the same problem as the thread you referenced; although I would check into a more robus method of trying to find your map (unless you can make the same assumptions as in that thread).
You may or may not hit a problem if a user instances the map, however - as I don't think there is a way to get the 'parent' of the map as it will have more than one:
anotherMat = meditmaterials[2]
02 - Default:Standard
anotherMat.diffuseMap = newMap
Noise:Noise
dependentRefs = refs.dependents myMap
#(Mix:Mix, ReferenceTarget:ReferenceTarget, 01 - Default:Standard, ReferenceTarget:ReferenceTarget, 02 - Default:Standard, ReferenceTarget:Material_Editor, ReferenceTarget:Scene)
mats = for ref in dependentRefs where (superClassOf ref == material) collect ( ref )
#(01 - Default:Standard, 02 - Default:Standard)
Which would be especially problematic if you have a multi/sub material and, say, the map is instanced to the second material - already being present in the first material. If you simply loop over things, the fist submat is what would be returned as having your map in it; thus ignoring the second material.
How to handle that situation (which may not actually occur where you use it) will depend on what the map does, etc. You might set a flag on any material you have already processed, for example, so that any loop you may use will ignore materials that are flagged until it finds the one it hasn't processed yet (indicating that the map would be new to that material).
It's entirely possible I missed something glaringly obvious the documentation, however :)
dandymite
07-30-2008, 04:28 PM
Hi ZeBoxx2,
thank you very much for the quick and detailed answer. I will check it out tomorrow an hope I can fix my problem with this information.
Thank you
dandymite
07-31-2008, 08:28 AM
Hi ZeBoxx2
I just try it and it works. Great. Thank you very much again.
Greets Stephan
CGTalk Moderation
07-31-2008, 08:28 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.