failing to access CTracks
-
On 29/03/2013 at 06:16, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 14.034
Platform: Windows ;
Language(s) : C++ ;---------
Hello,I am writing an exporter in C++ and cannot get any CTracks from my animated objects.
Here is the simple code:BaseObject* op = doc->GetFirstObject();
CTrack* track = op->GetFirstCTrack();while (track)
{
GePrint( "found track: " + track->GetName() );
track = track->GetNext();
}GetFirstCTrack() never returns a CTrack object.
I am new to the C++ SDK but I have managed to export static transformations, polygons, uvs etc.
Is there a plugin or function inside of Cinema 4D to get detailed SDK data structure information for debugging purposes?
Thanks for any help.
-
On 29/03/2013 at 07:58, xxxxxxxx wrote:
It looks like you might not be going deep enough.
Keys reside on curves, which reside in tracks.
So to get at a key value you need to go through the track->curve->key tree branching system.Example:
//This code Get's the key values on all the tracks of an object BaseObject* obj = doc->GetActiveObject(); //Get the active object if(!obj) return False; BaseTime time = doc->GetTime(); //Assigns the basetime class to a variable Real fps = doc->GetFps(); //Gets the frames per second value Real currentFrame = time.GetFrame(fps); //The current frame the slider is on CTrack *trk = obj->GetFirstCTrack(); //Get the first track while(trk) { CCurve *curve = trk->GetCurve(CCURVE_CURVE, FALSE); //Get the curve on the first track Real i; for(i=0; i<curve->GetKeyCount(); i++) { CKey *keys = curve->GetKey(i); //Get all of the keys Real keyframe = keys->GetTime().GetFrame(fps); //Assing the frame the keys are on to this variable float keyvalues = keys->GetValue(); // Get the values of each key GePrint("Frame= "+ RealToString(keyframe) + " " + " " + "Values= " + RealToString(keyvalues)); } trk = trk->GetNext(); }
-ScottA
-
On 29/03/2013 at 08:50, xxxxxxxx wrote:
Thanks for the code ScottA,
I didn't even get to CCurve and CKey yet because my problem is getting anything but NULL from:
CTrack \*trk = obj->GetFirstCTrack();
-
On 30/03/2013 at 17:35, xxxxxxxx wrote:
Trying the same in python gives me the expected CTrack names and subsequent data, so I know I actually have animated data...
import c4d def main() : obj = doc.GetFirstObject() while obj != None: print "tracks found for '" + obj.GetName() + ":" track = obj.GetFirstCTrack() while track != None: print track.GetName() curve = track.GetCurve() idx=0 while idx < curve.GetKeyCount() : key = curve.GetKey(idx) time = key.GetTime() print str( time.GetFrame(doc.GetFps()) ) + ": " + str(key.GetValue()) idx+=1 track = track.GetNext() obj = obj.GetNext()
-
On 01/04/2013 at 04:35, xxxxxxxx wrote:
Found the error on my part:
I created a clone of my document:
doc->Polygonize();
which defaults to not cloning any animations.
doc->Polygonize( true );
Does the trick.