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

    Dissipating fog volume

    Cinema 4D SDK
    python
    2
    2
    391
    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.
    • O
      ops
      last edited by

      Hello,
      I'd like to achieve a dissipating fog volume over time. I have a volume builder object parenting a simple sphere. I have tried applying the 'Display' Tag and setting the 'Visibility' to 0% on both the volume builder and the source sphere, but neither seems to make the fog volume disappear. The only way I could achieve the effect was to use the Fog Range Map Filter on the volume builder object and set the 'Min Output' and 'Max Output' to 0.0.

      Now with the python script, I don't know how I can access this range map filter object programmatically. I get the volume builder object through the doc.SearchObject().
      Any tips on how to obtain the filter object would be very helpful.
      And also if there's a better way to dissipate the fog, I would appreciate to know!
      Thanks in advance!!!

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

        Hey @ops,

        Thank you for reaching out to us. Please excuse the delayed reply. You must use the c4d.modules.volume.VolumeBuilder interface for what you want to do, specifically its GetInputObject method. You have to understand that a volume builder is not a singular object, but a virtual tree of objects, and most parameters are located on one of these child objects. Cinema 4D then only displays the parameters of the child objects inline in the GUI (i.e., description) of the Volume Builder object.

        5b76e06e-da90-4205-9e68-3e0ca7d14e8f-image.png
        Fig.I: The internal makeup of a Volume Builder object. The virtual hierarchy in form of Volume Filter is inaccessible both via the Object Manager and things like GeListNode.GetChildren(). Instead we must use the dedicate UI and API interface to access them.

        Cheers,
        Ferdinand

        Code

        """Sets the new min and max values of a Volume Builder fog range object.
        
        Must be run as a Script Manager script with a Volume Builder object selected.
        """
        
        import c4d
        
        doc: c4d.documents.BaseDocument  # The currently active document.
        op: c4d.BaseObject | None  # The primary selected object in `doc`. Can be `None`.
        
        #: The volume builder fog range object type. We currently do not expose a symbol for this.
        c4d.Ofograngemap = 1039862 
        
        def main() -> None:
            """Called by Cinema 4D when the script is being executed.
            """
            if not isinstance(op, c4d.modules.volume.VolumeBuilder):
                raise ValueError("The selected object is not a Volume Builder.")
            
            # Iterate over the objects in the Volume Builder 'Objects' parameter list.
            for i in range(op.GetInputObjectCount()):
                node: c4d.BaseList2D | None = op.GetInputObject(i)
                # Can happen for folders and on failure, there is no good way to distinguish between the two.
                if node is None:
                    continue
                
                # This is a fog range object, we could do here further checks to ensure it is the correct one.
                if node.GetType() == c4d.Ofograngemap:
                    print(f"{node[c4d.ID_VOLUMEFILTER_SDF_REMAP_NEW_MIN] = }")
                    print(f"{node[c4d.ID_VOLUMEFILTER_SDF_REMAP_NEW_MAX] = }")
        
                    # Set new values.
                    node[c4d.ID_VOLUMEFILTER_SDF_REMAP_NEW_MIN] = 0.5
                    node[c4d.ID_VOLUMEFILTER_SDF_REMAP_NEW_MAX] = 2.0
        
            #  Push an update event to Cinema 4D to refresh the user interface.
            c4d.EventAdd()
        
        if __name__ == '__main__':
            main()
        

        MAXON SDK Specialist
        developers.maxon.net

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