Alembic PLA bake [SOLVED]



  • On 27/03/2015 at 00:20, xxxxxxxx wrote:

    I don't even know how I'd begin to do this, but I'd like to take an alembic curve and bake it's animation to a exact same version of that spline that's been made editable.



  • On 27/03/2015 at 07:53, xxxxxxxx wrote:

    Hello,

    you can get the spline that is generated by the Alembic generator with GetRealSpline(). Please notice that the number of points of that spline can vary depending on the spline interpolation. So you have to make sure that in the spline properties the interpolation is set to none.

    With the spline returned from GetRealSpline() you could create a new spline object, add an animation track and set keyframes for each frame. You could iterate through the scene as described in this thread. To animate the document you could also use SetDocumentTime().

    You find an example on how to create the PLA track and how to create keys in this thread.

    Best wishes,
    Sebastian



  • On 27/03/2015 at 18:31, xxxxxxxx wrote:

    Thanks, I figured most of it out but this final part stumps me. I basically have like 300+ splines I need to bake and then combine together into one. For some reason I recall connect and delete objects actually preserving my animation once, but in this case when I do it they don't have any PLA keys. The reason I need to combine them into one is to use them as a link to the hair system. If I bake a Connect object using my script, modified a little, that has alembic curve I get a object but the PLA is jacked on it. It's as if the connect object and its clone aren't quite exactly the same.

    Here's a version of my script that takes multiple alembic splines and converts them to standard c4d splines with PLA.

    import c4d
    import os, hashlib, csv
      
    from c4d import bitmaps, gui, plugins, documents, utils
    from types import *
      
      
    if __name__ == '__main__':
        # Get active doc
        doc = c4d.documents.GetActiveDocument()
      
        # Get project current start and end frames
        startFrameValue = int(doc.GetMinTime().GetFrame(doc.GetFps()))
        endFrameValue = int(doc.GetMaxTime().GetFrame(doc.GetFps()))
      
        # this null is where the baked guides will go
        bakedHair = c4d.BaseObject(c4d.Onull) # Create new null
        bakedHair.SetName("baked_hair")
        doc.InsertObject(bakedHair)
      
        # get all the children under the parent, should be simulated guides
        # we will then create editable clones of the guides to use for baking
        guides = op.GetChildren()
        for guide in guides:
            realSpline = guide.GetRealSpline()
            if realSpline:
                obj = realSpline.GetClone()
                obj.SetName(obj.GetName() + '_bake')
      
                #get the pla track Description id
                id = c4d.DescID(c4d.DescLevel(c4d.CTpla, c4d.CTpla, 0))
      
                #Create the pla track
                plaTrack = c4d.CTrack(obj, id)
                obj.InsertTrackSorted(plaTrack)
      
                # For each guide we want to bake on every frame it's point level state
                for frame in range(startFrameValue, endFrameValue) :
                    # Set the docs current time to the correct frame so we can capture the key
                    time = c4d.BaseTime(frame, doc.GetFps())
                    doc.SetTime(time)
                    doc.ExecutePasses(None, True, True, True, 0);
                    c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED)
      
                    #Get pla curve
                    myCurve = plaTrack.GetCurve()
      
                    # Add a PLA key and set the key to the state of the alembic object at this frame
                    dictKey = myCurve.AddKey(time)
                    key = dictKey['key']
                    fillSuccess = plaTrack.FillKey(doc, guide.GetRealSpline().GetClone(), key)
      
                    #print "Key set sucessfully: ", fillSuccess
      
                obj.InsertUnder(bakedHair)
                
        c4d.EventAdd()
    

    My main question would be how could I take these hundreds of splines and make them one object with animation?



  • On 30/03/2015 at 03:08, xxxxxxxx wrote:

    Hello,

    to combine multiple splines to one spline you could extend your script a little bit. Splines can manage multiple segments so you could create a spline containing a segment for each original input spline or alembic curve. The number of segments can be defined with ResizeObject(). Then you could create a PLA track for that combined spline, create a similar spline as animation reference and use that reference to create PLA keyframes.

    You find some example of how to handle spline segments in the Double Circle plugin.

    Best wishes,
    Sebastian



  • On 02/04/2015 at 03:53, xxxxxxxx wrote:

    Thanks for the assistance, I don't think this is going to work out the way I had envisioned unfortunately. I played with the points link in the hair system and it doesn't work the way I thought it did. I can get the hair to maybe follow my baked splines exactly by using them as the link for the hair system, but then I can't use the link to grow interpolated hair to give the head volume. Its a rock and a hard place. Thanks for the assistance anyway.



  • On 02/04/2015 at 05:18, xxxxxxxx wrote:

    Hello,

    thanks for your answer. Since the original question was answered I'll mark this thread as solved.

    Best wishes,
    Sebastian


Log in to reply