print("Executing material script!")
newScene()
loadGeometry("$VRED_EXAMPLES/geo/teddy.osb")
calcVertexNormals()
updateScene()
fur = findMaterial("fur_white")
fur.fields().setVec3f("diffuseColor", 0.3, 0.2, 0.5)
fur.fields().setVec3f("specularColor", 0.2, 0.1, 0.8)
This example script loads the teddy geometry found in the VRED Examples folder, then looks for the fur material, fur_white
, and makes changes to the diffuse and specular color, using these new values. The fur.fields().setVec3f
indicates the object (fur
), its properties (fields
), and the value type (setVec3f
) for it. You add the name of the property and provide the values for the value type.
Since there are an assortment of value types, you need to know the value type for a property. Use the Node Editor to get this. Drag a material from the Material Editor into the Node Editor, then hover over the value (right column) for a specific property (left column). The value's tooltip provides the value type for the property.
For example, in the image, SFInt8 is the value type. To change the lightMode property of the fur, you would use fur.fields().setInt8("lightMode", 1).
For further help, please refer to the vrFieldAccess documentation in the Python docs. This will provide the return type of a field. This is helpful for getting to know which functions to call.
Do not expect the UI to update immediately, though rendering might, since updates to the UI can negatively impact rendering performance.