Navigation

    • Register
    • Login
        No matches found
    • Search
    1. Home
    2. baca
    B

    baca

    @baca

    1
    Reputation
    39
    Posts
    73
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    • Profile
    • More
      • Following
      • Followers
      • Topics
      • Posts
      • Best
      • Groups
    baca Follow

    Best posts made by baca

    RE: Blend matrices

    If anyone interested:

    def MatrixBlend(mxA, mxB, t):
        quatA = c4d.Quaternion()
        quatA.SetMatrix(mxA)
    
        quatB = c4d.Quaternion()
        quatB.SetMatrix(mxB)
    
        return utils.MatrixMove( utils.MixVec(mxA.off, mxB.off, t) ) * utils.QSlerp(quatA, quatB, t).GetMatrix() * utils.MatrixScale( utils.MixVec(mxA.GetScale(), mxB.GetScale(), t) )
    
    posted in Cinema 4D SDK •

    Latest posts made by baca

    RE: Touch input objects withot resetting its cache

    @ferdinand said in Touch input objects withot resetting its cache:

    NBIT_EHIDE

    Sorry Ferdinand,
    I might be not a great explainer... But that not I actually need.
    This bit only hides object in Editor, in Render it's still visible.

    So Touch() is the only way to truly hide the object.
    My only issue is that I'm trying to hide all nested objects with Touch().
    And when I'm doing it I'm also touching the grandchildren, and this cause their parent to be rebuilt.
    I'm looking for a way to skip objects which already touched by their parent generator.

    To be clear, here's the use case:
    +--Null whole tree has to be hidden
    | +--Loft has BIT_CONTROLOBJECT, has OBJECT_INPUT — not hidden yet, has to be hidden
    | | +--Circle has BIT_CONTROLOBJECT — already hidden by parent Loft, has to be skipped
    | +--Loft has BIT_CONTROLOBJECT, has OBJECT_INPUT — not hidden yet, has to be hidden
    | | +--Cube has BIT_CONTROLOBJECT — not hidden by parent Loft, has to be hidden
    +--...
    +--MY_GENERATOR has object link pointing to Null, it wants to hide this Null

    If I'll try to Touch() Circle spline, then it's parent Loft would be continuously regenerating, so MY_GENERATOR would be also continuously regenerating, because source dirtiness is changed.

    If I'll try to skip Touch() children of objects with OBJECT_INPUT set, then Cube under Loft would be visible - because it wasn't touched by its parent Loft as Cube is not a spline object.

    So either I go into regeneration loop, either I'm not hiding objects.
    But I want both performance and hide.

    posted in Cinema 4D SDK •
    RE: Touch input objects withot resetting its cache

    @ferdinand thanks for suggestion, I'll try it as well.

    Here's setup:

    SCENE_ROOT
    +--SOME_SOURCE (whole tree has to be hidden)
    |  +--SOURCE_CHILD_1
    |  |  +--SOURCE_GRANDCHILD_1_1
    |  |  +--...
    |  |  +--SOURCE_GRANDCHILD_1_N
    |  +--SOURCE_CHILD_N
    |  |  +--SOURCE_GRANDCHILD_N_1
    |  |  +--...
    |  |  +--SOURCE_GRANDCHILD_N_N
    +--...
    +--MY_GENERATOR (has object link pointing to SOME_SOURCE)
    

    The idea is to create similar functionality as Connect object has - object link as a mesh source, and this source (whole tree) has to be hidden.
    Touch is resetting object cache, what I want to avoid.
    While GetAndCheckHierarchyClone is able to hide whole subtree, keeping it's cache.

    posted in Cinema 4D SDK •
    RE: Draw editable spline in the viewport

    @ferdinand thanks for explanations and example.

    posted in Cinema 4D SDK •
    Touch input objects withot resetting its cache

    Hi,

    I'd like to know if there's a chance to hide objects the same way it's done in GetAndCheckHierarchyClone() method.
    Generally GACHC is hiding children geometry without destroying their cache, and it don't reset DIRTYFLAGS_CACHE.
    I'd like to do the similar thing to the dependencies, which aren't children.

    Currently I know only Touch() method, but it reset caches and enforce all generators to be recalculated when touching the chain.
    I seen many similar topics were related to the Touch() method, but there were no solution.

    Also are there any flags to know if object is made hidden by GetAndCheckHierarchyClone?
    At least I try to skip Touching for these objects.
    GetCache() is returning some value, testing BIT_CONTROLOBJECT is not relevant as it set for both Generator and Input objects.

    posted in Cinema 4D SDK •
    RE: Draw editable spline in the viewport

    @ferdinand huge thanks for detailed reply, as always.

    1. I didn't shared whole code here, but in GVO I'm also caching the spline as self._spline property and in GetSpline method I'm returning self._spline.GetClone()
      When dealing with child input object GetAndCheckHierarchyClone has no alternatives except weird combination of CSTO + Touch()
    2. //
    3. So solution might be to draw tiny polygons with gradient in vertex colors? Any suggestion for draw pas in that case - DRAWPASS_OBJECT or DRAWPASS_HANDLER?
      Current issue is that my object is drawn automatically, and I have no idea if I can prevent automatic drawing. I can render custom color only in case, if my object is not selected.
    4. //
    5. PointObject::DisplayPoints is only available under C++? Didn't found any references in both Py and Cpp documentation
    6. Yeah, thanks for suggestion to not store source line, as it's not reflecting further deformer changes. But I found that Draw is called so frequent, and converting spline to line takes sufficient time, so it becomes uncomfortable to work with.
      Maybe I need to check self DIRTYFLAGS_CACHE before rebuilding line object, not sure.
    7. I wanted to render vertices and spline direction not for manipulation, but for visual check.
      And thought to implement point selection feature for selection tag creating, maybe.
    posted in Cinema 4D SDK •
    Draw editable spline in the viewport

    Hi,
    I would like to draw a spline similar way it's drawing in the editor, with gradient from white to blue, and the points.
    As well as I'd like the points to be selectable.

    I've came to this for now:

    import c4d
    
    class SplineTest(c4d.plugins.ObjectData):
        def Init(self, op):
            self.LINE_DRAW = None
            return True
    
        def GetVirtualObjects(self, op, hh):
            hierarchyCloneRes = op.GetAndCheckHierarchyClone(hh, op.GetDown(), c4d.HIERARCHYCLONEFLAGS_ASSPLINE, False) if op.GetDown() else None
            spline = c4d.SplineObject(0, c4d.SPLINETYPE_LINEAR)
            if hierarchyCloneRes:
                if not hierarchyCloneRes["dirty"]:
                    return hierarchyCloneRes["clone"]
                if hierarchyCloneRes["clone"].IsInstanceOf(c4d.Ospline) or hierarchyCloneRes["clone"].IsInstanceOf(c4d.Oline):
                    spline = hierarchyCloneRes["clone"]
            sh = c4d.utils.SplineHelp()
            if sh.InitSplineWith(spline, c4d.SPLINEHELPFLAGS_RETAINLINEOBJECT):
                self.LINE_DRAW = sh.GetLineObject().GetClone()
                sh.FreeSpline()
            return spline
    
        def Draw(self, op, drawpass, bd, bh):
            doc = bh.GetDocument()
            if drawpass != c4d.DRAWPASS_OBJECT or self.LINE_DRAW is None or self.LINE_DRAW.GetPointCount() == 0 or not bh.IsActive() or not doc.IsEditMode():
                return c4d.DRAWRESULT_SKIP
    
            # this draw is ignored
            bd.DrawPolygonObject(bh, self.LINE_DRAW, c4d.DRAWOBJECT_USE_CUSTOM_COLOR, None, c4d.GetViewColor(c4d.VIEWCOLOR_SPLINESTART),
            )
    
            if doc.GetMode() == c4d.Mpoints:
                opPoints = self.LINE_DRAW.GetAllPoints()
                pSelection = self.LINE_DRAW.GetPointS().GetAll(len(opPoints))
                selected = [opPoints[index] for index, isSelected in enumerate(pSelection) if isSelected]
                nonselected = [opPoints[index] for index, isSelected in enumerate(pSelection) if not isSelected]
    
                bd.SetMatrix_Matrix(op, bh.GetMg())
                bd.SetPointSize(6)
                bd.LineZOffset(2)
    
                if len(nonselected):
                    bd.SetPen(c4d.GetViewColor(c4d.VIEWCOLOR_INACTIVEPOINT))
                    bd.DrawPoints(nonselected)
    
                if len(selected):
                    bd.SetPen(c4d.GetViewColor(c4d.VIEWCOLOR_ACTIVEPOINT))
                    bd.DrawPoints(selected)
    
            return c4d.DRAWRESULT_OK
    
    if __name__ == "__main__":
        c4d.plugins.RegisterObjectPlugin(id = 1000001, str = 'SplineTest', g = SplineTest, description = "osplinetest", icon = None, info = c4d.OBJECT_GENERATOR | c4d.OBJECT_INPUT | c4d.OBJECT_ISSPLINE)
    

    Issue is object lines are not being drawn with custom color.
    Instead this object is drawn as maybe with c4d.VIEWCOLOR_ACTIVEBOX (visually its drawn as orange in R25)

    1. Is it possible to draw spline similar to editor with existing toolset, and If not, what approach should be used here?
    2. And is it possible to let points be selected in viewport, but not using c4d.OBJECT_POINTOBJECT as generator flag (in that case generator become Opoint type, and it's not treated as spline anymore.
    posted in Cinema 4D SDK •
    RE: Python Source Protector: Can it be called via CLI?

    Hi C4D team.
    Is that functionality still under development?

    posted in Cinema 4D SDK •
    RE: CSTO over object.GetClone() produces excess geometry

    @m_magalhaes Thanks Manuel,
    I appreciate your wise support every time.

    Merry Xmas and Happy New Year!

    posted in Cinema 4D SDK •
    RE: CSTO over object.GetClone() produces excess geometry

    @m_magalhaes Hi Manuel,

    Thanks for the reply.

    1. I've read the caution in API documentation, but I have tried it once and now can't stop to use it.
      At least for now I don't face app crashes, so maybe C4D have some safety margin for python developers 😉
    2. I can use cache, and I use it. But I want both options to be available.
      BTW when I'm using Cache from execute it also gives me whole tree including the Cloner sub-tree, when executing at Expression priority. In Generator priority GetCache() produces expected results.
    3. I don't like to affect DIRTYFLAGS_CACHE, because I'm also optimizing redraw based on dirty check with flag c4d.DIRTYFLAGS_DESCRIPTION | c4d.DIRTYFLAGS_DATA | c4d.DIRTYFLAGS_CHILDREN | c4d.DIRTYFLAGS_CACHE
      Also it seems like VolumeBuilder starts to re-generate mesh after CSTO called, and I went into infinite redraw.
    4. Thanks for pointing to IsolateObjects method, but as you mentioned I have to find all linked objects, which is not a trivial task in C4D.
      I wouldn't go that way.
    5. Provided solution with the ExecutePasses is updating geometry very rarely (if it supposed to be executed from python tag).
    6. Currently made a solution to check baseObject.GetInfo() & c4d.OBJECT_INPUT to stop further children processing.
      Seems to work good enough.
    posted in Cinema 4D SDK •
    CSTO over object.GetClone() produces excess geometry

    Hi,

    I need alternative to GetCache(), and CSTO seems to be a good option.
    But Python tag produces wrong geometry when executed over clone of the object with CSTO.
    It additionally produces geometry which should be hidden by parent generators (for ex. Cloner under Volume Builder).
    Behavior is the same in Python Expression, or Python Tag Plugin, and it affects Cinema4D R21+ at the least.

    Here's the code:

                    srcClone = srcObj.GetClone(c4d.COPYFLAGS_NO_ANIMATION)
                    doc.InsertObject(srcClone)
    
                    cstoResult = c4d.utils.SendModelingCommand(
                        command=c4d.MCOMMAND_CURRENTSTATETOOBJECT,
                        list = [srcClone],
                        mode = c4d.MODELINGCOMMANDMODE_ALL,
                        bc = c4d.BaseContainer(),
                        doc = doc
                    )
    
                    srcClone.Remove()
    
                for resObj in cstoResult:
                    for resChildObj in HierarchyIterator(resObj.GetDown()):
                        cloneObject = resChildObj.GetClone(c4d.COPYFLAGS_NO_HIERARCHY)
                        cloneObject.InsertUnderLast(selfObj)
    

    Viewport:
    bug.jpg

    Don't like the idea to call CSTO over original object, because it rebuilds object cache and affect DIRTYFLAGS_CACHE.
    What's the issue, is it possible to resolve it?

    Plugin https://www.dropbox.com/s/fxz8g7p8uuwc5y0/c4d_tag_csto.zip?dl=0
    Scene simple csto test.c4d

    Thanks.

    posted in Cinema 4D SDK •