How to get target object in camera
-
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!");
} -
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.
-
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..
-
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 !");
}