How do I set Opacity Strength in script?

I have a simple plane surface with an image set-up using the "diffuse color" property. I'm using this as a semi-transparent reference for setting up poses.

I can get and manipulate translations of that node in script, now I want to set the "Opacity Strength" of that node.

 

var item = Scene.findNodeByLabel( "TORI" );// Transparancy Object Reference Item

 

How to I access and set the "Opacity Strength" of that node?

 

Comments

  • Richard HaseltineRichard Haseltine Posts: 100,747

    use getObject() on the prop (if it's a bonme on a figure you will need to use getSkeleton() first, since the geometry belongs to the figure), then use getCurrentShape() on the object to get the shape and from that getAllMaterials() to get ana rray with the materials, on which you can finally use setBaseOpacity( value )

  • a_s_lorda_s_lord Posts: 33

     

     

    That works a treat, you are a star!

    I've included a test function (ignore the style) for anyone who is interested. Call the function with small increments such as:

    trans(+0.1)

     

     

    function trans( increment )

    {

    var item = Scene.findNodeByLabel( "TORI" );// Transparancy Object Reference Item

    var obj = item.getObject();

    var shp = obj.getCurrentShape();

    var mat = shp.getAllMaterials();

    mat[ 0 ].setBaseOpacity(mat[ 0 ].getBaseOpacity() + increment);

    }

Sign In or Register to comment.