Thanks a lot !!!.
I will try it in the next days.
I'm free for my personal projects only during weekends
mdr74
@mdr74
Posts made by mdr74
-
RE: DEFORMCACHE AND MATRIX ISSUE
-
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 selectedIt'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
-
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 issueI'm checking the link provided
cheers
-
RE: DEFORMCACHE AND MATRIX ISSUE
@zipit
ThanksI corrected the matrix calculation as suggested but the problem persist.
I'll try to check the cache issue thread you linkedfor now I upload the plugin...it's very messy I think, but I use it also for testing other things ;):
PLUGINI also attach 2 screenshots of the problem
when there is no deformer everything's correct (with base object and polygonal object):
as soon as I put a deformer below the lines shift away:
the same problem occurs when I change the deformer alignment to other planes and fit to parent:
thanks for the support
-
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
-
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 -
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 modulethanks
-
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 pluginthanks again