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
    • Register
    • Login

    Negative Vertex Map values

    General Talk
    python r25
    2
    3
    560
    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.
    • P
      pyr
      last edited by

      i use a vertext map to manipulate the motion blur in redshift from an object. positive directions are no problem, but the vertext map only seems to store positive values. manipulating it afterwards via python script didn't help either.

      which surprises me in particular because the documentation mentions a float as the data type.

      in other tools it is easily possible to use negative float values to create the desired effect.

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

        Hey @pyr,

        Thank you for reaching out to us. I am a bit perplexed by this topic, as there is no real question here.

        The vertex maps of Cinema are usually defined in the closed interval [0, 1] (which is reflected as [0%, 100%] for the end user). We could of course have also chosen the interval to be [-1, 1] (standard interval), but we decided to go with the so-called half-standard-interval, that is just how it is.

        Not quite sure what to make out of your float comment. There is no such thing as a ufloat (unsigned float) in C because it does not make sense machine code wise. And you are on top of that here working with Python which does not really care about the whole unsigned concept in the first place (there is no uint in Python).

        If you want this to be changed, then end-user-support would be the right place to ask this for. They can probably also help you with your Redshift-Motion-Blur-thing (which is not obviously clear to me and also not an SDK topic).

        With all that being said, you can write values outside of that interval. It just might be that systems reading in such values might clamp them to the [0, 1] interval with is usually used. But there are some systems which also accept negative values. You would have to ask customer support about the details of the Redshift vertex map values.

        Because of it is ambivalent nature, I have moved this topic into General Talk.

        Cheers,
        Ferdinand

        Result

        Running the script twice: The negative values we wrote persist.
        424fa464-3b33-4195-979f-796967068d99-image.png

        Code

        """Demonstrates writing values outside of the standard half-interval [0, 1] to a vertex map.
        """
        
        import c4d
        from mxutils import CheckType
        
        doc: c4d.documents.BaseDocument  # The currently active document.
        op: c4d.BaseObject | None  # The primary selected object in `doc`. Can be `None`.
        
        def main() -> None:
            """Called by Cinema 4D when the script is being executed.
            """
            # Makre sure the selected object is a polygon object and either get the existing vertex map tag 
            # or create a new one.
            CheckType(op, c4d.PolygonObject)
            tag: c4d.VariableTag = CheckType(op.GetTag(c4d.Tvertexmap) or 
                                             op.MakeVariableTag(c4d.Tvertexmap, op.GetPointCount()))
            
            # Get the vertex data from the tag and print the first 5 values.
            data: list[float] = tag.GetAllHighlevelData()
            print (data[:5 if len(data) > 5 else len(data)])
        
            # Now set a gradient of values from -1 to 1 based on the x position of each point.
            for i, p in enumerate(op.GetAllPoints()):
                data[i] = c4d.utils.RangeMap(p.x, -250., 250., -1., 1., True)
        
            # Write the data back.
            tag.SetAllHighlevelData(data)
            tag.Message(c4d.MSG_UPDATE)
            c4d.EventAdd()
        
        if __name__ == '__main__':
            main()
        

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 1
        • ferdinandF ferdinand moved this topic from Cinema 4D SDK on
        • P
          pyr
          last edited by

          hey,

          found the error. works exactly as i had planned. my code was correct, but i forgot to switch off use fields on the new vertex i mapped.

          thanks for the help anyway!

          grafik.png

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