Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python 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

    HUD on OpenGl previews

    General Talk
    python
    2
    10
    1.8k
    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.
    • A
      ashambe
      last edited by ashambe

      Hi guys,

      As you may know, c4d doesn't allow adding watermark post-effect (project name, Time Code...) to OpenGl render engine.
      I'm trying to do this in python. but no luck!

      I've tried to add text objects that print the required attributes and attach them to the camera, but when adding DOF Effect in Enhanced OpenGL mode the text objects will disappear because they are simply out of focus.

      I've also tried to add a custom HUD but unfortunately, HUDs don't render in OpenGL renderer too.

      Until recently I discovered that realflow for c4d plugin add a special HUD that shows the particles count, fluid name.... and it renders in OpenGL!

      1. How could I add such and HUD in python

      2. if this is complicated could I exclude an object from being affected by DOF effect in python?

      Your Help is much appreciated.

      1 Reply Last reply Reply Quote 0
      • M
        m_adam
        last edited by

        Hi @ashambe,

        you can render HUD in OpenGL it's true that the Options tabs are not displayed if the render engine is set to OpenGL but if you defined it in standard (or even have the option container selected) then switch to OpenGL you can still access the Render HUD option.

        With that's said you can have a Python Script that draws HUD text.
        Here an example

        import c4d
        #Welcome to the world of Python
        
        
        def draw(bd):
            values = []
        
            # All txt to display
            txtList = [doc.GetActiveRenderData().GetName(), doc.GetDocumentName(), doc.GetFirstObject().GetName()]
            
            # Adds txt for each frame
            position = bd.GetSafeFrame()
            for x in xrange(len(txtList)):
                pos = c4d.Vector(position["cl"] + 2, 20 + 25 * x, 0)
                tmpDict = { "_txt" : txtList[x], "_position" : pos}
                values.append(tmpDict)
        
            # Sets the matrix to screen space
            bd.SetMatrix_Screen()
        
            # Enables depth buffer.
            bd.SetDepth(True)
        
            # Draws points indices at point coordinates
            bd.DrawMultipleHUDText(values)
        
            return True
        
        def main():
            pass  #put in your code here
        

        And the attached scene with the code and the settings already enabled.
        renderHud.c4d

        Cheers,
        Maxime.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        A 2 Replies Last reply Reply Quote 0
        • A
          ashambe @m_adam
          last edited by

          @m_adam
          Thanks gana try them both, much appreciated.

          1 Reply Last reply Reply Quote 0
          • A
            ashambe @m_adam
            last edited by ashambe

            @m_adam
            I've triedthe custom python script that draws HUD text but i'm stucked in the same original problem, The DOF effect is affecting the new HUDs which are blurred out 😢
            I've tried to change the value of the bd.SetDepth to False but no luck.

            M 1 Reply Last reply Reply Quote 0
            • M
              m_adam @ashambe
              last edited by m_adam

              @ashambe May I ask you in which version and OS (with version) are you?

              Using the next code is working nicely in R21.1

                  # Disables depth buffer.
                  bd.SetDepth(False)
              
                  # Draws points indices at point coordinates
                  bd.DrawMultipleHUDText(values)
                  
                  # Enables depth buffer.
                  bd.SetDepth(True)
              

              Cheers,
              Maxime.

              MAXON SDK Specialist

              Development Blog, MAXON Registered Developer

              A 1 Reply Last reply Reply Quote 0
              • A
                ashambe @m_adam
                last edited by

                Hey @m_adam
                I'm Using r20 windows 10, Thanks a lot m_adam

                1 Reply Last reply Reply Quote 0
                • M
                  m_adam
                  last edited by

                  Hi @ashambe may I ask your code because here I'm not able to reproduce it with bd.SetDepth(False) in Win 10 R20.

                  Cheers,
                  Maxime.

                  MAXON SDK Specialist

                  Development Blog, MAXON Registered Developer

                  A 1 Reply Last reply Reply Quote 0
                  • A
                    ashambe @m_adam
                    last edited by

                    @m_adam
                    Hi, I'm testing the same code you've provided!

                    1 Reply Last reply Reply Quote 0
                    • M
                      m_adam
                      last edited by m_adam

                      Yes the code I provided didn't work but with

                          # Disables depth buffer.
                          bd.SetDepth(False)
                      
                          # Draws points indices at point coordinates
                          bd.DrawMultipleHUDText(values)
                          
                          # Enables depth buffer.
                          bd.SetDepth(True)
                      

                      It worked.

                      Can you share a scene, please?
                      What's your exact version (including subversion not only R20 but R20.XX) of Windows/Driver/Cinema 4D?
                      Since I can't reproduce, without more information I can't help you.

                      Cheers,
                      Maxime.

                      MAXON SDK Specialist

                      Development Blog, MAXON Registered Developer

                      A 1 Reply Last reply Reply Quote 0
                      • A
                        ashambe @m_adam
                        last edited by

                        @m_adam
                        Ah OK great will test it and get back to you, Thanks sir.

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