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

    Create a dynamic list of structs or BaseContainers

    Cinema 4D SDK
    c++
    3
    4
    736
    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.
    • R
      rui_mac
      last edited by

      I need to create a dynamic list of data that will be populated with a variable number of elements, in the InitRender method of a shader.
      I need to store a few Float values, an Int32 and a Matrix, so, I can use a struct of a BaseContainer.
      Maybe the BaseContainer is the best method as I can add to the BaseContainer another BaseContainer, creating a hierarchy that I can travel through, starting with the parent Container.
      What do you guys think? Am I thinking correctly?

      i_mazlovI 1 Reply Last reply Reply Quote 0
      • S
        spedler
        last edited by

        Why not just use a BaseArray of the data structures you want to use? Re-initialise this every time InitRender is called then you can iterate through it when needed (presumably in the Output function?).

        You’ll also need to implement CopyTo() to make sure the data is available when rendering to the picture viewer.

        Steve

        R 1 Reply Last reply Reply Quote 0
        • R
          rui_mac @spedler
          last edited by

          @spedler said in Create a dynamic list of structs or BaseContainers:

          Why not just use a BaseArray of the data structures you want to use? Re-initialise this every time InitRender is called then you can iterate through it when needed (presumably in the Output function?).

          You’ll also need to implement CopyTo() to make sure the data is available when rendering to the picture viewer.

          Steve

          That could be a good option but I need a list to different types of values. I could create an array of structs but I believe the BaseContainer already has everything I need.
          If I create the BaseContainer as a public variable inside my plugin shader class, it will be available to the Output function?

          1 Reply Last reply Reply Quote 0
          • i_mazlovI
            i_mazlov @rui_mac
            last edited by

            Hi @rui_mac,

            As long as it fits your needs there's nothing to add against using BaseContainers in your case. However, if you don't need to store hierarchical data, the simpler approach of using BaseArray can sometimes end up in a cleaner implementation.

            You can use the generic Data type to handle values of different types.

            Cheers,
            Ilia

            MAXON SDK Specialist
            developers.maxon.net

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