Community
Hi,
is there a way to call the "Get values from object"-Method (yes, that is connected to the guiButton in MaterialEditor in TireMaterials under TextureSettings)?
Thanx
Best regards Marc
Solved! Go to Solution.
Solved by marc.winter2. Go to Solution.
Thx to @michael_nikelsky for the codeSamples
import vrMaterialPtr, vrNodeUtils
def updateTireMaterials():
for tempMaterial in vrMaterialPtr.getAllMaterials():
if tempMaterial.getType() == 'UTireMaterial':
for tempNode in tempMaterial.getNodes():
if tireMaterialGetValuesFromObject(tempNode):
break
def tireMaterialGetValuesFromObject(_tireNode):
if _tireNode is None or not _tireNode.isValid():
return False
print('tireMaterialGetValuesFromObject: ' + _tireNode.getName())
tempMaterial = _tireNode.getMaterial()
if not tempMaterial.isValid():
return False
tempCenter = vrNodeUtils.getBoundingBoxCenter(_tireNode, False)
tempGlobalBbox = _tireNode.getBoundingBox()
tempLengths = [tempGlobalBbox[3]-tempGlobalBbox[0], tempGlobalBbox[4]-tempGlobalBbox[1], tempGlobalBbox[5]-tempGlobalBbox[2]]
tempArea = [tempLengths[1]*tempLengths[2], tempLengths[0]*tempLengths[2], tempLengths[0]*tempLengths[1]]
tempAxis = 0
if tempArea[1] > tempArea[0] and tempArea[1] > tempArea[2]:
tempAxis = 1
tempMarkingsScale = 1000.0 / min(tempLengths[0], tempLengths[2])
elif tempArea[2] > tempArea[0] and tempArea[2] > tempArea[1]:
tempAxis = 2
tempMarkingsScale = 1000.0 / min(tempLengths[0], tempLengths[1])
else:
tempMarkingsScale = 1000.0 / min(tempLengths[1], tempLengths[2])
tempRepeatV = 1000.0 / (tempLengths[tempAxis])
tempRepeatU = 15.0
tempBlendPos = 0.8
tempAnisotropy = 11.0
tempMaterial.fields().setInt32('rotationAxis', tempAxis)
tempMaterial.fields().setVec3f('mappingCenter', tempCenter.x(), tempCenter.y(), tempCenter.z())
tempMaterial.fields().setReal32('repeatU', tempRepeatU)
tempMaterial.fields().setReal32('repeatV', tempRepeatV)
tempMaterial.fields().setReal32('markingsScale', tempMarkingsScale)
tempMaterial.fields().setReal32('blendPosition', tempBlendPos)
tempMaterial.fields().setReal32('anisotropy', tempAnisotropy)
return True
Can't find what you're looking for? Ask the community or share your knowledge.