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

    How to get target object in camera

    Scheduled Pinned Locked Moved SDK Help
    4 Posts 0 Posters 354 Views
    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 Offline
      Helper
      last edited by

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

      On 22/07/2007 at 01:00, xxxxxxxx wrote:

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

      ---------
      I can to add an new camera? but can't get  target object to display in showmap()?  some anyone can help me? the code bellow :
      bool DoAddCamera()
      {
        MessageDialog("AddCamera START!");
       BaseDocument* doc = GetActiveDocument();
       
       BaseObject* null = doc->GetActiveObject();
          if (!null) return false;
       CameraObject* cam = (CameraObject* )BaseObject::Alloc(Ocamera);
       if ( !cam )
       {
        MessageDialog("CameraObject Create Fail!");
        return false;
       }
       doc->InsertObject(cam, NULL, NULL);
         
       Vector objvcr = null->GetMg().off;
       Vector camvcr;
       
       camvcr.x = objvcr.x - 500;
       camvcr.y = objvcr.y + 500;
       camvcr.z = objvcr.z - 500;
       
        cam->SetPos( camvcr );
        cam->SetRot(Vector(-0.8, -0.6, 0)); // Set rotation (radians, HPB)

      cam->SetZoom( 1.0 );
       cam->SetAperture( 36.0 );
       cam->SetFocus( 36.0 );
       cam->SetEditorMode( MODE_ON );
       
       AutoAlloc<BaseLink> link;
       link->SetLink( null );
       cam->SetParameter(DescID(TARGETEXPRESSIONTAG_LINK), GeData(link), NULL);
       
       EventAdd();
         // Active the camera
       BaseObject* oldcam = doc->GetActiveBaseDraw()->GetSceneCamera(doc);
       doc->GetActiveBaseDraw()->SetSceneCamera(cam);
       // Create some temporaries for the render
        BaseContainer rdata = cam->GetData();
          BaseBitmap* bmp = BaseBitmap::Alloc();
           bmp->Init(400, 400);
        
          DrawViews(DA_FORCEFULLREDRAW);
         bmp->Save( GeGetStartupPath() + "test_camera.jpg", FILTER_JPG ,&rdata,  SAVEBIT_32b*tchANNELS);
         // Active the old camera
        doc->GetActiveBaseDraw()->SetSceneCamera(oldcam);
            
       DrawViews(DA_FORCEFULLREDRAW);
         
       ShowBitmap(bmp);

      BaseBitmap::Free( bmp );
       MessageDialog("AddCamera End!");
       
       
      }

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

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

        On 22/07/2007 at 11:39, xxxxxxxx wrote:

        DrawViews() only causes a redraw in the View editor. It does not create a render nor does it create a bitmap. You need to do a render - ala RenderDocument(). And then you need to get at the render bitmap.

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

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

          On 22/07/2007 at 18:58, xxxxxxxx wrote:

          hi Robert,  thank you for your help. but how can I get the originality snapshoot from the editviewport and to save it as..

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

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

            On 31/07/2007 at 00:59, xxxxxxxx wrote:

            I have been solved the problem, it have to render. but set the Basecontain as editor. this code:
            void Snapshoot( char FileName[] )
            {
             MessageDialog("Snapshoot START!");
             BaseDocument* doc = GetActiveDocument();
             if (!doc) return;
                   //get active object
                BaseObject* null = doc->GetActiveObject();
                if (!null)
             {
              null = doc->GetFirstObject();
              if (!null)
              {
               return;  //have't object
              }
             }

            //get render data where container value of RDATA_RENDERASEDITOR setting true that status is edit and get snapshoot , can't to render 
             BaseContainer rdata = doc->GetActiveRenderData()->GetData();
             //set to render as editor , is control code, must to SET TRUE,
            // otherwise is render.

            rdata.SetBool(RDATA_RENDERASEDITOR, TRUE);
             // Set render settings
             rdata.SetFilename(RDATA_PATH, Filename(null->GetName()));
               
             //BaseBitmap* bmp = AllocBaseBitmap();
             BaseBitmap* bmp = BaseBitmap::Alloc();
             BaseBitmap* desbmp =  BaseBitmap::Alloc();
             
             bmp->Init(rdata.GetLong(RDATA_XRES),
                rdata.GetLong(RDATA_YRES));
             desbmp->Init(rdata.GetLong(RDATA_XRES),
                rdata.GetLong(RDATA_YRES));
             
             RenderDocument(doc, rdata, NULL, NULL, bmp, TRUE , NULL);
             bmp->Save( GeGetStartupPath() + "test_modul2.jpg", FILTER_JPG, NULL, SAVEBIT_32b*tchANNELS);
             if ( bmp )
             {  
              bmp->ScaleBicubic( desbmp, 0,0, bmp->GetBw(), bmp->GetBh(), 0, 0, 400, 400);
              
             }

            //ShowBitmap(bmp);
             if (bmp)
             {
              bmp->ScaleBicubic( desbmp, 0, 0, bmp->GetBw(), bmp->GetBh(), 0, 0, 400, 400);
              desbmp->Save(GeGetStartupPath() + "test_modul3.jpg", FILTER_JPG, NULL, SAVEBIT_32b*tchANNELS);
             }
             BaseBitmap::Free( bmp );
             
                BaseBitmap::Free( desbmp );
             
               MessageDialog("end !");
            }

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