I am looking to change the texture of a material on a quad based on a value from a datalinq. I have a list of names and I’d like to change an image based on those names. The datalinq does not include a filepath for those images.
For Example:
If I have “JOHNSMITH” as the value from my Datalinq, then how to change the image to “P:\GRAPHICS\JOHNATHANSMITH.png”
I know materials can read a filepath from a datalinq, but is there a way to supply it through scripting? Or do I need to make a bunch of materials and set them based on the name value? Thanks!
At its most basic you can do something like this onOnline.
dim plyrImg as xpBaseObject
self.GetObjectByName(“Img1”, plyrImg)
plyrImg.SetVolatileTextureFile(0, P:\GRAPHICS\JOHNATHANSMITH.png")
If you want to add variables to it you can do something like.
dim plyrImg as xpBaseObject
dim tricode, filepath, first, last, uni as xpTextObject
self.GetObjectByName(“FirstName”, first)
self.GetObjectByName(“LastName”, last)
self.GetObjectByName(“Tricode”, tricode)
self.GetObjectByName(“FilePath”, filepath)
self.GetObjectByName(“UNI”, uni)
self.GetObjectByName(“Img1”, plyrImg)
plyrImg.SetVolatileTextureFile(0,filepath.Text & tricode.Text & "" & tricode.Text & “" & last.Text & "” & first.Text & “GS” & uni.Text & “_Img.png”)
You should now be able to do this via Dynamic Materials.
Make a hidden text field that is fed by datalinq, for example Name1, then your dynamic material has the filepath to the folder and references @Name1@.png
Hope this makes sense!
-m
Can Dynamic Material update the image when the scene is online state?
I am not able to achieve that. So a way around I found was to use datalinq on the image and then use ‘Prepend & Append’ to enter the image path.
They can if you use macros for the path such as @Text1@ and that text object is linked to data.
Make sure to check the “Requery scene datalinqs on data change” box in the Datalinq properties of your Text Object if you plan to use it as a @TextObject@ macro on another object. This way if your data changes while the scene is on the air, the macros in other Datalinq or Dynamic Material paths will update as well.