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 Key Frames.

    Scheduled Pinned Locked Moved SDK Help
    9 Posts 0 Posters 649 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 22/12/2009 at 14:38, xxxxxxxx wrote:

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

      ---------
      So I would like to set the align to spline position of my align to spline tag at 0  at frame 0 and 100% at frame 30.  This is the code I am using to attempt to do that.  but the results I am getting are not what I am expecting.  With the code below, I am getting two key frames placed at 0 and 30,   and the loop for that track is being set to repeat.  However, the track is not for the align to spline tag.  It is for the main object.  Does anyone see any problems with the code I have posted?

      Thanks in advance.

      ~Shawn

        
        
                //Orbit Looping  
                if (op->GetDataInstance()->GetBool(ORBIT_LOOP))  
                {  
                    if (op->GetDataInstance()->GetObjectLink(ORBIT_OBJECT, doc))  
                    {  
                      
                        BaseObject* orbitingOBJ = op->GetDataInstance()->GetObjectLink(ORBIT_OBJECT, doc);  
        
                        CTrack *track = op->FindCTrack(orbitingOBJ->GetFirstTag()->GetDataInstance()->GetReal(ALIGNTOSPLINETAG_POSITION));  
                        track = CTrack::Alloc(op,orbitingOBJ->GetFirstTag()->GetDataInstance()->GetReal(ALIGNTOSPLINETAG_POSITION));  
                        if (!track) return false;  
                            op->InsertTrackSorted(track);  
                      
                        BaseTime btime = doc->GetTime();  
                      
                        btime.SetDenominator(op->GetDataInstance()->GetReal(ORBIT_SPEED));  
                        Real deNom;  
                        deNom = btime.GetDenominator();  
                      
                        btime.SetNominator(0);  
                        orbitingOBJ->GetFirstTag()->GetDataInstance()->SetReal(ORBIT_POSITION, 0.0);  
        
                      
                        CKey *key = track->GetCurve()->AddKey(btime,0);  
                        if (!key) return false;      
        
                        btime.SetNominator(deNom);  
                        orbitingOBJ->GetFirstTag()->GetDataInstance()->SetReal(ORBIT_POSITION, 1.0);  
        
                        CKey *key2 = track->GetCurve()->AddKey(btime,0);  
                        if (!key) return false;  
                      
                        track->SetAfter(CLOOP_REPEAT);  
                    }  
                }  
        
                              
                return TRUE;  
              
            }  
        
        
      
      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 23/12/2009 at 02:54, xxxxxxxx wrote:

        There are several errors in your code. Some are basic C/C++ errors and some are wrong use of the Cinema API.

        First of all you have to create the track and set the keys for the tag and not the object.

        These lines make no sense:

          
        CTrack *track = op->FindCTrack(orbitingOBJ->GetFirstTag()->GetDataInstance()->GetReal(ALIGNTOSPLINETAG_POSITION));  
        track = CTrack::Alloc(op,orbitingOBJ->GetFirstTag()->GetDataInstance()->GetReal(ALIGNTOSPLINETAG_POSITION));  
        if (!track) return false;  
        op->InsertTrackSorted(track);  
        

        You should check the track returned by FindCTrack() and if it doesn't exist allocate a new one and insert it. Also the way you pass the track ID is wrong. You have to pass a DescID. Use the DescLevel constructor for this.

        It should be something like this:

          
        CTrack *track = tag->FindCTrack(DescLevel(ALIGNTOSPLINETAG_POSITION,DTYPE_REAL,0));  
        if (!track)  
        {  
          track = CTrack::Alloc(tag,DescLevel(ALIGNTOSPLINETAG_POSITION,DTYPE_REAL,0));  
          if (!track) return FALSE;  
          tag->InsertTrackSorted(track);  
        }  
        

        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 23/12/2009 at 03:18, xxxxxxxx wrote:

          Thanks Matthias..   I know you all don't give C++ support, but you mentioned that there were basic C/C++ errors in my code..   Could you kindly point them out so that I don't keep making them.    Thanks,

          ~Shawn

          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 23/12/2009 at 03:22, xxxxxxxx wrote:

            Actually it's just one error. I was refering to these two lines:

              
            CTrack *track = op->FindCTrack(orbitingOBJ->GetFirstTag()->GetDataInstance()->GetReal(ALIGNTOSPLINETAG_POSITION));  
            track = CTrack::Alloc(op,orbitingOBJ->GetFirstTag()->GetDataInstance()->GetReal(ALIGNTOSPLINETAG_POSITION));  
            

            It makes no sense to get a pointer to a track and in the next line to overwrite this pointer again without any check if this is even necessary.

            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 23/12/2009 at 03:24, xxxxxxxx wrote:

              ah..  yeah.. this is the first time I am attempting to use the API to manipulate tracks..    Thanks for the help.     Oh by the way...   You have some very nice art work and photos on your website.

              ~Shawn

              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 23/12/2009 at 03:46, xxxxxxxx wrote:

                Yeah, it needs some time to get a grip on the Cinema API and C++.

                Originally posted by xxxxxxxx

                Oh by the way...   You have some very nice art work and photos on your website.

                Thanks! It's a passionate hobby of mine.

                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 24/12/2009 at 06:56, xxxxxxxx wrote:

                  I changed my code to match what you suggested.  And Here is what I currently have.

                    
                  //Orbit Looping  
                            if (op->GetDataInstance()->GetBool(ORBIT_LOOP))  
                            {  
                                if (op->GetDataInstance()->GetObjectLink(ORBIT_OBJECT, doc))  
                                {  
                                  
                                    BaseTag* tag = op->GetDataInstance()->GetObjectLink(ORBIT_OBJECT, doc)->GetFirstTag();  
                    
                                    CTrack *track = tag->FindCTrack(DescLevel(ALIGNTOSPLINETAG_POSITION,DTYPE_REAL,0));  
                                    if (!track)  
                                    {  
                                        track = CTrack::Alloc(tag,DescLevel(ALIGNTOSPLINETAG_POSITION,DTYPE_REAL,0));  
                                        if (!track) return FALSE;  
                                        tag->InsertTrackSorted(track);  
                                        GePrint("Track Created");  
                                    }  
                                  
                                    BaseTime btime = doc->GetTime();  
                                  
                                    btime.SetDenominator(op->GetDataInstance()->GetReal(ORBIT_SPEED));  
                                    Real deNom;  
                                    deNom = btime.GetDenominator();  
                                  
                                    btime.SetNominator(0);  
                                    tag->GetDataInstance()->SetReal(ALIGNTOSPLINETAG_POSITION, 0);  
                    
                                    GePrint ("POSTITION IS" + RealToString(tag->GetDataInstance()->GetReal(ALIGNTOSPLINETAG_POSITION, 0.0)));   
                                    CKey *key = track->GetCurve()->AddKey(btime,0);  
                                    if (!key) return false;      
                    
                                    btime.SetNominator(deNom);  
                                    tag->GetDataInstance()->SetReal(ALIGNTOSPLINETAG_POSITION, 100);  
                                      
                                    GePrint ("POSTITION IS" + RealToString(tag->GetDataInstance()->GetReal(ALIGNTOSPLINETAG_POSITION, 0.0)));  
                                    CKey *key2 = track->GetCurve()->AddKey(btime,0);  
                                    if (!key) return false;  
                                  
                                    track->SetAfter(CLOOP_REPEAT);  
                                }  
                            }  
                  

                  Now it creates the keyframes for the align to spline tag.   But it is not setting the position at those key frames..     so the lines:

                    
                  tag->GetDataInstance()->SetReal(ALIGNTOSPLINETAG_POSITION, 0);  
                  

                  and...

                    
                  tag->GetDataInstance()->SetReal(ALIGNTOSPLINETAG_POSITION, 0);  
                  

                  are not setting the align to spline position where the keyframe is being placed.    Does anyone know why this isn't working?

                  Thanks,

                  ~Shawn

                  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 25/12/2009 at 18:28, xxxxxxxx wrote:

                    I think you have to set the key's value to the key itself using SetValue (or SetGeData in the case of bools and such). As you know I'm pretty wet behind the ears when it comes to this stuff; so...

                    But I think you wanna do it like this:

                    key->SetValue(track->GetCurve(), 0);
                    

                    Merry Christmas:)

                    kvb

                    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 25/12/2009 at 21:00, xxxxxxxx wrote:

                      Awesome..  That was exactly what I needed..  Thanks a lot.

                      ~Shawn

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