Graphics

 View Only
  • 1.  User Input Controls to Change Materials by Name

    Posted 03-16-2017 22:33
    Hello,

    I was wondering if it was possible to change a material using the User Input Controls Table system by name. I know this is possible to change materials if the table has file paths (like explained in XPression U 115), but I was trying to use Material Names instead of file paths, and it does not seem to work. Just curious if this is possible, especially for color/gradient shaders in your project that aren't tied to a file path.

    Thanks again for any help


  • 2.  RE: User Input Controls to Change Materials by Name

    Posted 03-17-2017 09:23
    Hello Jerrylu,

    Natively I don't think it's possible but you can certainly get it to work using Visual Logic or scripting.

    You would then create a dummy text object which is invisible in your scene, but where you could use the textvalue inside visual logic to select the correct material or you could use a little script in the scene to set the material based on the name you have entered in your textobject.

    In scripting the code would be something like:

    dim objToChangeMaterial as xpBaseObject
    dim txtObj as xpTextObject
    dim mat as xpMaterial

    ' LINK THE OBJECTS IN THE SCENE
    Scene.GetObjectByName("[the_name_of_your_dummy_text_object]", txtObj)
    Scene.GetObjectByName("[the_name_of_the_object_you_want_to_change_the_material_of]", objToChangeMaterial)

    ' GET THE MATERIAL YOU WOULD LIKE TO USE
    engine.getMaterialByName(txtObj, mat)

    ' SET THE MATERIAL ON THE OBJECT YOU WANT TO CHANGE THE MATERIAL OF
    objToChangeMaterial.setMaterial(0, mat)

    That should do it.
    I'm writing this out of the top of my head so I haven't tested this but I think it should work.

    You could copy this code into the OnOnline tab of the Scene script page.

    In Visual Logic you would have to use some comparisons to check whether or not it is found in some predefined values that you have defined which would make it a bit complicated and less dynamic. But it's up tp you.

    Cheers,
    Kenneth


    #XPression


  • 3.  RE: User Input Controls to Change Materials by Name

    Posted 03-17-2017 16:42
    Thanks for the help cainnech.

    I understand what you're saying with the script. I just had hoped this was built into the program because you can DataLinq materials by name.

    Thanks again though,
    Jerry
    #XPression


  • 4.  RE: User Input Controls to Change Materials by Name

    Posted 03-20-2017 00:08
    Hi Jerry, This will be available in an upcoming version of XPression.
    #XPression


  • 5.  RE: User Input Controls to Change Materials by Name

    Posted 03-20-2017 16:12
    Hello Jerry,

    The method described above will work very well with user input controls. (until the feature is released)

    Just un-publish the material face of the object, and use the script / controls to change the videos you are looking for. (In the past we used a drop down list for various news states (like weather warnings)).

    This will constrain the operators to those values assigned however.

    Peter
    #XPression


  • 6.  RE: User Input Controls to Change Materials by Name

    Posted 03-21-2017 11:42
    Or just :


    dim txtObj as xpTextObject
    Scene.GetObjectByName("[the_name_of_your_dummy_text_object]", txtObj)

    Scene.SetObjectPropertyString("[the_name_of_the_object_you_want_to_change_the_material_of]", "Material", txtObj.Text);

    #XPression


  • 7.  RE: User Input Controls to Change Materials by Name

    Posted 03-30-2017 20:19
    XPression beta version 6.7 3763 has added this as a new feature:

    • [implemented] user input controls can now be used to assign global materials to quad objects (in addition to image file paths already supported)

    #XPression