THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 06/08/2007 at 22:41, xxxxxxxx wrote:
static void GetCameraSnapshoot( void );
void LauntchWindow()
{
Bool bSingleModul = FALSE;
LONG OldProc = 0;
BaseDocument* doc = GetActiveDocument();
BaseObject* null = doc->GetActiveObject();
if (!null)
{
null = doc->GetFirstObject();
if (!null)
{
return ;
}
}
BaseTrack *track = null->GetTrack(Spla);
if (!track )
{
//is picture
nTypeObj = 0;
}
else
{
//is animal
nTypeObj = 1;
}
for ( LONG num = 0 ; num< 4; num++ )
{
//set view to active
SetActiveViewFromNum(num);
LONG proc = doc->GetBaseDraw( num )->GetProjection();
if ( OldProc == proc )
{
bSingleModul = TRUE;
break;
}
switch(proc )
{
case Pperspective:
{
if ( nTypeObj == 0)
{
Snapshoot("0_perspective"); //perspective is snapshoot name
}
else
{
Snapshoot("1_perspective"); //perspective is snapshoot name
}
break;
}
case Ptop:
{
if ( nTypeObj == 0)
{
Snapshoot("0_top"); //top is snapshoot name
}
else
{
Snapshoot("1_top"); //top is snapshoot name
}
break;
}
case Pright:
{
if ( nTypeObj == 0)
{
Snapshoot("0_right");
}
else
{
Snapshoot("1_right");
}
break;
}
case Pfront:
{
if ( nTypeObj == 0)
{
Snapshoot("0_front");
}
else
{
Snapshoot("1_front");
}
break;
}
}
OldProc = proc;
}
//is single view modul
if ( bSingleModul == TRUE )
{
BaseDraw *bd = doc->GetActiveBaseDraw();
for ( LONG num = 0 ; num< 4; num++ )
{
switch( num )
{
case 0:
{
GeData da(BASEDRAW_PROJECTION_PERSPECTIVE);
bd->SetParameter(DescLevel(BASEDRAW_DATA_PROJECTION),da,NULL);
DrawViews(DA_ONLY_ACTIVE_VIEW);
//get snapshoot
if ( nTypeObj == 0)
{
Snapshoot("0_perspective"); //perspective is snapshoot name
}
else
{
Snapshoot("1_perspective"); //perspective is snapshoot name
}
break;
}
case 1:
{
GeData da(BASEDRAW_PROJECTION_TOP);
bd->SetParameter(DescLevel(BASEDRAW_DATA_PROJECTION),da,NULL);
DrawViews(DA_ONLY_ACTIVE_VIEW);
//get snapshoot
if ( nTypeObj == 0)
{
Snapshoot("0_top"); //top is snapshoot name
}
else
{
Snapshoot("1_top"); //top is snapshoot name
}
break;
}
case 2:
{
GeData da(BASEDRAW_PROJECTION_RIGHT);
bd->SetParameter(DescLevel(BASEDRAW_DATA_PROJECTION),da,NULL);
DrawViews(DA_ONLY_ACTIVE_VIEW);
//get snapshoot
if ( nTypeObj == 0)
{
Snapshoot("0_right");
}
else
{
Snapshoot("1_right");
}
break;
}
case 3:
{
GeData da(BASEDRAW_PROJECTION_FRONT);
bd->SetParameter(DescLevel(BASEDRAW_DATA_PROJECTION),da,NULL);
DrawViews(DA_ONLY_ACTIVE_VIEW);
//get snapshoot
if ( nTypeObj == 0)
{
Snapshoot("0_front");
}
else
{
Snapshoot("1_front");
}
break;
}
}//end switch
}//end for
//reset to PERSPECTIVE
GeData da(BASEDRAW_PROJECTION_PERSPECTIVE);
bd->SetParameter(DescLevel(BASEDRAW_DATA_PROJECTION),da,NULL);
EventAdd();
}
GetCameraSnapshoot();
}
void Snapshoot( char FileName[] )
{
BaseDocument* doc = GetActiveDocument();
if (!doc) return;
String sFileName = String( FileName ) + String(".jpg");
BaseObject* null = doc->GetActiveObject();
if (!null)
{
null = doc->GetFirstObject();
if (!null)
{
return; //have't object
}
}
BaseContainer rdata = doc->GetActiveRenderData()->GetData();
//set to render as editor
rdata.SetBool(RDATA_RENDERASEDITOR, TRUE);
char* szPath = bNew CHAR[512];
GetShadeImageDir( szPath );
//MessageDialog(szPath);
//char * szPath = "C:\\Documents and Settings\\Administrator\\Turbo Squid Tentacles\\Uploaded\\Shade";
String sPath = String( szPath );
bDelete(szPath);
Filename renderpath = Filename( sPath ); // for instance
rdata.SetFilename(RDATA_PATH, renderpath);
//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);
String sFullPath = sPath + "\" + sFileName;
//MessageDialog(sFullPath);
bmp->Save( Filename(sFullPath), FILTER_JPG, NULL, SAVEBIT_32b*tchANNELS);
BaseBitmap::Free( bmp );
BaseBitmap::Free( desbmp );
}
static void SetActiveViewFromNum( LONG iNUM = 0 )
{
BaseDocument* doc = GetActiveDocument();
LONG lngIndex = 0;
lngIndex = iNUM;
BaseDraw *bd = doc->GetActiveBaseDraw();
switch( lngIndex )
{
case 0:
{
//BaseDraw *bd = doc->GetBaseDraw( 0);
//bd->SetBit( BIT_ACTIVE );
//bd->SetBit( BIT_DOCUMENT_CHECKREWIND );
//SendCoreMessage(EVMSG_ACTIVEVIEWCHANGED);
//EventAdd(EVMSG_ACTIVEVIEWCHANGED);
GeData da(BASEDRAW_PROJECTION_PERSPECTIVE);
bd->SetParameter(DescLevel(BASEDRAW_DATA_PROJECTION),da,NULL);
}
break;
case 1:
{
//BaseDraw *bd = doc->GetBaseDraw( 1 );
//bd->SetBit( BIT_ACTIVE );
//bd->SetBit( BIT_DOCUMENT_CHECKREWIND );
//EventAdd(EVMSG_ACTIVEVIEWCHANGED);
GeData da(BASEDRAW_PROJECTION_TOP);
bd->SetParameter(DescLevel(BASEDRAW_DATA_PROJECTION),da,NULL);
}
break;
case 2:
{
//BaseDraw *bd = doc->GetBaseDraw( 2);
//bd->SetBit( BIT_ACTIVE );
//bd->SetBit( BIT_DOCUMENT_CHECKREWIND );
GeData da(BASEDRAW_PROJECTION_RIGHT);
bd->SetParameter(DescLevel(BASEDRAW_DATA_PROJECTION),da,NULL);
}
break;
case 3:
{
//BaseDraw *bd = doc->GetBaseDraw( 3);
//bd->SetBit( BIT_ACTIVE );
//bd->SetBit( BIT_DOCUMENT_CHECKREWIND );
GeData da(BASEDRAW_PROJECTION_FRONT);
bd->SetParameter(DescLevel(BASEDRAW_DATA_PROJECTION),da,NULL);
}
break;
}
EventAdd();
}
void GetAllCameras(AtomArray *oCams,BaseObject *oCam)
{
if(oCam)
{
if(oCam->GetType()==Ocamera)
oCams->Append(oCam);
if(oCam->GetDown())
GetAllCameras(oCams,oCam->GetDown());
if(oCam->GetNext())
GetAllCameras(oCams,oCam->GetNext());
}
}
LONG GetAllCameras(AtomArray *oCams)
{
if(!oCams)
{
//MessageDialog("Alloc AtomArray Fail that Can't get Camera ");
return 0;
}
BaseDocument *doc=GetActiveDocument();
BaseObject *obj=doc->GetFirstObject();
if(obj)
{
GetAllCameras(oCams,obj);
}
return oCams->GetCount();
}
static void GetCameraSnapshoot( void )
{
LONG nCount = 0;
LONG nIndex[256] ={0};
AtomArray *oCameras = AtomArray::Alloc();
if ( !oCameras )
{
return ;
}
LONG lCamCnt = GetAllCameras(oCameras);
BaseDocument* doc = GetActiveDocument();
//MessageDialog( LongToString(lCamCnt) );
for(LONG i = 0;i < lCamCnt; i++)
{
BaseObject *obj=(BaseObject * )oCameras->GetIndex(i);
MessageDialog(obj->GetName());
if ( !obj) break;
String camname = obj->GetName();
LONG iLen = camname.GetCStringLen(St8bit)+1;
char* pName = bNew CHAR[iLen];
camname.GetCString( pName,iLen);
BaseObject * oldcam = doc->GetRenderBaseDraw()->GetSceneCamera( doc );
doc->GetRenderBaseDraw()->SetSceneCamera( obj );
Snapshoot( pName ); //perspective is snapshoot name
bDelete(pName);
}
AtomArray::Free(oCameras) ;
return ;
}
this is my some codes: to get snapshoot (viewport and cameras) when the plugin be clicked and launch my operation windonws