本文整理汇总了C++中AutoAlloc::Init方法的典型用法代码示例。如果您正苦于以下问题:C++ AutoAlloc::Init方法的具体用法?C++ AutoAlloc::Init怎么用?C++ AutoAlloc::Init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AutoAlloc
的用法示例。
在下文中一共展示了AutoAlloc::Init方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BrowsePath
/*********************************************************************\
Function name : CResEditBrowser::BrowsePath
Description :
Created at : 26.09.01, @ 11:59:42
Created by : Thomas Kunert
Modified by :
\*********************************************************************/
void CResEditBrowser::BrowsePath(Filename fn)
{
AutoAlloc <BrowseFiles> pBrowse;
pBrowse->Init(fn, false);
Filename fnBrowse;
TreeViewItem* pNewItem;
//TRACE_STRING(fn.GetString());
while (pBrowse->GetNext())
{
fnBrowse = pBrowse->GetFilename();
if (pBrowse->IsDir())
{
BrowsePath(fn + fnBrowse);
continue;
}
pNewItem = nullptr;
if (fnBrowse.CheckSuffix("res"))
pNewItem = m_wndTreeView.AddItem(fnBrowse.GetFileString(), m_pDialogsItem);
else if (fnBrowse.CheckSuffix("tif") || fnBrowse.CheckSuffix("jpg") || fnBrowse.CheckSuffix("bmp"))
pNewItem = m_wndTreeView.AddItem(fnBrowse.GetFileString(), m_pImagesItem);
if (pNewItem)
pNewItem->GetData()->SetString(ITEM_PATH_NAME, (fn + fnBrowse).GetString());
}
}
示例2: InitPoints
void DropEffector::InitPoints(BaseObject* op, BaseObject* gen, BaseDocument* doc, EffectorDataStruct* data, MoData* md, BaseThread* thread)
{
BaseContainer* bc = op->GetDataInstance();
if (!bc)
return;
if (!rcol)
return;
ed.mode = bc->GetInt32(DROPEFFECTOR_MODE);
ed.maxdist = bc->GetFloat(DROPEFFECTOR_DISTANCE);
ed.target = bc->GetObjectLink(DROPEFFECTOR_TARGET, doc);
if (!ed.target)
return;
ed.targmg = ed.target->GetMg();
ed.itargmg = ~ed.targmg;
ed.genmg = gen->GetMg();
ed.igenmg = ~ed.genmg;
//Add a dependency so that the effector will update if the target changes
AddEffectorDependence(ed.target);
//Can't init raycollider or the target isn't polygonal, then skip
if (!rcol->Init(ed.target))
ed.target = nullptr;
else if (!ed.target->IsInstanceOf(Opolygon))
ed.target = nullptr;
}
示例3: Init
/*********************************************************************\
Function name : CLanguageList::Init
Description :
Created at : 26.09.01, @ 16:11:23
Created by : Thomas Kunert
Modified by :
\*********************************************************************/
void CLanguageList::Init()
{
Filename resourcepath = GeGetStartupPath() + Filename("resource");
if (GetC4DVersion() >= 16000) {
// R16 has a new resource directory structure. The c4d_language.str
// files we are searching for are in resource/modules/c4dplugin/strings_xx.
// Fix for https://github.com/nr-plugins/resedit/issues/4
resourcepath = resourcepath + "modules" + "c4dplugin";
}
AutoAlloc <BrowseFiles> pBrowse;
pBrowse->Init(resourcepath, false);
while (pBrowse->GetNext())
{
if (pBrowse->IsDir())
{
Filename fn = pBrowse->GetFilename();
if (fn.GetString().SubStr(0, 8).ToLower() == "strings_")
{
String idx = fn.GetString();
idx.Delete(0, 8);
Filename stringname = resourcepath + fn+Filename("c4d_language.str");
AutoAlloc <BaseFile> pFile;
if (!pFile)
return;
if (!GeFExist(stringname))
{
GeOutString("Missing c4d_language.str to identify the string directory!!!", GEMB_ICONEXCLAMATION);
}
else if (pFile->Open(stringname))
{
Int32 len = pFile->GetLength();
Char *buffer = NewMemClear(Char,len + 2);
if (buffer)
{
pFile->ReadBytes(buffer,len);
buffer[len]=0;
Int32 i;
for (i = 0; i < len && buffer[i] >= ' '; i++) { }
buffer[i] = 0;
for (i--; i > 0 && buffer[i]== ' '; i--) { }
buffer[i + 1] = 0;
AddLanguage(buffer, idx);
DeleteMem(buffer);
}
}
}
}
}
CriticalAssert(GetNumLanguages() > 0);
}
示例4: Init
/*********************************************************************\
Function name : CLanguageList::Init
Description :
Created at : 26.09.01, @ 16:11:23
Created by : Thomas Kunert
Modified by :
\*********************************************************************/
void CLanguageList::Init()
{
Filename resourcepath = GeGetStartupPath() + Filename("resource");
AutoAlloc <BrowseFiles> pBrowse;
pBrowse->Init(resourcepath, false);
while (pBrowse->GetNext())
{
if (pBrowse->IsDir())
{
Filename fn = pBrowse->GetFilename();
if (fn.GetString().SubStr(0, 8).ToLower() == "strings_")
{
String idx = fn.GetString();
idx.Delete(0, 8);
Filename stringname = resourcepath + fn+Filename("c4d_language.str");
AutoAlloc <BaseFile> pFile;
if (!pFile)
return;
if (!GeFExist(stringname))
{
GeOutString("Missing c4d_language.str to identify the string directory!!!", GEMB_ICONEXCLAMATION);
}
else if (pFile->Open(stringname))
{
Int32 len = pFile->GetLength();
Char *buffer = NewMemClear(Char,len + 2);
if (buffer)
{
pFile->ReadBytes(buffer,len);
buffer[len]=0;
Int32 i;
for (i = 0; i < len && buffer[i] >= ' '; i++) { }
buffer[i] = 0;
for (i--; i > 0 && buffer[i]== ' '; i--) { }
buffer[i + 1] = 0;
AddLanguage(buffer, idx);
DeleteMem(buffer);
}
}
}
}
}
}
示例5: ReadDistriPrefs
static void ReadDistriPrefs(const Filename &fnDir)
{
AutoAlloc <BrowseFiles> pBrowse;
if (!pBrowse)
return;
Filename fn = fnDir;
Filename fnPreset;
pBrowse->Init(fn, false);
while (pBrowse->GetNext())
{
fnPreset = fn + pBrowse->GetFilename();
ReadPreset(fnPreset);
}
}
示例6: RegisterGradient
Bool RegisterGradient(void)
{
Filename fn = GeGetPluginPath()+"res"+"gradienttypes.tif";
AutoAlloc<BaseBitmap> bmp;
if (IMAGERESULT_OK!=bmp->Init(fn)) return FALSE;
RegisterIcon(200000135,bmp,0*32,0,32,32,ICONFLAG_COPY);
RegisterIcon(200000136,bmp,1*32,0,32,32,ICONFLAG_COPY);
RegisterIcon(200000137,bmp,2*32,0,32,32,ICONFLAG_COPY);
RegisterIcon(200000138,bmp,3*32,0,32,32,ICONFLAG_COPY);
RegisterIcon(200000139,bmp,4*32,0,32,32,ICONFLAG_COPY);
RegisterIcon(200000140,bmp,5*32,0,32,32,ICONFLAG_COPY);
RegisterIcon(200000141,bmp,6*32,0,32,32,ICONFLAG_COPY);
RegisterIcon(200000142,bmp,7*32,0,32,32,ICONFLAG_COPY);
// be sure to use a unique ID obtained from www.plugincafe.com
return RegisterShaderPlugin(1001161,GeLoadString(IDS_SDKGRADIENT),0,SDKGradientClass::Alloc,"Xsdkgradient",0);
}
示例7: GetVirtualObjects
BaseObject* VoxelGenerator::GetVirtualObjects(BaseObject* op, HierarchyHelp* hh)
{
BaseContainer* data = op->GetDataInstance();
BaseDocument* doc = op->GetDocument();
/************************************************************************/
Bool dirty = op->CheckCache(hh) || op->IsDirty(DIRTYFLAGS_DATA);
if (!dirty)
return op->GetCache(hh);
/************************************************************************/
Float t_scale = data->GetFloat(VGEN_SCALE); if(t_scale == 0.0) return nullptr;
Float t_threshold = data->GetFloat(VGEN_THRESHOLD);
Vector scale(t_scale); //Just the vector version of the uniform scale
/************************************************************************/
//Get the Effex Server (which contains all effex scenes)
FXAPI::FXServer *server = FXAPI::FXServer::Get(doc); if(!server) return nullptr;
//Get the scalar channel's BaseObject interface from the link field
BaseObject* channel_object = op->GetDataInstance()->GetObjectLink(VGEN_CHANNEL, doc); if(!channel_object) return nullptr;
//Find the Effex scene the scalar channel belongs to
FXAPI::FXScene* effex_scene = server->GetEffexScene(channel_object); if(!effex_scene) return nullptr;
//Finally retrieve the scalar channel node from the effex scene */
FXAPI::FXScalarChannel* ptr_channel = static_cast<FXAPI::FXScalarChannel*>(FXAPI::GetNode(effex_scene,channel_object,FXAPI::NodeRetrieveType_ScalarChannel));
if(!ptr_channel) return nullptr;
/************************************************************************/
//We wanna place all voxel cubes under this null object
BaseObject* ret = BaseObject::Alloc(Onull); if(!ret) { return nullptr; }
//Create a reference cube
BaseObject* voxel_cube = BaseObject::Alloc(Ocube); if(!voxel_cube) return ret;
//Set Normal scale
voxel_cube->GetDataInstance()->SetVector(PRIM_CUBE_LEN, Vector(1.0));
//Renaming the cube
voxel_cube->SetName("Voxel Reference");
//Tell the cube to update bounding box etc.
voxel_cube->Message(MSG_UPDATE);
//Finally place the cube under our null object
voxel_cube->InsertUnder(ret);
/************************************************************************/
//Now we create a scalar cell iterator which lets us browse all cells of a scalar channel
//You can use C4D's AutoAlloc class for scope based construction/destruction
//Otherwise just use FXAPI::FXScalarCellIterator::Alloc/Free
AutoAlloc<FXAPI::FXScalarCellIterator> iterator;
//Initialise it with our scalar channel, the cpu threads count we use and if grid border cells should be browsed as well
if(iterator->Init(ptr_channel, 1, true))
{
/************************************************************************/
/* The following part could be called from multiple cpu threads */
/* but here we stay single-threaded */
/************************************************************************/
Int32 cpu_index = 0; //First cpu = 0
//Call once per thread
iterator->Start(cpu_index,false); //passing true would give a reverse iterator
do //Now we browse with a do...while loop all cells of this cpu
{
//The iterator gives us the current cell value
double cell_scalar_value = iterator->GetValue(cpu_index);
//Example: check for value threshold to only create instances in cells containing a value (e.g. smoke density)
if(cell_scalar_value <= t_threshold)
continue; //don't process this cell
//Get the current cell's coordinate (in grid cell space)
NAVIE_GLOBAL::VecInt3D xyz_cell = iterator->GetCoordinate(cpu_index);
//Now convert coordinates from grid cell space to world space coordinates
//which we will use to set the cube instances's position
NAVIE_GLOBAL::vector3d xyz_global;
if(FXAPI::GridToWorld(ptr_channel, xyz_cell, xyz_global, false))
{
//Conversion was fine. Now we create an instance object for this cell
BaseObject* voxel_instance = BaseObject::Alloc(Oinstance); if(!voxel_instance) continue;
//Set the reference voxel cube as source
voxel_instance->GetDataInstance()->SetLink(INSTANCEOBJECT_LINK, voxel_cube);
//Make it a render instance
voxel_instance->GetDataInstance()->SetBool(INSTANCEOBJECT_RENDERINSTANCE, true);
//Renaming the instance to Voxel + its linear coordinate index
voxel_instance->SetName("Voxel Reference" + String::IntToString(iterator->GetLinearCoordinate(cpu_index)));
//Set position (converting from an Effex vector3d to a c4d Vector on the fly)
voxel_instance->SetAbsPos(FXAPI::Vec3DToVector(xyz_global));
//We also control the scale by the scalar cell value
voxel_instance->SetAbsScale(scale * cell_scalar_value);
//Tell the instance to update all its data
voxel_instance->Message(MSG_UPDATE);
//Finally place the instance under our null object
voxel_instance->InsertUnderLast(ret);
}
} while(iterator->SetNext(cpu_index)); //Go to next cell..
//.........这里部分代码省略.........
示例8: Command
/*********************************************************************\
Function name : CResEditBrowser::Command
Description :
Created at : 25.09.01, @ 22:33:39
Created by : Thomas Kunert
Modified by :
\*********************************************************************/
Bool CResEditBrowser::Command(Int32 lID, const BaseContainer &msg)
{
switch (lID)
{
case IDC_BROWSE_BUTTON: {
Filename fn = m_strPath;
AutoAlloc <BrowseFiles> pFiles;
pFiles->Init(Filename("\\"), false);
if (!m_strPath.Content())
fn = GeGetStartupPath() + String("resource");
if (fn.FileSelect(FILESELECTTYPE_ANYTHING, FILESELECT_DIRECTORY, GeLoadString(IDS_SPECIFY_RES_PATH)))
{
m_strPath = fn;
FillList();
}
break;
}
case IDC_DIRECTORY_TREE: {
TreeViewItem* pSelItem = (TreeViewItem*)msg.GetVoid(TREEVIEW_MESSAGE_ITEM);
Int32 lType = msg.GetInt32(TREEVIEW_MESSAGE_TYPE);
if (!pSelItem) break;
if (lType == TREEVIEW_DOUBLECLICK)
{
Filename fn = pSelItem->GetData()->GetString(ITEM_PATH_NAME);
if (fn.CheckSuffix("res"))
{
// open the resource file
if (!g_bWasActive)
{ CResEditMenu m; m.Execute(nullptr); }
if (!g_pTreeDialog) break;
g_pTreeDialog->OpenDialog(fn);
}
else if (fn.CheckSuffix("str"))
{
CDialogDoc tempDoc;
tempDoc.LoadGlobalStringTable(m_strPath, pSelItem->GetData()->GetString(TREEVIEW_TEXT));
CStringtableDialog dlg(&tempDoc, true);
if (dlg.Open())
{
if (GeOutString(GeLoadString(IDS_SAVE_STRINGTABLE), GEMB_YESNO | GEMB_ICONQUESTION) == GEMB_R_YES)
{
tempDoc.SaveGlobalStringTable();
}
}
}
else if (fn.Content())
{
// open the file (it may be an image)
GeExecuteFile(fn);
}
return true;
}
else if (lType == TREEVIEW_SELCHANGE)
{
m_dirText = pSelItem->GetData()->GetString(ITEM_PATH_NAME);
}
break;
}
};
return GeDialog::Command(lID, msg);
}
示例9: FillList
/*********************************************************************\
Function name : CResEditBrowser::FillList
Description :
Created at : 25.09.01, @ 22:58:07
Created by : Thomas Kunert
Modified by :
\*********************************************************************/
void CResEditBrowser::FillList()
{
SetTitle(GeLoadString(IDS_BROWSER_CAPT) + " - " + m_strPath.GetString());
GeShowMouse(MOUSE_BUSY);
m_wndTreeView.LockWindowUpdate();
m_wndTreeView.Reset();
m_pDialogsItem = m_wndTreeView.AddItem(GeLoadString(IDS_BROWSER_DIALOGS));
m_pImagesItem = m_wndTreeView.AddItem(GeLoadString(IDS_BROWSER_IMAGES));
m_pStringTablesItem = m_wndTreeView.AddItem(GeLoadString(IDS_BROWSER_STRIG_TABLES));
BrowsePath(m_strPath);
// add global string table(s)
CDoubleLinkedList <CStringTableName> stringList;
AutoAlloc <BrowseFiles> pBrowse;
pBrowse->Init(m_strPath, false);
while (pBrowse->GetNext())
{
if (!pBrowse->IsDir()) continue;
Filename fnNew = pBrowse->GetFilename();
if (fnNew.GetString().SubStr(0, 8).ToLower() == "strings_")
{
Filename fnStringTable = m_strPath + fnNew;
TRACE("Found string table path ");
//TRACE_STRING(fnStringTable.GetString());
AutoAlloc <BrowseFiles> pBrowseTable;
pBrowseTable->Init(fnStringTable, false);
while (pBrowseTable->GetNext())
{
Filename fnTable = pBrowseTable->GetFilename();
if (fnTable.CheckSuffix("str"))
{
TRACE(" ");
//TRACE_STRING(fnTable.GetString());
String strNewName = fnTable.GetString();
// check, if we didn't find this table before
CStringTableName *pSearch = stringList.First();
Bool bFound = false;
while (pSearch)
{
if (pSearch->strName == strNewName)
{
bFound = true;
break;
}
pSearch = stringList.Next(pSearch);
}
if (bFound) continue;
CStringTableName *pNewItem = NewObjClear(CStringTableName);
pNewItem->strName = strNewName;
stringList.Append(pNewItem);
}
}
}
}
CStringTableName *pInsert = stringList.First();
while (pInsert)
{
TreeViewItem* pNewItem = m_wndTreeView.AddItem(pInsert->strName, m_pStringTablesItem);
pNewItem->GetData()->SetString(ITEM_PATH_NAME, pInsert->strName);
pInsert = stringList.Next(pInsert);
}
stringList.FreeList();
m_wndTreeView.SortChildren(m_pDialogsItem);
m_wndTreeView.SortChildren(m_pImagesItem);
m_wndTreeView.SortChildren(m_pStringTablesItem);
m_wndTreeView.UnlockWindowUpdate();
GeShowMouse(MOUSE_NORMAL);
}