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
    • Recent
    • Tags
    • Users
    • Login

    Setting Keyframes for Object Position

    Scheduled Pinned Locked Moved SDK Help
    6 Posts 0 Posters 559 Views
    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 Offline
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 03/03/2010 at 10:55, xxxxxxxx wrote:

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

      ---------
      Hi,

      I have created a CommandData plugin that adds an object to an existing scene and makes it follow a certain pre-defined path. For this I am setting the keyframes for the position of the object, i.e.

        
      CTrack *bodyTrack = CTrack::Alloc(bodyOp,DescLevel(ID_BASEOBJECT_POSITION,DTYPE_VECTOR,0));   
      if (!bodyTrack)     { return FALSE; }   
      bodyOp->InsertTrackSorted(bodyTrack);   
      CKey *bodyKey = NULL;   
      for (LONG simCount = 0; simCount<=simRuns; simCount++)   
      {   
      Vector posVector = ComputeCoords(body,time);   
      bodyKey = bodyTrack->GetCurve()->AddKey(BaseTime(simCount,framerate),NULL);   
      bodyKey->SetGeData(bodyTrack->GetCurve(),posVector);             
      time++;   
      }   
      

      It seems to work, and I see all the keyframes and the object moves. However, I was expecting to also see these keyframes in the Attribute Manager (i.e. in the object description) and also to see the path in the editor window (like it happens when I manually change the position and set the keyframe). Why is that not shown? What do I have to do to show it?

      Thanks,
      Juergen

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

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 03/03/2010 at 15:02, xxxxxxxx wrote:

        Does it show after you moved the timeslider? If yes, it's just a refresh/redraw problem.
        If not, I also don't know.
        Cheers,
        Jack

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

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 04/03/2010 at 08:18, xxxxxxxx wrote:

          Make sure to inform the object and managers about the changes.

            
          bodyOp->Message(MSG_UPDATE);  
            
          EventAdd();  
          

          cheers,
          Matthias

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

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            On 08/03/2010 at 12:15, xxxxxxxx wrote:

            Hi Matthias,

            I am doing that. I have the keyframes and the objects are moving in the scene.

            I just don't see the object path in the editor window and the respective coordinate fields in the attribute manager are not highlighted. I don't care so much about the latter, but is there a way to make the path show up as a spline in the editor window?

            Juergen

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

              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

              On 09/03/2010 at 23:28, xxxxxxxx wrote:

              I find it worrysome that it moves correctly but doesn't highlight the coordinates in the attribute manager.

              How about

                
                CCurve *seq=bodyTrack->GetCurve();  
                bodyKey=CKey::Alloc();  
                bodyKey->SetGeData(seq,posVector);  
                bodyKey->SetTime(seq,BaseTime(simCount,framerate));  
                key->SetInterpolation(seq,CINTER_STEP);  
                if (!(seq->InsertKey(key))) {  
                    GeConsoleOut(String("I'm in trouble :-)"));  
                }  
              

              That way you'll already have the correct values at the time you make the key known to Cinema 4D and you don't have to worry about refreshing.
              I'm using this code snippet in a project of mine and I see the object path just fine in the editor.

              Best regards
              Mike

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

                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                On 15/03/2010 at 02:02, xxxxxxxx wrote:

                The error lies in your track allocation and key creation. Position tracks are three independent Real tracks.

                Have a look at following code, it should be pretty much self explainatory:

                  
                Bool MenuTest::Execute(BaseDocument *doc)  
                {  
                  BaseObject *op = doc->GetActiveObject();  
                  
                  if (!op) return FALSE;  
                  
                  StopAllThreads();  
                  
                  CTrack *trackX = NULL;  
                  CTrack *trackY = NULL;  
                  CTrack *trackZ = NULL;  
                  
                  trackX = CTrack::Alloc(op,DescID(DescLevel(ID_BASEOBJECT_POSITION,DTYPE_VECTOR,0),DescLevel(VECTOR_X,DTYPE_REAL,0)));  
                  if (!trackX) goto Error;  
                  
                  trackY = CTrack::Alloc(op,DescID(DescLevel(ID_BASEOBJECT_POSITION,DTYPE_VECTOR,0),DescLevel(VECTOR_Y,DTYPE_REAL,0)));  
                  if (!trackY) goto Error;  
                  
                  trackZ = CTrack::Alloc(op,DescID(DescLevel(ID_BASEOBJECT_POSITION,DTYPE_VECTOR,0),DescLevel(VECTOR_Z,DTYPE_REAL,0)));  
                  if (!trackZ) goto Error;  
                  
                  op->InsertTrackSorted(trackX);  
                  op->InsertTrackSorted(trackY);  
                  op->InsertTrackSorted(trackZ);  
                  
                  CKey *key = NULL;  
                    
                  //add keys add 0s  
                  key = trackX->GetCurve()->AddKey(BaseTime()); if (!key) return FALSE;  
                  key->SetValue(trackX->GetCurve(), 100.0);  
                  
                  key = trackY->GetCurve()->AddKey(BaseTime()); if (!key) return FALSE;  
                  key->SetValue(trackY->GetCurve(), 100.0);  
                  
                  key = trackZ->GetCurve()->AddKey(BaseTime()); if (!key) return FALSE;  
                  key->SetValue(trackZ->GetCurve(), 100.0);  
                  
                  //add keys at 1s  
                  key = trackX->GetCurve()->AddKey(BaseTime(1.0)); if (!key) return FALSE;  
                  key->SetValue(trackX->GetCurve(), 0.0);  
                  
                  key = trackY->GetCurve()->AddKey(BaseTime(1.0)); if (!key) return FALSE;  
                  key->SetValue(trackY->GetCurve(), 0.0);  
                  
                  key = trackZ->GetCurve()->AddKey(BaseTime(1.0)); if (!key) return FALSE;  
                  key->SetValue(trackZ->GetCurve(), 0.0);  
                  
                  op->Message(MSG_UPDATE);  
                  EventAdd();  
                  
                  return TRUE;  
                  
                Error:  
                  blDelete(trackX);  
                  blDelete(trackY);  
                  blDelete(trackZ);  
                  return FALSE;  
                }  
                

                cheers,
                Matthias

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