Hi Ferdinand and Maxime,
I think I was unclear when asking the last question, my bad. I get that the issue would be that we would essentially have a Filename
that does not resolve if the image was in working memory (using a RamDisk
or a MemoryFileStruct
) and then shut down and re-launched Cinema 4D. I was originally wondering if we could trigger a function (probably using the modifier Message
function) when saving the scene to save the image on the physical disk at that point, and change the Filename
in the shader accordingly. However we've decided not to try putting the image in memory at all, and directly save it to the disk. I'll try to explain what we're trying to achieve so the situation is a bit clearer, I would love your input on this.
We currently have an object consisting of a stack that performs computations. We are implementing functionality so that the entire stack can be baked into a single object, which helps speed up computations. The collapse is reversible, so we want the user to be able to "unbake" the object. We also want the user to be able to save the stack to the physical disk as a "baked" object. If one of the objects in the stack (let's call it object A) uses a texture, we save the texture as an image with the baked object. We essentially serialize the image and use it in the calculations, then save it to the physical disk. However, if the user "unbakes" the object, we need to take the serialized image and generate a texture for object A to use. The texture could be an image found on the disk, a gradient created in C4D, some procedurally generated image, etc.
What we are currently considering is to simply save the texture as an image at the moment that the stack is baked, and use a Filename
pointing to it if the stack is unbaked. However, if the scene had not been saved before, we would have to create the image as a temp file and copy it to wherever the scene is saved on the disk afterwards. Is there something I might be missing in the Cinema 4D SDK that could improve this approach, or even be a better way to handle the situation?
Thanks a lot for the help,
Daniel