ofEasyCam save as pdf


ofBeginSaveScreenAsPdf ignores my ofEasyCam position.
Is it by design or should I post an issue?

    if (bSaveAsPdf) {  
        ofBeginSaveScreenAsPDF(ofGetTimestampString() + ".pdf");  
    float normalLength =  30.f;  
    for (int i = 0; i < vertices.size(); i++) {  
        ofVec3f tmpVec = mesh.getVertex(i);  
        float noiseValue = -ofGetFrameNum()*.1f;  
        tmpVec.x = vertices[i].x + (normals[i].x * noiseValue);  
        tmpVec.y = vertices[i].y + (normals[i].z * noiseValue);  
        tmpVec.z = vertices[i].z + (normals[i].z * noiseValue);  
        ofCircle(tmpVec.x, tmpVec.y, tmpVec.z, 4);  
    if (bSaveAsPdf) {  
        bSaveAsPdf = false;  

ok, so cairo rendering seems to disregard 3d completely.
However there is in ofBeginsSaveScreenAsPDF a b3d bool parameter which was giving me some hope

void ofBeginSaveScreenAsPDF(string filename, bool bMultipage, bool b3D, ofRectangle viewport)  

but setting it to true doesn’t have any effect. The documentation doesn’t say anything. Is this parameter unimplemented?

actually by looking at the implementation of ofCairoGraphics it seems to be implemented, but I’m not quite sure how to test beyond setting it to true on ofBeginSaveScreenAsPDF. Also in this old pull request by arturo


there is a dead link to a pdf rendering of the 3d squirrel so in principle it should be possible to have 3d correctly interpreted by cairo, but I can’t find the way.

Is there a more advanced example of cairo rendering available? maybe using it directly?

Any light greatly appreciated.

hey jesus

the 3d capabilities of the cairo renderer are very limited and at the time it doesn’t support cameras. the problem is ofCamera is currently using openGL directly instead of OF calls so the cairo renderer want get affected by the camera matrix. i want to solve this at some point by having an OF function to upload a matrix to whatever renderer you are using and make the cameras use those but it’s not there yet

Hey there Jesus,
the trick when it comes to saving 3d vector graphics in cairo etc. is to unproject the 3d unto 2d.
You simply need to iterate through the 3d paths when you are saving out and draw with

ofVec3f v2d = easyCam.worldToScreen(v3d);

That way you can retain 3d vectors in all their awesomeness.

Hope that helps

1 Like

Hey borg!

Never thanked you for this. I’ve been using it and It works beautifully. Thanks a lot!

May I ask an additional question? With that trick I can get the position of the object but I still need the size at which it should be rendered on the pdf. Do you know how I can calculate that size? I guess it has to do with the fov of the camera, but I’m my 3d math is hazy and I haven’t been able to find the solution.

Any pointers greatly appreciated.
Thanks again,