本文整理汇总了C++中COFile类的典型用法代码示例。如果您正苦于以下问题:C++ COFile类的具体用法?C++ COFile怎么用?C++ COFile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了COFile类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: exportSWT
bool CNelExport::exportSWT(const char *sPath, std::vector<INode*>& vectNode)
{
float rPosValue;
float rRotValue;
float rScaleValue;
CSkeletonWeight::TNodeArray aSWNodes; // Array of Skeleton Weight Node
int nNumNode = 0;
aSWNodes.empty();
// Build the array of node
std::vector<INode*>::iterator it = vectNode.begin();
for(int i=0; i<(int)vectNode.size(); ++i,++it)
{
// Get the SWT Modifier
INode *pNode = *it;
// SWT active ?
if (CExportNel::getScriptAppData (pNode, NEL3D_APPDATA_EXPORT_SWT, BST_UNCHECKED) != BST_UNCHECKED)
{
// Get the value
rPosValue = CExportNel::getScriptAppData (pNode, NEL3D_APPDATA_EXPORT_SWT_WEIGHT, 0.f);
rRotValue = rPosValue;
rScaleValue = rPosValue;
// Store them in the temporary list
aSWNodes.resize(nNumNode+3);
aSWNodes[nNumNode].Name = pNode->GetName();
aSWNodes[nNumNode].Name += std::string (".")+ITransformable::getRotQuatValueName();
aSWNodes[nNumNode].Weight = rRotValue;
++nNumNode;
aSWNodes[nNumNode].Name = pNode->GetName();
aSWNodes[nNumNode].Name += std::string (".")+ITransformable::getPosValueName ();
aSWNodes[nNumNode].Weight = rPosValue;
++nNumNode;
aSWNodes[nNumNode].Name = pNode->GetName();
aSWNodes[nNumNode].Name += std::string (".")+ITransformable::getScaleValueName();
aSWNodes[nNumNode].Weight = rScaleValue;
++nNumNode;
}
}
if (aSWNodes.size())
{
CSkeletonWeight sw;
COFile file;
sw.build( aSWNodes );
if (file.open (sPath))
{
try
{
// Serial the skeleton
sw.serial (file);
// All is good
return true;
}
catch (Exception &e)
{
nlwarning (e.what());
}
}
}
else
{
// No node found with a SWT Modifier
nlwarning ("No node found with a SWT Modifier");
}
return false;
}
示例2: tr
//TODO titegus: replace that by 4 buttons Export128Diffuse, Export128Additive, Export256Diffuse, Export256Diffuse ?
void CTile_browser_dlg::on_exportBorderPushButton_clicked()
{
// Select a file
QFileDialog::Options options;
QString selectedFilter;
QString fileName = QFileDialog::getSaveFileName(this, tr("Choose Bitmap"), QString(tileBankBrowser.getAbsPath().c_str()) , "Targa Bitmap(*.tga);;All Files (*.*);;", &selectedFilter, options);
if (!fileName.isEmpty())
{
fileName = QDir::toNativeSeparators(fileName);
// Get the border of the bank
std::vector<NLMISC::CBGRA> array;
// 256 or 128 ?
int width, height;
//TODO titegus: And So what if Alpha ??? and what about border256 ???
tileBankBrowser.getTileSet (tileSetIndex)->getBorder128 ((CTile::TBitmap)tileTextureButtonGroup->checkedId())->get (width, height, array);
// Make a bitmap
if (width&&height)
{
NLMISC::CBitmap bitmap;
bitmap.resize (width, height, NLMISC::CBitmap::RGBA);
// Get pixel
CRGBA *pPixel=(CRGBA*)&bitmap.getPixels()[0];
// Make a copy
for (int i=0; i<width*height; i++)
{
// Copy the pixel
pPixel->R=array[i].R;
pPixel->G=array[i].G;
pPixel->B=array[i].B;
pPixel->A=array[i].A;
pPixel++;
}
// Write the bitmap
bool error=false;
try
{
COFile file;
if (file.open (fileName.toStdString().c_str()))
{
// Export
bitmap.writeTGA (file, 32);
}
else
error=true;
}
catch (Exception& e)
{
const char *toto=e.what ();
error=true;
}
// Error during export ?
if (error)
{
// Error message
QString s = tr("Can't write bitmap %1").arg(fileName);
QMessageBox::information (this, tr("Export border"), s);
}
}
}
}