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;
    }
Exemplo n.º 2
0
// returns the list of files to archive.
MStringArray AlembicNode::getFilesToArchive(
    bool /* shortName */,
    bool unresolvedName,
    bool /* markCouldBeImageSequence */) const
{
    MStringArray files;
    MStatus status = MS::kSuccess;

    MPlug fileNamePlug(thisMObject(), mAbcFileNameAttr);
    MString fileName = fileNamePlug.asString(MDGContext::fsNormal, &status);

    if (status == MS::kSuccess && fileName.length() > 0) {
        if(unresolvedName)
        {
            files.append(fileName);
        }
        else
        {
            //unresolvedName is false, resolve the path via MFileObject.
            MFileObject fileObject;
            fileObject.setRawFullName(fileName);
            files.append(fileObject.resolvedFullName());
        }
    }

    return files;
}
Exemplo n.º 3
0
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;

}
Exemplo n.º 4
0
// returns the list of files to archive.
MStringArray AlembicNode::getFilesToArchive(
    bool /* shortName */,
    bool unresolvedName,
    bool /* markCouldBeImageSequence */) const
{
    MStringArray files;
    MStatus status = MS::kSuccess;

    MPlug layerFilenamesPlug(thisMObject(), mAbcLayerFileNamesAttr);

    MFnStringArrayData fnSAD( layerFilenamesPlug.asMObject() );
	MStringArray layerFilenames = fnSAD.array();

	for( unsigned int i = 0; i < layerFilenames.length(); i++ )
	{
		MString fileName = layerFilenames[i];

		if (status == MS::kSuccess && fileName.length() > 0) {
			if(unresolvedName)
			{
				files.append(fileName);
			}
			else
			{
				//unresolvedName is false, resolve the path via MFileObject.
				MFileObject fileObject;
				fileObject.setRawFullName(fileName);
				files.append(fileObject.resolvedFullName());
			}
		}
	}

    return files;
}
Exemplo n.º 5
0
void    
cgfxGetFxIncludePath( const MString &fxFile, MStringArray &pathOptions )
{
	// Append the path of the cgfx file as a possible include search path
	//
	MString option;
	if (fxFile.length())
	{
		MFileObject fobject;
		fobject.setRawFullName( fxFile );
		option = MString("-I") + fobject.resolvedPath();		
		pathOptions.append( option );
	}

	// Add in "standard" cgfx search for cgfx files as a possible include
	// search path
	//
	char * cgfxRoot = getenv("CGFX_ROOT");
	if (cgfxRoot)
	{
		option = MString("-I") + MString(cgfxRoot);
		pathOptions.append( option );
		option = MString("-I") + MString(cgfxRoot) + MString("/CgFX");
		pathOptions.append( option );
	}

	// Add in Maya's Cg directory
	char * mayaLocation = getenv("MAYA_LOCATION");
	if (mayaLocation)
	{
		MString mayaCgLocation(MString(mayaLocation) + MString("/bin/Cg/"));
		option = MString("-I") + mayaCgLocation;
		pathOptions.append( option );
	}
}
Exemplo n.º 6
0
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;
}
    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;
    }
MStatus  metro_model_translator::reader(const MFileObject &file, const MString &optionsString, FileAccessMode mode)
{
	m2033::file_system fs;
	m2033::model model;
	bool res = MStatus::kFailure;

	fs.set_root_from_fname( file.expandedFullName().asChar() );

	res = model.load( file.expandedFullName().asChar() );
	if( !res ) {
		return MStatus::kFailure;
	}

	return read( model );
}
Exemplo n.º 9
0
//
// 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;
}
Exemplo n.º 10
0
// *****************************************************************************
MPxFileTranslator::MFileKind GtoIO::identifyFile( const MFileObject &file,
                                                  const char *magic,
                                                  short magicSize ) const
{
    if( magicSize < 4 )
    {
        return MPxFileTranslator::kNotMyFileType;
    }

    const unsigned int magicInt = *((unsigned int *)magic );
    if( magicInt == Gto::Header::Magic
        || magicInt == Gto::Header::Cigam )
    {
        return MPxFileTranslator::kIsMyFileType;
    }

    const char gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */
    if( magic[0] == gz_magic[0] && magic[1] == gz_magic[1] )
    {
        if( strstr( file.name().asChar(), ".gto" ) )
        {
            return MPxFileTranslator::kIsMyFileType;
        }
    }

    return MPxFileTranslator::kNotMyFileType;
}
Exemplo n.º 11
0
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;
}
Exemplo n.º 12
0
    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;
    }
Exemplo n.º 13
0
MPxFileTranslator::MFileKind NifTranslator::identifyFile(const MFileObject& fileName, const char* buffer, short size) const
{
	MString fName = fileName.name();
	if (fName.toUpperCase() != "NIF" && fName.toUpperCase() != "KF")
		return kNotMyFileType;

	return kIsMyFileType;
}
Exemplo n.º 14
0
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();
}
Exemplo n.º 15
0
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;
	}
}
Exemplo n.º 16
0
MPxFileTranslator::MFileKind OxDnaTranslator::identifyFile (const MFileObject& file, const char *buffer, short size) const {
    const MString filename(file.resolvedFullName().toLowerCase());

    if (filename.rindexW("." HELIX_OXDNA_CONF_FILE_TYPE) == int(filename.length()) - int(strlen(HELIX_OXDNA_CONF_FILE_TYPE)) - 1 ||
            filename.rindexW("." HELIX_OXDNA_TOP_FILE_TYPE) == int(filename.length()) - int(strlen(HELIX_OXDNA_TOP_FILE_TYPE)) - 1)
        return MPxFileTranslator::kIsMyFileType;
    else
        return MPxFileTranslator::kNotMyFileType;
}
MPxFileTranslator::MFileKind metro_model_translator::identifyFile(const MFileObject &file, const char *buffer, short size) const
{
	MString name = file.name();
	MString ext = name.substring( name.rindex( '.' ), name.length() ).toLowerCase();
	if( ext != MString( ".model" ) )
		return MPxFileTranslator::kNotMyFileType;

	return MPxFileTranslator::kIsMyFileType;
}
Exemplo n.º 18
0
//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);
}
Exemplo n.º 19
0
MPxFileTranslator::MFileKind DCTranslator::identifyFile(
	const MFileObject &fileName, const char *, short) const
{
	const char * name = fileName.name().asChar();
	size_t   nameLength = strlen(name);

	if ((nameLength > 14) && !_stricmp(name + nameLength - 7, MAYA_TRANSLATOR_EXT))
		return kCouldBeMyFileType;
	else
		return kNotMyFileType;
}
    MPxFileTranslator::MFileKind FileTranslator::identifyFile ( 
        const MFileObject &fileObject,
        const char *buffer,
        short size )
    const
    {
        // Just check for the proper extension for now
        MFileKind rval = kNotMyFileType;
        int extLocation = fileObject.name().rindex ( '.' );

        if ( extLocation > 0 )
        {
            MString ext = fileObject.name().substring ( extLocation + 1, fileObject.name().length()-1 ).toLowerCase();
            if ( ext == "dae" || ext == "xml" )
            {
                rval = kIsMyFileType;
            }
        }

        return rval;
    }
Exemplo n.º 21
0
MPxFileTranslator::MFileKind CXRayCameraExport::identifyFile (
                                        const MFileObject& fileName,
                                        const char* buffer,
                                        short size) const
{
    const char * name = fileName.name().asChar();
    int   nameLength = xr_strlen(name);
    
	if ((nameLength > 4) && !stricmp(name+nameLength-4, ".anm"))
        return kCouldBeMyFileType;
    else
        return kNotMyFileType;
}
Exemplo n.º 22
0
    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;
    }
Exemplo n.º 23
0
MPxFileTranslator::MFileKind ObjTranslator::identifyFile (
                                        const MFileObject& fileName,
                                        const char* buffer,
                                        short size) const
{
    const char * name = fileName.name().asChar();
    int   nameLength = strlen(name);
    
    if ((nameLength > 4) && !strcasecmp(name+nameLength-4, ".dae"))
        return kCouldBeMyFileType;
    else
        return kNotMyFileType;
}
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 );
    }
}
Exemplo n.º 25
0
MPxFileTranslator::MFileKind atomExport::identifyFile(
								const MFileObject& fileName,
								const char* buffer,
								short size) const
{
	const char *name = fileName.name().asChar();
	int   nameLength = (int)strlen(name);

	if ((nameLength > 5) && !strcasecmp(name+nameLength-5, ".atom")) {
		return kIsMyFileType;
	}

	return	kNotMyFileType;
}
Exemplo n.º 26
0
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;
}
Exemplo n.º 27
0
MPxFileTranslator::MFileKind 
XFileTranslator::identifyFile(	
	const MFileObject& fileName,
	const char* buffer,
	short size) const
{ 
    LPSTR extension = PathFindExtensionA(fileName.name().asChar());
    if(0==lstrcmpA(extension, ".x"))
	{
		return kIsMyFileType;
	}
	else
	{
		return kNotMyFileType; 
	}
}
Exemplo n.º 28
0
OSGFileTranslator::MFileKind OSGFileTranslator::identifyFile (const MFileObject &file, const char *buffer, short size) const
{
    std::string filename = file.name().asChar();
    if ( filename.substr( filename.size()-4, 4 ).compare(".osg") )
        return kIsMyFileType;
    else if ( filename.substr( filename.size()-4, 4 ).compare(".ive") )
        return kIsMyFileType;
    else if ( filename.substr( filename.size()-5, 5 ).compare(".osgt") )
        return kIsMyFileType;
    else if ( filename.substr( filename.size()-5, 5 ).compare(".osgb") )
        return kIsMyFileType;
    else if ( filename.substr( filename.size()-5, 5 ).compare(".osgx") )
        return kIsMyFileType;

    return kNotMyFileType;       
}
Exemplo n.º 29
0
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;
}
Exemplo n.º 30
0
    void increaseFileRef(const MFileObject& file)
    {
        MString resolvedFullName = file.resolvedFullName();
        std::string key = resolvedFullName.asChar();
        tbb::unique_lock<tbb::mutex> lock(fMutex);

        // look up the file ref count
        FileRefCountIterator fileRefCountIter = fFileRefCount.find(key);
        if (fileRefCountIter != fFileRefCount.end()) {
            // increase the file ref count
            ++(*fileRefCountIter).second;
        }
        else {
            // insert a new entry for file ref count
            fFileRefCount[key] = 1;
        }
    }