Page 1 of 1

How to get material's color and texture info

Posted: Fri Sep 24, 2021 10:48 am
by Mingfae Wong 20210811011621
Can anyone get me some hints that how to get the material's Reflectance 0/90 color and texture information?


my code:
scene = Cmaxwell(mwcallback_cb)
scene.readMXS(mxsFile)
materials = CmaxwellMaterialIterator() # read all materials into a list.
mat = materials.first(scene) # get the first item from the list.
while not mat.isNull():
name = mat.getName()
numLayers = mat.getNumLayers()
for i in range(numLayers[0]):
layer = mat.getLayer(i)
for b in range(layer.getNumBSDFs()[0]):
bsdfdata = layer.getBSDF(b)
reflectance_0_map = bsdfdata.getAttribute('reflectance_0_map')
print(reflectance_0_map[0])
mat = materials.next()

Re: How to get material's color and texture info

Posted: Sat Sep 25, 2021 2:30 am
by Harvey Fong
Ya sometimes the Maxwell API is like trying to solve a Sudoku puzzle. A lot of head scratching. I wish the documentation explained more because I waste so much time guessing.
Code: Select all
...
    for b in range(layer.getNumBSDFs()[0]):
        bsdfdata = layer.getBSDF(b)
        refldata = bsdfdata.getReflectance() # handle to instance of Creflectance
        refl_color, ok = refldata.getAttribute('color') # handle to instance of Cattribute
        if refl_color.activeType == MAP_TYPE_BITMAP:
            print('bitmap:',refl_color.textureMap)
        if refl_color.activeType == MAP_TYPE_RGB:
            print('rgb', refl_color.rgb)
    mat = materials.next()

Re: How to get material's color and texture info

Posted: Sat Sep 25, 2021 2:53 am
by Harvey Fong
if you need reflectance 90 then use
Code: Select all
refl_color, ok = refldata.getAttribute('color.tangential')

Re: How to get material's color and texture info

Posted: Mon Sep 27, 2021 5:23 am
by Mingfae Wong 20210811011621
ok, thank you Harvey.