Profile Picture

Is there a way to change an image on a plane via Python?

Posted By Data Juggler 3 Years Ago
You don't have permission to rate!

Is there a way to change an image on a plane via Python?

Author
Message
Data Juggler
Data Juggler
Posted 3 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (12.4K reputation)Distinguished Member (12.4K reputation)Distinguished Member (12.4K reputation)Distinguished Member (12.4K reputation)Distinguished Member (12.4K reputation)Distinguished Member (12.4K reputation)Distinguished Member (12.4K reputation)Distinguished Member (12.4K reputation)Distinguished Member (12.4K reputation)

Group: Forum Members
Last Active: 3 hours ago
Posts: 1.7K, Visits: 5.4K
To be specific, the title should say at given frames. So it starts on one and changes to another at frame x.

Someone asked this question about how to animate a plane's texture, meaning change the image at frame x and at frame y use another image in the forum, and I volunteered I thought this could be useful for a "slide show" creator or a dance floor that changes with the music, etc.
After I started building it I realized I don't see a way.

I looked through all my python scripts and read the documentation here:
https://wiki.reallusion.com/IC_Python_API:RLPy_RIMaterialComponent#AddDiffuseKey_.28_self.2C_kKey.2C_strMeshName.2C_strMaterialName.2C_kColor_.29

The closest I have is to set the glow channel at a given frame, the AddTextureWeightKey lets you change the weight (strength) of the channel, but not the image itself 

   material_component = prop.GetMaterialComponent()
    mesh_list = prop.GetMeshNames()
    mesh_name = mesh_list[0]
    material_list = material_component.GetMaterialNames(mesh_name)
    material_name = material_list[0]
    #Load image to material channel
    texture_channel = RLPy.EMaterialTextureChannel_Diffuse
    # apply the material
    result = material_component.LoadImageToTexture(mesh_name, material_name, texture_channel, materialPath)
    key = RLPy.RKey()
    key.SetTime(FrameTime)
    diffuse_weight = 1 
    material_component.AddTextureWeightKey(key, mesh_name, material_name, texture_channel, diffuse_weight)


The closest I found was this, which lets you change a color at a given frame. Is there a way to do this to change an image at a given frame?

This is for an avatar, but most of this works the same for props.

avatar_list = RLPy.RScene.GetAvatars()
avatar = avatar_list[0]
material_component = avatar.GetMaterialComponent()
mesh_list = avatar.GetMeshNames()
mesh_name = mesh_list[0]
material_list = material_component.GetMaterialNames(mesh_name)
material_name = material_list[0]
# Create a key
key = RLPy.RKey()
key.SetTime(RLPy.RTime(1200))
# Add a diffuse key value
material_component.AddDiffuseKey(key, mesh_name, material_name, RLPy.RRgb.RED)

I thought of a couple of work arounds if it isn't possible.

1. As Gerry suggested, create duplicate planes, and hide / show at certain frames.
2. Set the first texture, render each clip via Python (which I read about but never tried) and change the texture and render again, repeat.
I like Option 1 better because I know how to do it (I think), and for the WYSIWYG value (IClone will be updated in design mode with option 1).

Thanks if anyone knows a way or has a better workaround.

I modified this Theater prop I purchased, and I was already for a slide show, and ran into a 'I don't know how to do this in Python'.
https://forum.reallusion.com/uploads/images/6340262d-82fa-417d-8691-4091.png



Creator of the free website:
PixelDatabase.Net
A Free Online Text Based Image Editor
https://forum.reallusion.com/uploads/images/6e6663e2-0ecf-447a-ab3d-d49d.png

Edited
3 Years Ago by Data Juggler
videodv
videodv
Posted 3 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)Distinguished Member (2.7K reputation)

Group: Forum Members
Last Active: Last Year
Posts: 342, Visits: 12.0K
I dont believe you can change the textures on different frames on the timeline at this time.
It is something I asked about sometime ago as I had an idea for a script where the texture changed on different frames bit could not get it to work.
Maybe they will update this soon?

Chris.
Data Juggler
Data Juggler
Posted 3 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (12.4K reputation)Distinguished Member (12.4K reputation)Distinguished Member (12.4K reputation)Distinguished Member (12.4K reputation)Distinguished Member (12.4K reputation)Distinguished Member (12.4K reputation)Distinguished Member (12.4K reputation)Distinguished Member (12.4K reputation)Distinguished Member (12.4K reputation)

Group: Forum Members
Last Active: 3 hours ago
Posts: 1.7K, Visits: 5.4K
I guess I will go with a clone and hide pattern.

I would rank this feature of changing a texture on the timeline and also finding the child props for a prop should be a higher priority than the new features that have been requested in this recent Python feature request contest.

Seems like this would be pretty easy for them to implement this.

Thanks for the reply. 

Corby

Creator of the free website:
PixelDatabase.Net
A Free Online Text Based Image Editor
https://forum.reallusion.com/uploads/images/6e6663e2-0ecf-447a-ab3d-d49d.png




Reading This Topic