Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Texture file sequence, get exact filename per frame

    Cinema 4D SDK
    c++
    4
    8
    1.1k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • F
      Filip
      last edited by

      Hi!
      For a render engine plugin, I would like to support animations (file sequences) as textures. In the bitmap shader, there are settings for animation, and c4d the automatically parses the texture file name to identify the frame number part which is modified per frame to render the appropriate texture.

      Is there anyway to get, for a given Bitmap shader and timepoint (BaseTime or frame), the exact texture name that c4d would load for rendering?

      We could try to reverse engineer this of course, but it would be really convenient and more robust if there was a function for accessing this.

      Thanks!
      /Filip

      1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand
        last edited by ferdinand

        Hi,

        I am not sure if that helps, but BaseShader::GetBitmap returns the correct bitmap. I do not have any image sequences lying around here, but I would assume it also does work there. The interpolation offset is determined by the document time of the BaseDocument you are passing to BaseShader::InitRender. As a Python example (I left out all the ifs and whens), the first material needs to be a standard material with some kind of movie in the color channel. Scrubbing the timeline and executing the script will cause it to open the corresponding frame of that movie in the Picture Viewer.

        You could then try to get the filename from that BaseBitmap. BASEBITMAP_DATA might be helpful in that context.

        Cheers,
        zipit

        import c4d
        
        
        def main():
            """
            """
            material = doc.GetFirstMaterial()
            shader = material[c4d.MATERIAL_COLOR_SHADER]
            
            irs = c4d.modules.render.InitRenderStruct(doc)
            shader.InitRender(irs)
            bitmap = shader.GetBitmap()
            shader.FreeRender()
            c4d.bitmaps.ShowBitmap(bitmap)
        
        if __name__=='__main__':
            main()
        

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 0
        • F
          Filip
          last edited by

          Thanks for the input zipit!

          That is promising, but unfortunately does not quite help in my case as I really need the filename rather than the bitmap itself. The rendering in my plugin is also, for various good reasons, not guaranteed to happen within a InitRender()/FreeRender() context.

          /Filip

          1 Reply Last reply Reply Quote 0
          • ferdinandF
            ferdinand
            last edited by ferdinand

            Hi,

            jeah, I already suspected something like that; that is why included the link to BASEBITMAP_DATA. With BaseBitmap::GetData you can access these attribute, including several frame related attributes. The whole thing is flagged as private in both the C++ and Python docs, which usually means that things won't be as easy as one might think, which is why I did not really bother to go down that rabbit hole.

            Not quite sure about the InitRender part. If you want to interpret a Xbitmap BaseShader like Cinema would, you will have to sample it, i,e. init that shader for rendering. Everything else would be an eating the cake without eating it scenraio.

            Cheers,
            zipit

            MAXON SDK Specialist
            developers.maxon.net

            1 Reply Last reply Reply Quote 0
            • P
              PluginStudent
              last edited by

              That BASEBITMAP_DATA stuff is related to rendering information when a bitmap is displayed in the Picture Viewer (BaseBitmap Manual).

              ferdinandF 1 Reply Last reply Reply Quote 0
              • ferdinandF
                ferdinand @PluginStudent
                last edited by

                @PluginStudent said in Texture file sequence, get exact filename per frame:

                That BASEBITMAP_DATA stuff is related to rendering information when a bitmap is displayed in the Picture Viewer (BaseBitmap Manual).

                Oh, I did not know that. Thanks for the link.

                MAXON SDK Specialist
                developers.maxon.net

                1 Reply Last reply Reply Quote 0
                • r_giganteR
                  r_gigante
                  last edited by

                  Hi @Filip , thanks for reaching out us.

                  With regard to your question, I confirm there's no available method in our API that provides you with the exact name of the bitmap used at a certain frame.
                  The information about which exact bitmap to fetch from the sequence of textures set in the BitmapShader, is instead calculated programmatically given the data stored in

                      BITMAPSHADER_TIMING_FROM
                      BITMAPSHADER_TIMING_TO
                      BITMAPSHADER_TIMING_FPS
                      BITMAPSHADER_TIMING_TIMING
                      BITMAPSHADER_TIMING_MODE
                      BITMAPSHADER_TIMING_LOOPS
                      BITMAPSHADER_TIMING_RANGEFROM
                      BITMAPSHADER_TIMING_RANGETO
                  

                  Best, R

                  F 1 Reply Last reply Reply Quote 0
                  • F
                    Filip @r_gigante
                    last edited by

                    @r_gigante Thanks for confirming. We will try to reverse engineer the filenames based on that data.

                    Cheers
                    /Filip

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post