Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Get data about moving objects in c4d file

    Cineware SDK
    sdk r21
    3
    5
    1.2k
    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.
    • T
      tsj_JNU
      last edited by

      Here is a file in C4D format, and the object in the file is motion, and I want to get the pose of each frame in motion, or I want to read the data of key frames in the file, as shown in the figure
      c86da7da-40c4-443c-bbcb-48fdfb3a1c35-image.png

      What should I do?

      1 Reply Last reply Reply Quote 0
      • ManuelM
        Manuel
        last edited by

        Hi,

        Just to be sure, you want to use Cineware and read that file from another software than Cinema 4D?

        Cheers,
        Manuel

        MAXON SDK Specialist

        MAXON Registered Developer

        1 Reply Last reply Reply Quote 0
        • T
          tsj_JNU
          last edited by

          Hi
          I wanted to use the Cineware SDK, but could not find the relevant information!
          Thank you!

          1 Reply Last reply Reply Quote 0
          • ManuelM
            Manuel
            last edited by

            hi,
            This is like retrieving the information from a document inside cinema4D. You need to get the CTrack first, fromt that CTrack you can retrieve the CCurve and retrieve the values from CCurve.

            To retrieve the information, you will need to understand the concept of DescID, check our manual about them. You can read our manual about CTrack You will find interesting manual about animation at this page

            
            	const char* fn = "cube_anim.c4d";
            	auto ExitError = [](const String& msg ) -> int
            	{
            		printf("error : %s", msg);
            		char value;
            		printf("\n <press return to exit>");
            		scanf("%c", &value);
            		return 0;
            	
            	};
            
            	// check if the file exists
            	if (!GeFExist(fn))
            		ExitError("\n   file do not exist\n   aborting...");
            		
            	// in this document, i've got the first object that is a cube with several tracks with an animation of the cube moving along the Z axis.
            	BaseDocument* doc = LoadDocument(fn, SCENEFILTER_MATERIALS | SCENEFILTER_OBJECTS);
            	if (!doc)
            		ExitError("no document found");
            
            
            	BaseObject* cube  = doc->GetFirstObject();
            	if (!cube)
            		ExitError("no object found found");;
            
            	// To retrieve the position.z track we need to define its DescID
            	DescID trackID = DescID(DescLevel(ID_BASEOBJECT_REL_POSITION, DTYPE_VECTOR, 0), DescLevel(VECTOR_Z, DTYPE_REAL, 0));
            	CTrack* cubeTrack = cube->FindCTrack(trackID);
            	if (!cubeTrack)
            		ExitError("no track found");;
            	
            	// Get the curve of that track
            	CCurve* curve = cubeTrack->GetCurve();
            	if (!curve)
            		ExitError("no curve found");
            
            	const Int32 docFPS = doc->GetFps();
            	
            	for (Int32 frame = 0; frame < 30; frame++)
            	{
            		const BaseTime timeToSample = BaseTime(frame, docFPS);
            		doc->SetTime(timeToSample);
            		doc->Execute();
            
            		const Float value = curve->GetValue(timeToSample);
            		printf("value at this frame : %i   value  %i\n", frame, value);
            	}
            
            	// display all values of all tracks
            
            	for (Int32 frame = 0; frame < 30; frame++)
            	{
            
            		// define the document's time and execute so everything update correctly.
            		const BaseTime timeToSample = BaseTime(frame, docFPS);
            		doc->SetTime(timeToSample);
            		doc->Execute();
            
            		// Retrieve the first track
            		CTrack* track = cube->GetFirstCTrack();
            		while (track)
            		{
            			CCurve* trackCurve = track->GetCurve();
            			if (!trackCurve)
            				continue;
            			const Float value = trackCurve->GetValue(timeToSample);
            			// display the name of the track and the value sampled.
            			printf("value of track %s at this frame : %i   value  %i\n", track->GetName().GetCStringCopy(STRINGENCODING::STRINGENCODING_8BIT), frame, value);
            			track = track->GetNext();
            		}
            	}
            
            
            	// to keep the console window open wait here for input
            	char value;
            	printf("\n <press return to exit>");
            	scanf("%c", &value);
            
            

            Cheers,
            Manuel

            MAXON SDK Specialist

            MAXON Registered Developer

            1 Reply Last reply Reply Quote 0
            • ferdinandF
              ferdinand
              last edited by

              Hello @tsj_JNU,

              without any further questions we will consider this topic as solved by Friday, December the 17th.

              Thank you for your understanding,
              Ferdinand

              MAXON SDK Specialist
              developers.maxon.net

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