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

    Make Hair Editable according to animation

    SDK Help
    0
    5
    452
    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
      Helper
      last edited by

      On 13/10/2015 at 03:06, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   R17 
      Platform:   Windows  ;   
      Language(s) :     C++  ;

      ---------
      Greetings !

      I try to make hair objects editable according to the current frame.
      For primitives, i use ExecutePasses(any_thread,TRUE,TRUE,TRUE,BUILDFLAGS_EXTERNALRENDERER);
      to apply the animation to the objects and then making editable. But it seems it doesnt work the same with hair since it doesn't have keyframes.

      In a scene consisting of 30 frames with 2-3 animated objects and hair wrapping a sphere, the objects are rendered fine but the hair stay the same as in initial frame.

      What can i do to apply the animation to the hair as well ?

      Thank you.

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

        On 14/10/2015 at 11:26, xxxxxxxx wrote:

        Hi,

        I'm terribly sorry, but I'm not sure I understand. On the one hand you ask how to make a hair object editable at a specific frame. I assume you are talking about spline or polygonal hair here, right? And on the other hand you talk about rendering an animation.
        Can you perhaps explain, in what situation (plugin type, function) you are trying to do what?
        Please bear with me, maybe I'm a bit slow today.

        But I played around a bit with a Python script and assuming you are talking about polygon hair. ExecutePasses() does the job for me, but as hair is a simulation you have to make sure, you simulate every frame.
        Here's my script (please forgive, posting a Python script in the C++ forum, but I think you get the idea) :

        import c4d
        from c4d import utils
          
        def main() :
          for t in range(0, 30) :
            doc.SetTime(c4d.BaseTime(t, doc.GetFps()))
            doc.ExecutePasses(None, True, True, True, c4d.BUILDFLAGS_INTERNALRENDERER)
            c4d.EventAdd()
          hair = doc.SearchObject("Hair")
          settings = c4d.BaseContainer()
          objResult = utils.SendModelingCommand(command = c4d.MCOMMAND_CURRENTSTATETOOBJECT,
                                                list = [hair],
                                                mode = c4d.MODELINGCOMMANDMODE_ALL,
                                                bc = settings,
                                                doc = doc)
          doc.InsertObject(objResult[0])
          c4d.EventAdd()
          
        if __name__=='__main__':
          main()
        
        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          On 15/10/2015 at 03:56, xxxxxxxx wrote:

          Greetings !

          My scene consists of a sphere and a hair object.
          In the document i use 60 frames total.

          As i see i don't have to add key frames myself.

          1. Does each frame of the whole track bar is considered a separate keyframe ?

          I have used your code and it works. I had to use the ExecutePasses for all the previous frames of the one i want to render. 
          2) Is this necessary ?

          Thank you very much.

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

            On 15/10/2015 at 05:39, xxxxxxxx wrote:

            1. There are no keyframes, just frames.  As a simulation, the initial conditions and parameters over the simulation dictate what happens at each frame of the animation.

            2. Since the animation is a simulation, the result at frame n is dependent upon the results of frame 1-(n-1), so it is necessary unfortunately.  Using the cache for hair dynamics simulation might help expedite the process.

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

              On 16/10/2015 at 02:10, xxxxxxxx wrote:

              Thank you very much for your explanation !

              Instead of executing the N-1 passes, can i get the result at frame N directly from hair Cache ? (if it has been already calculated)

              Thank you.

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