Skip to content

Instantly share code, notes, and snippets.

@julik
Created March 23, 2011 00:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save julik/882373 to your computer and use it in GitHub Desktop.
Save julik/882373 to your computer and use it in GitHub Desktop.
CINEMA4D C.O.F.F.E.E. camera retimer tag
main(doc,op)
{
// Which frame to sample. Grab this from the userattr of the COFFEE tag!
var cofy = op->GetFirstTag();
// Gotcha - when rendering tags get reordered and coffee tag might not come first,
// so walk the fucking linked list until we arrive at the tag
while(cofy) {
if(instanceof(cofy, CoffeeExpressionTag)) break;
cofy = cofy->GetNext();
}
if(!cofy) return;
// Float attr
var at = cofy#ID_USERDATA:1;
// Sample FPS once
var fps = doc->GetFps();
// We need to pass a BaseTime object to the track sampler
var atTime = new(BaseTime);
atTime->SetFrame(at, fps);
// Positions
var myT = op->GetFirstCTrack();
var posX = myT->GetValue(doc, atTime, fps);
myT = myT->GetNext();
var posY = myT->GetValue(doc, atTime, fps);
myT = myT->GetNext();
var posZ = myT->GetValue(doc, atTime, fps);
// Then rotations
myT = myT->GetNext();
var rotH = myT->GetValue(doc, atTime, fps);
myT = myT->GetNext();
var rotP = myT->GetValue(doc, atTime, fps);
myT = myT->GetNext();
var rotB = myT->GetValue(doc, atTime, fps);
op->SetPosition(vector(posX, posY, posZ));
op->SetRotation(vector(rotH, rotP, rotB));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment