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

    CTrack questions

    Scheduled Pinned Locked Moved SDK Help
    2 Posts 0 Posters 229 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 15/01/2011 at 08:17, xxxxxxxx wrote:

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

      ---------
      Okay so I have a function that worked 100% in R11.5 but does not do anything in R12.  The function rotates the active object at the speed specified based on the current framerate.

      I assume that somehting has changed in the timeline/ CTrack ...     Here's is the code that worked in R11.5.   Does anyone see any reason why it wouldn't work in R12?   I'm not asking you to debug the whole thing.  I am asking you to look to see if there is something in this code that has changed in the r12 sdk..   That will at least help me pin point what I should be looking at.

      Thanks so much,.

        
      //ROTATE PLANET  
      //====================================================//  
      Bool PlanetXObject::RotatePlanet(BaseObject *op, GeListNode* node){  
          
        if (!op) return FALSE;  
        
        BaseContainer *bc = ((BaseList2D* )node)->GetDataInstance();   
        if (!bc) return FALSE;  
        BaseDocument *doc = op->GetDocument();  
        if(!doc) return FALSE;  
        BaseObject* prnt = doc->GetActiveObject();  
        if(!prnt) return FALSE;  
        BaseTime time = doc->GetTime();  
        Real fps = doc->GetFps();  
        
        //Planet COUNTER CLOCKWISE Rotation  
        //==========================================//  
        if (bc->GetBool(PLANETX_GENERAL_ENABLE_ROTATION)  &&   
            bc->GetBool(PLANETX_GENERAL_ROTATION_DIRECTION) == PLANETX_GENERAL_ROTATION_COUNTER_CLOCKWISE){  
            //Remove Existing Track  
            //==========================================//  
            if (prnt->FindCTrack(DescID(DescLevel(myID,DTYPE_VECTOR,0), DescLevel(VECTOR_Z,DTYPE_REAL,0)))){  
                prnt->FindCTrack(DescID(DescLevel(myID,DTYPE_VECTOR,0), DescLevel(VECTOR_Z,DTYPE_REAL,0)))->Remove();  
            }  
            //Insert the New Track  
            //==========================================//  
            CTrack *track = prnt->FindCTrack(DescID(DescLevel(myID,DTYPE_VECTOR,0), DescLevel(VECTOR_Z,DTYPE_REAL,0)));  
            if (!track){  
                track = CTrack::Alloc(prnt,DescID(DescLevel(myID,DTYPE_VECTOR,0), DescLevel(VECTOR_Z,DTYPE_REAL,0)));  
                if (!track) return FALSE;  
        
                prnt->InsertTrackSorted(track);  
            }  
                //Get the Base Time  
                //==========================================//  
                BaseTime bstime = time;  
        
                //Set the Frame Rate (FPS)  
                //==========================================//  
                bstime.SetDenominator(fps);  
        
                Real deNomin;  
                deNomin = (60 *fps) / bc->GetReal(PLANETX_GENERAL_ROTATION_SPEED);  
        
                //First Key will be set at 0  
                //==========================================//  
                bstime.SetNumerator(0);  
                CKey *keyH = track->GetCurve()->AddKey(bstime,0);  
                if (!keyH) return false;  
                keyH->SetValue(track->GetCurve(),0); //Set Position to 0  
        
                //Second Key will be placed at deNomin  
                //==========================================//  
                bstime.SetNumerator(deNomin);  
                CKey *keyH2 = track->GetCurve()->AddKey(bstime,0);  
                if (!keyH2) return false;  
                keyH2->SetValue(track->GetCurve(),6.283185307); //Set Position to 360  
        
                track->SetAfter(CLOOP_REPEAT);  
        }  
        
        //Planet CLOCKWISE Rotation  
        //==========================================//  
        
        else if (bc->GetBool(PLANETX_GENERAL_ENABLE_ROTATION)  &&    
                 bc->GetBool(PLANETX_GENERAL_ROTATION_DIRECTION) == PLANETX_GENERAL_ROTATION_CLOCKWISE)  
        {  
            //Remove Existing Track  
            //==========================================//  
            if (prnt->FindCTrack(DescID(DescLevel(myID,DTYPE_VECTOR,0), DescLevel(VECTOR_Z,DTYPE_REAL,0))))  
            {  
                prnt->FindCTrack(DescID(DescLevel(myID,DTYPE_VECTOR,0), DescLevel(VECTOR_Z,DTYPE_REAL,0)))->Remove();  
            }  
              
            //Insert the New Track  
            //==========================================//  
            CTrack *track = prnt->FindCTrack(DescID(DescLevel(myID,DTYPE_VECTOR,0), DescLevel(VECTOR_Z,DTYPE_REAL,0)));  
            if (!track)  
            {  
                track = CTrack::Alloc(prnt,DescID(DescLevel(myID,DTYPE_VECTOR,0), DescLevel(VECTOR_Z,DTYPE_REAL,0)));  
                if (!track) return FALSE;  
                prnt->InsertTrackSorted(track);  
            }  
        
                //Get the Base Time  
                //==========================================//  
                BaseTime bstime = time;  
                  
                //Set the Frame Rate (FPS)  
                //==========================================================================  
                bstime.SetDenominator(fps);  
                      
                Real deNomin;  
                deNomin = (60 *fps) / bc->GetReal(PLANETX_GENERAL_ROTATION_SPEED);  
        
                //First Key will be set at 0  
                //==========================================================================  
                bstime.SetNumerator(0);  
                CKey *keyH = track->GetCurve()->AddKey(bstime,0);  
                if (!keyH) return false;  
                  
                keyH->SetValue(track->GetCurve(),6.283185307); //Set Position to 0  
                  
                //Second Key will be placed at 3 times the location of the frame rate (i.e. if FPS is set to 30, then the key will be placed at frame 45.  
                //==========================================================================  
                bstime.SetNumerator(deNomin);  
                CKey *keyH2 = track->GetCurve()->AddKey(bstime,0);  
                if (!keyH2) return false;  
                keyH2->SetValue(track->GetCurve(),0); //Set Position to 360  
        
                track->SetAfter(CLOOP_REPEAT);  
        }  
        
        else  
        {  
            if (prnt->FindCTrack(DescLevel(myID,DTYPE_REAL,0)))  
            {  
        
                prnt->FindCTrack(DescLevel(myID,DTYPE_REAL,0))->Remove();  
            }  
              
        }  
      }  
        
      

      PS this code compiles fine in R12 but does not rotate the object at all.   🙂

      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/01/2011 at 12:56, xxxxxxxx wrote:

        Solved this.   I just declared,

        DescID idRotY = DescID(DescLevel(ID_BASEOBJECT_REL_ROTATION,DTYPE_VECTOR,0),DescLevel(VECTOR_Y,DTYPE_REAL,0));

        and replaced all DescID calles with   idRotY

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