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

    ObjectData/Draw/DrawPolygonObject in XRay Mode

    Scheduled Pinned Locked Moved PYTHON Development
    3 Posts 0 Posters 378 Views
    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 Offline
      Helper
      last edited by

      On 15/02/2016 at 10:53, xxxxxxxx wrote:

      Hello everybody,

      i´d like to draw a PolygonObject in Xray mode into the viewport. Im able to draw the object, but just without xray.

      def Draw(self, op, drawpass, bd, bh) :  
        if drawpass!=c4d.DRAWPASS_XRAY:  
            obj = MachCube(100, 75, 50)  
            bd.DrawPolygonObject(bh, obj, c4d.DRAWOBJECT_0)  
        
        return c4d.DRAWRESULT_OK  
        
      ...  
        
      def MachCube(size_x, size_y, size_z) :  
        size = c4d.Vector()  
        size.x = size_x  
        size.y = size_y  
        size.z = size_z  
          
        cube = c4d.PolygonObject(8, 6)  
          
        pnts = [c4d.Vector() for x in xrange(8)]  
        pnts[0] = c4d.Vector(-size.x/2, -size.y/2, -size.z/2)  
        pnts[1] = c4d.Vector(-size.x/2,  size.y/2, -size.z/2)  
        pnts[2] = c4d.Vector( size.x/2, -size.y/2, -size.z/2)  
        pnts[3] = c4d.Vector( size.x/2,  size.y/2, -size.z/2)  
        pnts[4] = c4d.Vector( size.x/2, -size.y/2,  size.z/2)  
        pnts[5] = c4d.Vector( size.x/2,  size.y/2,  size.z/2)  
        pnts[6] = c4d.Vector(-size.x/2, -size.y/2,  size.z/2)  
        pnts[7] = c4d.Vector(-size.x/2,  size.y/2,  size.z/2)  
          
        plys = c4d.CPolygon(0,1,3,2), c4d.CPolygon(2,3,5,4), c4d.CPolygon(4,5,7,6), c4d.CPolygon(6,7,1,0), c4d.CPolygon(1,7,5,3), c4d.CPolygon(6,0,2,4)  
          
        cube.SetAllPoints(pnts)  
        for index, ply in enumerate(plys) : cube.SetPolygon(index, ply)  
          
        return cube  
      

      Is it possible to do?

      Greetings
      rown

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

        On 16/02/2016 at 03:07, xxxxxxxx wrote:

        Hello,

        It seems to work fine using DrawObject() and setting the ID_BASEOBJECT_XRAY parameter of the drawn object.

          
        def Draw(self, op, drawpass, bd, bh) :  
          
         self._cube[c4d.ID_BASEOBJECT_XRAY] = op[c4d.ID_BASEOBJECT_XRAY]  
          
         bd.DrawObject(bh, self._cube, c4d.DRAWOBJECT_0, drawpass, op)  
          
         return c4d.DRAWRESULT_OK  
        

        Also it seems to be the best solution to store the geometry as a member of your class.

        Best wishes,
        Sebastian

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

          On 16/02/2016 at 07:27, xxxxxxxx wrote:

          Hey Sebastian,

          thx alot. I also tried to set the ID_BASEOBJECT_XRAY parameter yesterday. But I didnt try to let the object be a member. Thats the solution.

          if drawpass!=c4d.DRAWPASS_XRAY:  
            self.cube[c4d.ID_BASEOBJECT_XRAY] = op[c4d.ID_BASEOBJECT_XRAY]  
            bd.DrawObject(bh, self.cube, c4d.DRAWOBJECT_0, drawpass, op)  
            c4d.DRAWRESULT_OK
          

          One other question just for knowing. Why cant I draw a primitive object like c4d.BaseObject(c4d.Ocube)? At this point its not importaint to know, but it was noticed by me.

          Thx and greetings
          rown

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