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

    Camera Animation

    SDK Help
    0
    12
    835
    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

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

      On 09/06/2008 at 06:17, xxxxxxxx wrote:

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

      ---------

      Hi! I'm writing an exporter plugin and need information on how to extract camera animation. The camera is animated through its parent null object aligntospline tag.
      As i was unable to find any documentation on how this animation system works I have tried numerous approaches to retrieving this animation data.
      My first approach was using the Taligntospline tag;
      (pseudo)

      > \> ... \> for (LONG i=doc->getMinTime().Get()\*fps;i<doc->GetMaxTime().Get()\*fps;i++) { \> BaseTime time(i / fps); \> doc->AnimateObject(obj,time,0);          tag->GetParameter(DescID(ALIGNTOSPLINETAG_POSITION),data,NULL); \> Vector pos = data.GetVector(); \> ... \>

      That didnt give me anything useful (all data was 0) so I tried using CTracks etc. Iterating through the object hierarchy i I searched for CTracks;

      > \> CTrack \*postrack_x = op->FindCTrack(DescID( DescLevel(ID_BASEOBJECT_POSITION,DTYPE_VECTOR,0),DescLevel(VECTOR_X, DTYPE_REAL,0)) ); \>      CTrack \*postrack_y = op->FindCTrack(DescID( DescLevel(ID_BASEOBJECT_POSITION,DTYPE_VECTOR,0),DescLevel(VECTOR_Y, DTYPE_REAL,0)) ); \>      CTrack \*postrack_z = op->FindCTrack(DescID( DescLevel(ID_BASEOBJECT_POSITION,DTYPE_VECTOR,0),DescLevel(VECTOR_Z, DTYPE_REAL,0)) ); \>

      But that didnt give me anything but NULL (I also searched all tags).
      Clearly i must be missing out on some fundamental concepts of this animation system. I assume the data is stored in a CTrack somewhere (??), but I cant figure out how to find'em (IDs??). And yes, I did call Polygonize(true). Also tried getFirstCTrack().
      What I need is either a link to find some documentation on this issue or some pointers to guide me back on track:)

      Thanks!

      - bo

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

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

        On 09/06/2008 at 06:30, xxxxxxxx wrote:

        Just read out the global matrix of the camera object.

        Vector campos = camobj->GetMg().off

        cheers,
        Matthias

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

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

          On 09/06/2008 at 06:41, xxxxxxxx wrote:

          Ok, I tried that earlier, but maybe I was passing something erronous to animateobject etc (only got static position/orentation). Back on track now, thanks 🙂

          - marodern

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

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

            On 11/06/2008 at 06:09, xxxxxxxx wrote:

            Ok, still only getting static position and orientation from the global camera matrix. If I understood your post right, the GetMg() matrix will be updated using animateobject()?

            Here is a code snippet:

            > \> ModelingCommandData cd; \> BaseTime t1 = doc->GetMinTime(); \> BaseTime t2 = doc->GetMaxTime(); \> LONG fps = doc->GetFps(); \> for (LONG i=t1.GetFrame(fps);i<t2.GetFrame(fps);i++) {      \> time =BaseTime::BaseTime(i,fps); \> doc->AnimateObject(op,time,0); \> cd.doc = doc; \> cd.op = op; \> if (!SendModelingCommand(MCOMMAND_CURRENTSTATETOOBJECT, cd)) { \>                               ; \>                          } \> newpos = op->GetMg().off; \> newhpr = MatrixToHPB(op->GetMg()); \> } \>

            I have also tried using the cd.result object but that gives nothing. AnimateDocument() is giving the same results. Clearly I must be missing something essential to get the matrices updated. (I also tried setting the global matrix from the cd.result->getIndex(0) object)

            - marodern

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

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

              On 11/06/2008 at 06:49, xxxxxxxx wrote:

              You have to use AnimateDocument().

              > \> BaseTime tmin = doc->GetMinTime(); \> BaseTime tmax = doc->GetMaxTime(); \> BaseTime time; \> LONG i, fps = doc->GetFps(); \> time.SetDenominator(fps); \> \> \> for(i=tmin.GetFrame(fps); i<=tmax.GetFrame(fps); i++) \> { \>      time.SetNominator(i); \>      doc->SetTime(time); \>      doc->AnimateDocument(NULL, TRUE, TRUE); \>      GePrint(VectorToString(op->GetMg().off)); //my Vector to String function \> } \> \> EventAdd(); \>

              cheers,
              Matthias

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

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

                On 12/06/2008 at 05:23, xxxxxxxx wrote:

                Hi again, sorry for nagging about such a simple task 😕
                I just cant get the above sample to work. I copied it into to the stl exporter stub provided by the SDK, grabbed my camera object from the WriteObjects() method, cloned my document with doc.Polygonize(TRUE). I suspected that maybe the tags were working on a cloned document or something like that, but Ive tried all the tags GetDocument()'s, getActiveDocument etc. I get the correct (static) coordinates from my object so im working on the right object.

                The camera is animated from a null object like this:

                NullObject [XPresso, XPresso, AlignToSpline]
                |- CameraObject

                I call AnimateDocument(NULL,TRUE,TRUE) so it should eval all expressions and keep anim. So Im guessing im working on the wrong document ??

                Thanks for all help.
                - marodern

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

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

                  On 12/06/2008 at 06:44, xxxxxxxx wrote:

                  Here is the test code from the stl exporter stub.

                  > \> void test(BaseDocument \*doc, std::vector<BaseObject \*> camlist) { \> \>      BaseObject \*op = camlist[0]; \>      Vector pos; \>      BaseTime tmin = doc->GetMinTime(); \>      BaseTime tmax = doc->GetMaxTime(); \>      BaseTime time; \>      LONG i, fps = doc->GetFps(); \>      time.SetDenominator(fps);      \>      for(i=tmin.GetFrame(fps); i<=tmax.GetFrame(fps); i++) \>      { \>           time.SetNominator(i); \>           doc->SetTime(time); \>           doc->AnimateDocument(NULL, TRUE, TRUE); \>           pos = op->GetMg().off;           \>           GePrint("pos = " + RealToString(pos.x) + ", " + RealToString(pos.y) + ", " + RealToString(pos.z) ); \>      } \>      GePrint("CameraName: " + op->GetName()); \>      EventAdd(); \> } \> LONG mypluginSaverData::Save(PluginSceneSaver \*node, const Filename &name;, BaseDocument \*doc, LONG flags) \> { \>      if (!(flags&SCENEFILTER;\_OBJECTS)) return FILEERROR_NONE; \> \>      mypluginSAVE      myplugin; \>      CHAR                     header[80]; \> \>      myplugin.flags = flags; \>      myplugin.doc   = doc->Polygonize(TRUE); \> \>         if (!myplugin.doc || !myplugin.file) return FILEERROR_MEMORY; \> WriteObjects(myplugin,myplugin.doc->GetFirstObject(),Matrix()); \>      test(myVRplugin.doc,cameralist); // cameralist populated in WriteObjects, getting correct objects. \> \> ... \>

                  - marodern

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

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

                    On 13/06/2008 at 05:19, xxxxxxxx wrote:

                    Any ideas?? Already broke my deadline so im kinda hoping for some support here. I see the timeline updated in the editor, but the GetMg() matrix of the camera object does NOT get updated with AnimateDocument.

                    - marodern

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

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

                      On 13/06/2008 at 05:38, xxxxxxxx wrote:

                      Just an idea, is the document in your test function the polygonized document or the original document? You should animate the original document or a clone and polygonize it for each frame.

                      cheers,
                      Matthias

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

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

                        On 16/06/2008 at 00:14, xxxxxxxx wrote:

                        Hi, I tried both of the documents. A polygonize pr frame makes c4d crash. Even if it were not to crash, it sounds very expensive, and im working with very large models.

                        - marodern

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

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

                          On 23/06/2008 at 00:56, xxxxxxxx wrote:

                          Well you have to polygonize it for every frame. You can not animate a polygonized document. You could also animate the document and manually go through the hierachy and use a Current State To Object.

                          cheers,
                          Matthias

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

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

                            On 04/07/2008 at 14:25, xxxxxxxx wrote:

                            ...just be sure that you're freeing the (each) Polygonized document when you're done with it...

                                
                                
                                  
                                ....... S N I P ........  
                                  
                                BaseTime tmin = doc->GetMinTime();  
                                BaseTime tmax = doc->GetMaxTime();  
                                BaseTime time;  
                                LONG i, fps = doc->GetFps();  
                                
                                
                                
                                
                                
                                time.SetDenominator(fps);  
                                for(i=tmin.GetFrame(fps); i<=tmax.GetFrame(fps); i++)  
                                {  
                                    time.SetNominator(i);  
                                    doc->SetTime(time);  
                                    doc->AnimateDocument(NULL, TRUE, TRUE);
                                
                                
                                
                                
                                    BaseDocument *pPolyDoc = doc->Polygonize();  
                                    if( !pPolyDoc )  
                                    {  
                                        MessageDialog("Error cloning Document.");  
                                        EventAdd();  
                                        return false;  
                                    }
                                
                                
                                
                                
                                    ExportAFrameOfData(pPolyDoc);
                                
                                
                                
                                
                                    BaseDocument::Free(pPolyDoc); // <-- be sure to free the cloned document
                                
                                
                                
                                
                                }
                                
                                
                                
                                
                                ....... S N I P ........
                            
                            1 Reply Last reply Reply Quote 0
                            • First post
                              Last post