Navigation

    • Register
    • Login
    • Search
    • Categories
    1. Home
    2. mdr74
    M
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    mdr74

    @mdr74

    0
    Reputation
    14
    Posts
    37
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    mdr74 Follow

    Posts made by mdr74

    • RE: DEFORMCACHE AND MATRIX ISSUE

      Thanks a lot !!!.
      I will try it in the next days.
      I'm free for my personal projects only during weekends

      posted in Cinema 4D Development
      M
      mdr74
    • RE: DEFORMCACHE AND MATRIX ISSUE

      I don't know exactly how and why, but I found the solution.
      setting the basedraw matrix relative to the object when deformer is selected

      It's not a clean solution, but I cannot understand the hierarchy cache problem

      the modified method is:

      def DrawPolyNormals(self, obj):
              for p, n in zip(self.objPolysCenter, self.objPolysNormal):
                  mx = self.mx
                  if obj.GetDown():
                      if obj.GetDown().GetBit(c4d.BIT_ACTIVE):
                          self.basedraw.SetMatrix_Matrix(None, mx)
                      else:
                          self.basedraw.SetMatrix_Matrix(None, c4d.Matrix())
                  normalDistance = n * self.normalLength
                  q = p
                  r = q + normalDistance * c4d.Matrix(v1=~mx.v1, v2=~mx.v2, v3=~mx.v3)
                  self.basedraw.DrawLine(q, r, 0)
      

      the object points global position are calculated in self.objPolysCenter:

      def polysCenter(self, local=False):
              polys = self.polyPlgList
              pts = self.polyPtsList
              nbPolys = self.polyPlgCount
              center = vc()
      
              for i, poly in enumerate(self.polyPlgList):
                  if poly.c != poly.d:
                      center = (pts[poly.a] + pts[poly.b] + pts[poly.c] + pts[poly.d]) / 4
                  else:
                      center = (pts[poly.a] + pts[poly.b] + pts[poly.c]) / 3
                  if not local:
                      yield center * self.mx
                  else:
                      yield center
      
      posted in Cinema 4D Development
      M
      mdr74
    • RE: DEFORMCACHE AND MATRIX ISSUE

      @zipit
      I can wait, no hurry ;)

      Just to let you know...the same problem occurs with polygonal object and deformer
      everything's correct in world center but as soon as I move the object it seems that the matrix are calculated 2 times.
      It seems a cache issue

      I'm checking the link provided

      cheers

      posted in Cinema 4D Development
      M
      mdr74
    • RE: DEFORMCACHE AND MATRIX ISSUE

      @zipit
      Thanks

      I corrected the matrix calculation as suggested but the problem persist.
      I'll try to check the cache issue thread you linked

      for now I upload the plugin...it's very messy I think, but I use it also for testing other things ;):
      PLUGIN

      I also attach 2 screenshots of the problem

      when there is no deformer everything's correct (with base object and polygonal object):

      image.jpg

      as soon as I put a deformer below the lines shift away:

      image.jpg

      the same problem occurs when I change the deformer alignment to other planes and fit to parent:

      image.jpg

      thanks for the support

      posted in Cinema 4D Development
      M
      mdr74
    • DEFORMCACHE AND MATRIX ISSUE

      Hi,
      I'm trying to write a Tag plugin to visualise data on objects.
      Everything's work fine until I put a deformer under the object and get the deformed Cache.
      In that case, the matrix of the generated Lines are translated ( I think they are calculated twice or something similar ).

      this is the code:

      import random
      import os
      import sys
      import c4d
      from c4d import utils as u
      from c4d import Vector as vc
      
      PLUGIN_ID = 1099997
      # VIS_SETTINGS
      # POLYCENTERINFO
      # POLYNORMALINFO
      
      
      class PolyVisualiserHelper(object):
          def polysCenter(self, ob, local=True):
              polys = ob.GetAllPolygons()
              pts = ob.GetAllPoints()
              nbPolys = ob.GetPolygonCount()
              center = vc()
      
              for i, poly in enumerate(polys):
                  if poly.c != poly.d:
                      center = (pts[poly.a] + pts[poly.b] + pts[poly.c] + pts[poly.d]) / 4
                  else:
                      center = (pts[poly.a] + pts[poly.b] + pts[poly.c]) / 3
      
                  yield center
      
      
          def polysNormal(self, ob, local=True):
              polys = ob.GetAllPolygons()
              pts = ob.GetAllPoints()
              nbPolys = ob.GetPolygonCount()
      
              norPolys = [vc()] * nbPolys
              nor = vc()
      
              for i, poly in enumerate(polys):
                  nor = (pts[poly.a] - pts[poly.c]).Cross(pts[poly.b] - pts[poly.d])
                  nor.Normalize()
      
                  yield nor
      
      
          def DrawPolyNormals(self, bd, obj):
              ob = obj
              mx = ob.GetMg()
              for p, n in zip(self.polysCenter(ob), self.polysNormal(ob)):
                  normalDistance = n * 50
                  destV = p + normalDistance
                  bd.DrawLine(p * mx, destV * mx, 0)
      
      
          def AccessCache(self, bd, op) :
              temp = op.GetDeformCache()
              if temp is not None:
                # recurse over the deformed cache
                self.AccessCache(bd, temp)
              else:
                # verify existance of the cache
                temp = op.GetCache()
                if temp is not None:
                    # recurve over the cache
                    self.AccessCache(bd, temp)
                else:
                    # the relevant data has been found
                    # and it should not be a generator
                    if not op.GetBit(c4d.BIT_CONTROLOBJECT) :
                        # check the cache is an instance of Opoint
                        if op.IsInstanceOf(c4d.Opoint) :
                            self.DrawPolyNormals(bd, op)
      
      
      class PolyVisualiser(c4d.plugins.TagData, PolyVisualiserHelper):
          """Look at Camera"""
      
          def Init(self, node):
              pd = c4d.PriorityData()
              if pd is None:
                  raise MemoryError("Failed to create a priority data.")
      
              pd.SetPriorityValue(c4d.PRIORITYVALUE_CAMERADEPENDENT, True)
              node[c4d.EXPRESSION_PRIORITY] = pd
      
              return True
      
      
          def Draw(self, tag, op, bd, bh):
              self.AccessCache(bd, op)
      
              return c4d.DRAWRESULT_OK
      
      
      if __name__ == "__main__":
          # Retrieves the icon path
          directory, _ = os.path.split(__file__)
          fn = os.path.join(directory, "res", "polyNormal.png")
      
          # Creates a BaseBitmap
          bmp = c4d.bitmaps.BaseBitmap()
          if bmp is None:
              raise MemoryError("Failed to create a BaseBitmap.")
      
          # Init the BaseBitmap with the icon
          if bmp.InitWith(fn)[0] != c4d.IMAGERESULT_OK:
              raise MemoryError("Failed to initialize the BaseBitmap.")
      
          c4d.plugins.RegisterTagPlugin(id=PLUGIN_ID,
                                        str="Draw Test 03",
                                        info=c4d.TAG_EXPRESSION | c4d.TAG_VISIBLE | c4d.TAG_IMPLEMENTS_DRAW_FUNCTION,
                                        g=PolyVisualiser,
                                        description="drawtest03",
                                        icon=bmp)
      
      

      I already tried to disable the Matrix multiplication in the DrawPolyNormals() method when deformCache is generated but the matrix were still not correct

      thanks for future help

      posted in Cinema 4D Development
      M
      mdr74
    • RE: Send Python Code To C4D from any Texteditor

      @mikeudin I change this code in line 432 of SendPythonCodeToCinema4D.pyp

      str(code)
      

      with

      str(code, "utf-8")
      

      and also in lines 436, 440, 448

      the code returned to cinema4d was in byte format, not string.
      I'm not very good with python but it works for me

      posted in General Programming & Plugin Discussions
      M
      mdr74
    • RE: Send Python Code To C4D from any Texteditor

      @mikeudin thanks

      posted in General Programming & Plugin Discussions
      M
      mdr74
    • RE: Send Python Code To C4D from any Texteditor

      Hi,
      is it possible to update this fantastic tool for R23.
      I think it's broken due to new python 3.7 version, but I don't understand the socket module

      thanks

      posted in General Programming & Plugin Discussions
      M
      mdr74
    • RE: DrawHUDText returns a white box instead of a text?

      I discovered another problem in S22, maybe.
      The Hud text is correct but when I deselect the polygon object I cannot select anything in the viewport anymore.
      I don't know if it's a bug or an error in the plugin

      thanks again

      posted in Cinema 4D Development
      M
      mdr74
    • RE: DrawHUDText returns a white box instead of a text?

      it works.
      thanks

      posted in Cinema 4D Development
      M
      mdr74