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

    ObjectData: draw above everything else

    PYTHON Development
    0
    5
    1.2k
    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.
    • H
      Helper
      last edited by

      On 31/10/2017 at 11:07, xxxxxxxx wrote:

      Hey guys,

      is there a way to draw lines or points above everything else? Preferably in object drawpass.
      SetMatrix_Matrix(op, m, ZOFFSET) or SetMatrix_Screen(ZOFFSET) has no effect.

      Thx and greetings
      rownn

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        On 31/10/2017 at 12:12, xxxxxxxx wrote:

        Ok, I think this could be a workaround.

        def Draw(self, op, drawpass, bd, bh) :  
          color = op[c4d.ID_BASEOBJECT_COLOR]  
          m = op.GetMg()  
          
          if drawpass==c4d.DRAWPASS_OBJECT:  
              if bh.IsHighlight() :  
                 color = c4d.Vector(1,1,1)  
          
              if bh.IsActive() :  
                  color = op[c4d.ID_BASEOBJECT_COLOR]  
          
              bd.SetPen(color)  
              bd.SetPointSize(10)  
          
              bd.SetMatrix_Camera()  
              bd.DrawPoints([(m.off*~bd.GetMg()).GetNormalized()*2])  
          
          return c4d.DRAWRESULT_OK
        
        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          On 01/11/2017 at 05:00, xxxxxxxx wrote:

          Here a little update, which consider the different projections except parallel projection.

          def Draw(self, op, drawpass, bd, bh) :  
            color = op[c4d.ID_BASEOBJECT_COLOR]  
            m = op.GetMg()  
            ibdMg = ~bd.GetMg()  
            
            if drawpass==c4d.DRAWPASS_OBJECT:  
                if bh.IsHighlight() : color = pencolor+c4d.Vector(0.5)  
            
                bd.SetPen(pencolor)  
                bd.SetPointSize(10)  
            
                projection = bd.GetProjection()  
                bd.SetMatrix_Camera()  
                  
                if projection == 0:  
                    pos = (m.off*ibdMg).GetNormalized()*2  
                    bd.DrawPoints([pos])  
            
                elif projection in (2,3,4,5,6,7) :  
                    pos = op.GetMg().off*ibdMg  
                    pos.z = -1000000  
                    bd.DrawPoints([pos])  
            
            return c4d.DRAWRESULT_OK
          
          1 Reply Last reply Reply Quote 0
          • H
            Helper
            last edited by

            On 02/11/2017 at 08:29, xxxxxxxx wrote:

            Next little update. In case more than one postion should be drawn there was an issue with overlapping. I don´t thing it is totally fixed now, but works better.

            def Draw(self, op, drawpass, bd, bh) :  
              color = op[c4d.ID_BASEOBJECT_COLOR]  
              m = op.GetMg()  
              ibdMg = ~bd.GetMg()  
              
              if drawpass==c4d.DRAWPASS_OBJECT:  
                  if bh.IsHighlight() :  
                      color = color+c4d.Vector(0.5)  
              
                  bd.SetPen(color)  
                  bd.SetPointSize(10)  
              
                  projection = bd.GetProjection()  
                  bd.SetMatrix_Camera()  
                    
                  if projection == 0:  
                      pos = m*ibdMg  
                      posFront = pos.GetNormalized()*(2+(pos.z/10000.0))  
                      bd.DrawPoints([posFront])  
              
                  elif projection in (2,3,4,5,6,7) :  
                      pos = op.GetMg()*ibdMg  
                      pos.z += -100000  
                      bd.DrawPoints([pos])  
              
              return c4d.DRAWRESULT_OK
            
            1 Reply Last reply Reply Quote 0
            • H
              Helper
              last edited by

              On 06/11/2017 at 14:53, xxxxxxxx wrote:

              Hi rown, thanks for writing us and sorry for the delay in getting back to you.

              After researching a bit, and without using 2D drawing methods, slightly extending (and optimizing) your code you can support also isometric and dimetric projections:

                
                def Draw(self, op, drawpass, bd, bh) :  
                    color = op[c4d.ID_BASEOBJECT_COLOR]  
                    m = op.GetMg()  
                    ibdMg = ~bd.GetMg()  
                    pos = m.off * ibdMg        
                    projection = bd.GetProjection()  
                
                    if drawpass == c4d.DRAWPASS_OBJECT:  
                        if bh.IsHighlight() :  
                            color = color + c4d.Vector(0.5)  
                
                        bd.SetPen(color)  
                        bd.SetPointSize(10)  
                
                        bd.SetMatrix_Camera()  
                
                        if projection == 0:  
                            pos = pos.GetNormalized() * (2 + (pos.z / 10000.0))  
                
                        elif projection in (2, 3, 4, 5, 6, 7, 12, 13) :  
                            pos.z += -10000  
                
                        bd.DrawPoints([pos])  
                
                    return c4d.DRAWRESULT_OK      
              

              Finally the zoffset parameter found in SetMatrix_Matrix() or SetMatrix_Screen() has no real effect because it's not meant to change the depth at which an entity is drawn with respect to another, but it  changes the drawing priority in the z-buffer.

              Best, Riccardo

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