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

    Set CKey with Vector Data [SOLVED]

    SDK Help
    0
    9
    817
    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 16/10/2016 at 06:10, xxxxxxxx wrote:

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

      ---------
      I want to keyframe the position Vector of an object. The following (simplified) code does this, but the keyframed position coordinates in the C4D GUI is not being marked red.

      CTrack* pos_track = CTrack::Alloc(object, DescID(DescLevel(ID_BASEOBJECT_REL_POSITION,DTYPE_VECTOR, 0)));
        
      object->InsertTrackSorted(pos_track);
        
      for (size_t i = 0; i < motiondata.size(); i++)
      {
      	CKey* pos_key = pos_track->GetCurve()->AddKey(BaseTime(i, fps));
        
      	auto &p = motiondata[i].pos;
      	pos_key->SetGeData(pos_track->GetCurve(), Vector(p[0], p[1], p[2]));
      }
      

      I previously created separate tracks for each position component and then used CKey::SetValue to set the floating point value of each position component in a keyframe. 
      This correctly marked the keyframed position coordinates red in the C4D GUI, but the code becomes more messy and unreadable.

      Is there a way to create keyframes using vector data and still have the coordinates being marked as red?

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

        On 16/10/2016 at 06:40, xxxxxxxx wrote:

        After your loop.
        Use this to update the pallet that holds those dots: DrawViews(c4d.DRAWFLAGS_FORCEFULLREDRAW)

        -ScottA

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

          On 16/10/2016 at 07:47, xxxxxxxx wrote:

          Originally posted by xxxxxxxx

          After your loop.
          Use this to update the pallet that holds those dots: DrawViews(c4d.DRAWFLAGS_FORCEFULLREDRAW)

          -ScottA

          Tried both

          DrawViews(DRAWFLAGS_FORCEFULLREDRAW);
          

          and

          BaseDraw* bd = doc->GetActiveBaseDraw();
          if (bd)
          {
          	DrawViews(DRAWFLAGS_FORCEFULLREDRAW, bd);
          }
          

          but they still don't display as red.

          Edit: 
          I think that there might be some fundamental diference between "Value Keys" and "Data Keys"(the ones I'm creating).
          It's as if "Data Keys" happens behind the scenes, even if they only affect GUI-accessible parameters such as position coordinates.

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

            On 16/10/2016 at 08:56, xxxxxxxx wrote:

            I'm still using R13. So maybe they changed in in later versions. But I'm surprised your code works at all. Because AFAIK. You can't create a position track in one line. You need to create each track individually like this:

            CTrack *posX_track = CTrack::Alloc(obj, DescID(DescLevel(ID_BASEOBJECT_REL_POSITION, DTYPE_VECTOR, 0), DescLevel(VECTOR_X, DTYPE_REAL, 0)));
            

            When I do this and use DrawViews(c4d.DRAWFLAGS_FORCEFULLREDRAW). The dots turn from yellow to red as expected when using SetGeData().

            -ScottA

            Edit:
            One other thing to note.
            SetGeData() seems to be mostly used for animating descriptions. Like bool type GUI operations.
            For positions I think you're supposed to use SetValue() instead.

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

              On 16/10/2016 at 09:29, xxxxxxxx wrote:

              Originally posted by xxxxxxxx

              I'm still using R13. So maybe they changed in in later versions. But I'm surprised your code works at all. Because AFAIK. You can't create a position track in one line. You need to create each track individually like this:

              CTrack *posX_track = CTrack::Alloc(obj, DescID(DescLevel(ID_BASEOBJECT_REL_POSITION, DTYPE_VECTOR, 0), DescLevel(VECTOR_X, DTYPE_REAL, 0)));
              

              When I do this and use DrawViews(c4d.DRAWFLAGS_FORCEFULLREDRAW). The dots turn from yellow to red as expected when using SetGeData().

              -ScottA

              Originally posted by xxxxxxxx

              I previously created separate tracks for each position component and then used CKey::SetValue to set the floating point value of each position component in a keyframe. 
              This correctly marked the keyframed position coordinates red in the C4D GUI, but the code becomes more messy and unreadable.

              As stated in OP, I did this at first and I want to avoid it since it's an ugly solution.

              Animation track categories (value and data) is a thing in R17 at least, so the code works.
              https://developers.maxon.net/docs/cpp/2023_2/page_manual_ckey.html#page_manual_ckey_edit_value

              Edit:

              Originally posted by xxxxxxxx

              Edit: 
              One other thing to note.
              SetGeData() seems to be mostly used for animating descriptions. Like bool type GUI operations.
              For positions I think you're supposed to use SetValue() instead.

              This seems very weird to me. Working with vector and matrix types in a 3D environment rather than doing everything componentwise should be standard.

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

                On 16/10/2016 at 09:57, xxxxxxxx wrote:

                That SDK example seems to be talking about special tracks.
                I have fallen way behind to the most recent changes and additions. So I can't say for sure it can't be done.
                The support guys might have a different answer for you on Monday.

                -ScottA

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

                  On 16/10/2016 at 22:27, xxxxxxxx wrote:

                  Alright, thanks for your time anyway.

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

                    On 17/10/2016 at 02:23, xxxxxxxx wrote:

                    Hello,

                    indeed it looks like that you have to animate each vector component individually to properly create the needed tracks. Only then the animation dots appear. It shouldn't be too hard to come up with a simple utility function to handle this. Since R18 the API contains BaseObject::GetVectorTracks() that gives easy access to the actual vector component tracks. See BaseObject Manual.

                    With the tracks created you have to call EventAdd() to inform Cinema about the update.

                    best wishes,
                    Sebastian

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

                      On 17/10/2016 at 04:16, xxxxxxxx wrote:

                      Ok, thanks for confirming. 
                      Yes, I suppose a simple function could be used to handle vectors of tracks. Just wanted to make sure that I wasn't missing something before starting.

                      Also, nice to see that this type of functionality is beginning to be built into the api.

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