本文整理汇总了C++中MFileObject::fullName方法的典型用法代码示例。如果您正苦于以下问题:C++ MFileObject::fullName方法的具体用法?C++ MFileObject::fullName怎么用?C++ MFileObject::fullName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MFileObject
的用法示例。
在下文中一共展示了MFileObject::fullName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writer
MStatus FileTranslator::writer ( const MFileObject& file,
const MString& options,
MPxFileTranslator::FileAccessMode mode )
{
MStatus status = MStatus::kFailure;
try
{
// Extract the filename
#if defined (OSMac_)
char nameBuffer[MAXPATHLEN];
strcpy ( nameBuffer, file.fullName().asChar() );
const MString fileName ( nameBuffer );
#else
const MString fileName = file.fullName();
#endif // OSMac
// TODO Export the referenced files!
// Maya forces the write of all the references, on export.
// Intentionally skip known reference file paths.
for ( MItDependencyNodes it ( MFn::kReference ); !it.isDone(); it.next() )
{
MObject refNode = it.item();
MString refNodeName = MFnDependencyNode ( refNode ).name();
MString refNodeFilename;
MGlobal::executeCommand ( MString ( "reference -rfn \"" ) + refNodeName + MString ( "\" -q -filename" ),
refNodeFilename );
if ( refNodeFilename == fileName ) return MStatus::kSuccess;
if ( ExportOptions::exportXRefs() )
{
// TODO Open file export dialog ( !? HOW ?! ) to get a DAE filename
// to export the referenced file.
}
}
// Parse the export options
ExportOptions::set ( options );
// Check, if we should just export the selected Objects
exportSelection = mode == MPxFileTranslator::kExportActiveAccessMode;
// Do the actual export now
status = exportIntoFile ( fileName, exportSelection );
}
catch ( COLLADASW::StreamWriterException* swException )
{
String message = "StreamWriterException: " + swException->getMessage();
MGlobal::displayError ( message.c_str() );
}
catch ( ... )
{
MGlobal::displayError ( "ColladaMaya has thrown an exception!" );
}
return status;
}
示例2: writer
MStatus ObjTranslator::writer ( const MFileObject& file,
const MString& options,
FileAccessMode mode )
{
MStatus status;
MString mname = file.fullName(), unitName;
//just pass in the filename
#if defined (OSMac_)
char fname[256];//MAXPATHLEN];
strcpy (fname, file.fullName().asChar());
// fp = fopen(fname,"wb");//MAYAMACTODO
#else
const char *fname = mname.asChar();
// fp = fopen(fname,"w");
#endif
shared_ptr<solver_impl_t> solv = solver_t::get_solver();
solv->export_collada_file(fname);
return status;
}
示例3: writer
MStatus polyExporter::writer(const MFileObject& file,
const MString& /*options*/,
MPxFileTranslator::FileAccessMode mode)
//Summary: saves a file of a type supported by this translator by traversing
// the all or selected objects (depending on mode) in the current
// Maya scene, and writing a representation to the given file
//Args : file - object containing the pathname of the file to be written to
// options - a string representation of any file options
// mode - the method used to write the file - export, or export active
// are valid values; method will fail for any other values
//Returns: MStatus::kSuccess if the export was successful;
// MStatus::kFailure otherwise
{
#if defined (OSMac_)
char nameBuffer[MAXPATHLEN];
strcpy (nameBuffer, file.fullName().asChar());
const MString fileName(nameBuffer);
#else
const MString fileName = file.fullName();
#endif
ofstream newFile(fileName.asChar(), ios::out);
if (!newFile) {
MGlobal::displayError(fileName + ": could not be opened for reading");
return MS::kFailure;
}
newFile.setf(ios::unitbuf);
writeHeader(newFile);
//check which objects are to be exported, and invoke the corresponding
//methods; only 'export all' and 'export selection' are allowed
//
if (MPxFileTranslator::kExportAccessMode == mode) {
if (MStatus::kFailure == exportAll(newFile)) {
return MStatus::kFailure;
}
} else if (MPxFileTranslator::kExportActiveAccessMode == mode) {
if (MStatus::kFailure == exportSelection(newFile)) {
return MStatus::kFailure;
}
} else {
return MStatus::kFailure;
}
writeFooter(newFile);
newFile.flush();
newFile.close();
MGlobal::displayInfo("Export to " + fileName + " successful!");
return MS::kSuccess;
}
示例4: reader
MStatus FileTranslator::reader ( const MFileObject& file,
const MString& options,
MPxFileTranslator::FileAccessMode mode )
{
MStatus status ( MS::kSuccess );
try
{
#if MAYA_API_VERSION >= 800
if ( mode == MPxFileTranslator::kReferenceAccessMode )
{
int optionValue;
MGlobal::executeCommand ( "optionVar -q \"referenceOptionsSharedReference\";", optionValue );
if ( optionValue != 0 )
{
#ifdef WIN32
MessageBox ( NULL, "Maya may now hang. Do disable the reference option named: \"Shared Reference Nodes\".", "POSSIBLE HANG", MB_OK );
#endif
}
}
#endif // Maya 8.0 and 8.5
#if defined (OSMac_)
char nameBuffer[MAXPATHLEN];
strcpy ( nameBuffer, file.fullName().asChar() );
const MString filename ( nameBuffer );
#else
const MString filename = file.fullName();
#endif // OSMac
// Process the import options
ImportOptions::set ( options, mode );
if (ImportOptions::hasError()) status = MStatus::kFailure;
// Import the COLLADA DAE file
status = importFromFile ( filename.asChar() );
}
catch ( COLLADABU::Exception* exception )
{
MGlobal::displayWarning ( exception->getMessage().c_str() );
}
catch ( ... )
{
MGlobal::displayWarning ( "ColladaMaya has thrown an exception!" );
}
return status;
}
示例5: writer
MStatus CXRayObjectExport::writer ( const MFileObject& file, const MString& options, FileAccessMode mode )
{
MStatus status= MS::kFailure;
//move default extesion here..
MString mname = file.fullName()+".object";
LPCSTR fname = mname.asChar();
Log("Export object: ",fname);
CEditableObject* OBJECT = new CEditableObject(fname);
OBJECT->SetVersionToCurrent(TRUE,TRUE);
if((mode==MPxFileTranslator::kExportAccessMode)||(mode==MPxFileTranslator::kSaveAccessMode)){
status = ExportAll(OBJECT)?MS::kSuccess:MS::kFailure;
}else if(mode==MPxFileTranslator::kExportActiveAccessMode){
status = ExportSelected(OBJECT)?MS::kSuccess:MS::kFailure;
}
if (MS::kSuccess==status){
OBJECT->Optimize ();
OBJECT->SaveObject (fname);
Log("Object succesfully exported.");
Msg("%d vertices, %d faces", OBJECT->GetVertexCount(), OBJECT->GetFaceCount());
}else{
Log("! Export failed.");
}
xr_delete(OBJECT);
return status;
}
示例6: writer
//
// Maya calls this method to have the translator write out a file.
//
MStatus colorTransformDataTranslator::writer(
const MFileObject& file,
const MString& /* options */,
MPxFileTranslator::FileAccessMode mode
)
{
//
// For simplicity, we only do full saves/exports.
//
if ((mode != kSaveAccessMode) && (mode != kExportAccessMode))
return MS::kNotImplemented;
//
// Let's see if we can open the output file.
//
fstream output(file.fullName().asChar(), ios::out | ios::trunc);
if (!output.good()) return MS::kNotFound;
writeColorSpaceForNodes(output);
writeOutputTransformId(output);
writeColorTransformData(output);
output.close();
return MS::kSuccess;
}
示例7: writer
MStatus writer (const MFileObject& file, const MString& optionsString, MPxFileTranslator::FileAccessMode mode)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CMayaInterface mayaInterface;
if (!mayaInterface.Create (mode == MPxFileTranslator::kExportActiveAccessMode))
{
MGlobal::displayError("Failed to initialize cal3d CMayaInterface.");
return MS::kFailure;
}
// create an exporter instance
if(!theExporter.Create(&mayaInterface))
{
MGlobal::displayError(theExporter.GetLastError().c_str());
return MS::kFailure;
}
if (!theExporter.ExportSkeleton (file.fullName().asChar()))
{
MGlobal::displayError(theExporter.GetLastError().c_str());
return MS::kFailure;
}
return MS::kSuccess;
}
示例8: reader
MStatus BinMeshTranslator::reader(const MFileObject& file,
const MString& opts,
MPxFileTranslator::FileAccessMode mode)
{
options = opts;
#if defined (OSMac_)
char nameBuffer[MAXPATHLEN];
strcpy (nameBuffer, file.fullName().asChar());
fileName(nameBuffer);
#else
fileName = file.fullName();
#endif
MGlobal::displayInfo("Options " + options);
return this->importObjects();
}
示例9: reader
//This routine is called by Maya when it is necessary to load a file of a type supported by this translator.
//Responsible for reading the contents of the given file, and creating Maya objects via API or MEL calls to reflect the data in the file.
MStatus NifTranslator::reader(const MFileObject& file, const MString& optionsString, MPxFileTranslator::FileAccessMode mode)
{
NifTranslatorDataRef translator_data(new NifTranslatorData());
NifTranslatorOptionsRef translator_options(new NifTranslatorOptions());
NifTranslatorUtilsRef translator_utils(new NifTranslatorUtils(translator_data, translator_options));
NifImportingFixtureRef importer;
ImportType import_type = ImportType::Default;
Header file_header = ReadHeader(file.fullName().asChar());
vector<string> block_types = file_header.getBlockTypes();
vector<unsigned short> block_types_index = file_header.getBlockTypeIndex();
translator_options->ParseOptionsString(optionsString);
if (block_types[block_types_index[0]] == NiControllerSequence::TYPE.GetTypeName())
{
import_type = ImportType::AnimationKF;
}
else if (file_header.getUserVersion() == 12 && file_header.getUserVersion2() == 83)
{
import_type = ImportType::SkyrimFallout;
} else if (file_header.getUserVersion() == 12 && file_header.getUserVersion2() == 130)
{
import_type = ImportType::Fallout4;
}
else
{
for (int i = 0; i < block_types.size(); i++)
{
if (block_types[i] == BSDismemberSkinInstance::TYPE.GetTypeName() || block_types[i] == BSShaderTextureSet::TYPE.GetTypeName())
{
import_type = ImportType::SkyrimFallout;
}
}
}
if (import_type == ImportType::AnimationKF)
{
importer = new NifKFImportingFixture(translator_options, translator_data, translator_utils);
}
else if (import_type == ImportType::SkyrimFallout)
{
importer = new NifImportingFixtureSkyrim(translator_options, translator_data, translator_utils);
} else if (import_type == ImportType::Fallout4)
{
importer = new NifImportingFixtureFallout4(translator_options, translator_data, translator_utils);
}
else if (import_type == ImportType::Default)
{
importer = new NifDefaultImportingFixture(translator_data, translator_options, translator_utils);
}
return importer->ReadNodes(file);
}
示例10: writer
MStatus writer (const MFileObject& dest_path, const MString& options, FileAccessMode mode) try
{
std::ofstream file (dest_path.fullName ().asChar ());
if (!file)
throw std::runtime_error ("Error opening output file");
}
catch (std::exception& e)
{
MGlobal::displayError (e.what ());
return MS::kFailure;
}
示例11: if
MStatus eae6320::cMayaMeshExporter::writer( const MFileObject& i_file, const MString& i_options, FileAccessMode i_mode )
{
MStatus status;
// Gather the vertex and index buffer information
std::map<std::string, sVertex_maya> uniqueVertices;
std::vector<sTriangle> triangles;
std::vector<MObject> shadingGroups;
{
// The user decides whether to export the entire scene or just a selection
if ( i_mode == MPxFileTranslator::kExportAccessMode )
{
status = ProcessAllMeshes( uniqueVertices, triangles, shadingGroups );
if ( !status )
{
return status;
}
}
else if ( i_mode == MPxFileTranslator::kExportActiveAccessMode )
{
status = ProcessSelectedMeshes( uniqueVertices, triangles, shadingGroups );
if ( !status )
{
return status;
}
}
else
{
MGlobal::displayError( "Unexpected file access mode" );
return MStatus::kFailure;
}
}
// Convert the mesh information to vertex and index buffers
std::vector<sVertex_maya> vertexBuffer;
std::vector<size_t> indexBuffer;
std::vector<sMaterialInfo> materialInfo;
{
status = FillVertexAndIndexBuffer( uniqueVertices, shadingGroups, triangles, vertexBuffer, indexBuffer, materialInfo );
if ( !status )
{
return status;
}
}
// Write the mesh to the requested file
{
const MString filePath = i_file.fullName();
return WriteMeshToFile( filePath, vertexBuffer, indexBuffer, materialInfo );
}
}
示例12: writer
MStatus BinMeshTranslator::writer(const MFileObject& file,
const MString& opts,
MPxFileTranslator::FileAccessMode mode)
//Summary: saves a file of a type supported by this translator by traversing
// the all or selected objects (depending on mode) in the current
// Maya scene, and writing a representation to the given file
//Args : file - object containing the pathname of the file to be written to
// options - a string representation of any file options
// mode - the method used to write the file - export, or export active
// are valid values; method will fail for any other values
//Returns: MStatus::kSuccess if the export was successful;
// MStatus::kFailure otherwise
{
options = opts;
#if defined (OSMac_)
char nameBuffer[MAXPATHLEN];
strcpy (nameBuffer, file.fullName().asChar());
fileName(nameBuffer);
#else
fileName = file.fullName();
#endif
if (MPxFileTranslator::kExportAccessMode == mode)
{
MGlobal::displayInfo("writer - export all.");
return exportObjects("all");
}
if (MPxFileTranslator::kExportActiveAccessMode == mode)
{
MGlobal::displayInfo("writer - export selected.");
return exportObjects("selected");
}
return MS::kSuccess;
}
示例13: writer
MStatus AnmExporter::writer(const MFileObject& file,
const MString& /*options*/,
MPxFileTranslator::FileAccessMode mode)
{
if (MPxFileTranslator::kExportAccessMode != mode)
{
MGlobal::displayInfo("AnmExporter: only support \"export all\" \n(will export from start to end time)");
return MStatus::kFailure;
}
#if defined (OSMac_)
FAILURE("Sorry guys, I hate Apple.");
/*
char name_buffer[MAXPATHLEN];
strcpy(name_buffer, file.fullName().asChar());
const MString file_name(nameBuffer);
*/
#else
const MString file_name = file.fullName();
#endif
ofstream fout(file_name.asChar(), ios::binary);
if (!fout)
FAILURE("AnmExporter: " + file_name + " : could not be opened for reading");
AnmWriter *writer = new AnmWriter();
if (MStatus::kFailure == writer->dumpData())
{
delete writer;
FAILURE("AnmExporter: writer->dumpData(): failed");
}
if (MStatus::kFailure == writer->write(fout))
{
delete writer;
FAILURE("AnmExporter: writer->write(" + file_name + "); failed");
}
fout.flush();
fout.close();
delete writer;
MGlobal::displayInfo("AnmExporter: export successful!");
return MS::kSuccess;
}
示例14: get_filenames
/*
* Helper method for obtaining the two filenames.
*/
void get_filenames(const MFileObject& file, MString & topology_filename, MString & configuration_filename, MString & vhelix_filename) {
const MString filename(file.fullName());
int extension = filename.rindexW("." HELIX_OXDNA_CONF_FILE_TYPE);
if (extension != int(filename.length()) - int(strlen(HELIX_OXDNA_CONF_FILE_TYPE)) - 1) {
extension = filename.rindexW("." HELIX_OXDNA_TOP_FILE_TYPE);
if (extension != int(filename.length()) - int(strlen(HELIX_OXDNA_TOP_FILE_TYPE)) - 1)
extension = -1;
}
const MString stripped_filename(filename.asChar(), extension != -1 ? extension : filename.length());
configuration_filename = stripped_filename + "." HELIX_OXDNA_CONF_FILE_TYPE;
topology_filename = stripped_filename + "." HELIX_OXDNA_TOP_FILE_TYPE;
vhelix_filename = stripped_filename + "." HELIX_OXDNA_VHELIX_FILE_TYPE;
}
示例15: writer
MStatus DCTranslator::writer(
const MFileObject &file,
const MString &,
MPxFileTranslator::FileAccessMode mode)
{
MString fileName = file.fullName();
m_ExportPath = file.path();
MString pathInfo = "Export Model Path: ";
MGlobal::displayInfo(pathInfo + m_ExportPath);
MGlobal::displayInfo("Exporting Mesh...\n");
m_MeshFilePtr = GetIODevice<File>();
//m_PhysxAssetFilePtr = GetIODevice<File>();
if (m_MeshFilePtr->Open(fileName.asChar(), IOWrite)) {
//m_PhysxAssetFilePtr->Open((fileName+".pxasset").asChar(), IOWrite);
m_MeshArch = new Archive;
m_MeshArch->SetIODevice(m_MeshFilePtr);
////// write the header ///////
MeshHeader header;
header.Version = VERSION_1_1;
//////
(*m_MeshArch) << header;
if ((mode == MPxFileTranslator::kExportAccessMode) ||
(mode == MPxFileTranslator::kSaveAccessMode))
{
exportAll();
}
else if (mode == MPxFileTranslator::kExportActiveAccessMode)
{
exportSelected();
}
char EndCode[64] = "End";
m_MeshFilePtr->Write(EndCode, 64);
m_MeshFilePtr->Close();
delete m_MeshFilePtr;
m_MeshFilePtr = 0;
return MS::kSuccess;
}
else {
return MStatus::kFailure;
}
}