importexport/FBXExtension/IOPlugin/MyOwnIOPlugin.cxx

importexport/FBXExtension/IOPlugin/MyOwnIOPlugin.cxx
/***************************************************************************************
Autodesk(R) Open Reality(R) Samples
(C) 2009 Autodesk, Inc. and/or its licensors
All rights reserved.
AUTODESK SOFTWARE LICENSE AGREEMENT
Autodesk, Inc. licenses this Software to you only upon the condition that
you accept all of the terms contained in the Software License Agreement ("Agreement")
that is embedded in or that is delivered with this Software. By selecting
the "I ACCEPT" button at the end of the Agreement or by copying, installing,
uploading, accessing or using all or any portion of the Software you agree
to enter into the Agreement. A contract is then formed between Autodesk and
either you personally, if you acquire the Software for yourself, or the company
or other legal entity for which you are acquiring the software.
AUTODESK, INC., MAKES NO WARRANTY, EITHER EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
PURPOSE REGARDING THESE MATERIALS, AND MAKES SUCH MATERIALS AVAILABLE SOLELY ON AN
"AS-IS" BASIS.
IN NO EVENT SHALL AUTODESK, INC., BE LIABLE TO ANYONE FOR SPECIAL, COLLATERAL,
INCIDENTAL, OR CONSEQUENTIAL DAMAGES IN CONNECTION WITH OR ARISING OUT OF PURCHASE
OR USE OF THESE MATERIALS. THE SOLE AND EXCLUSIVE LIABILITY TO AUTODESK, INC.,
REGARDLESS OF THE FORM OF ACTION, SHALL NOT EXCEED THE PURCHASE PRICE OF THE
MATERIALS DESCRIBED HEREIN.
Autodesk, Inc., reserves the right to revise and improve its products as it sees fit.
Autodesk and Open Reality are registered trademarks or trademarks of Autodesk, Inc.,
in the U.S.A. and/or other countries. All other brand names, product names, or
trademarks belong to their respective holders.
GOVERNMENT USE
Use, duplication, or disclosure by the U.S. Government is subject to restrictions as
set forth in FAR 12.212 (Commercial Computer Software-Restricted Rights) and
DFAR 227.7202 (Rights in Technical Data and Computer Software), as applicable.
Manufacturer is Autodesk, Inc., 10 Duke Street, Montreal, Quebec, Canada, H3C 2L7.
***************************************************************************************/
#include "MyOwnReader.h"
#include "MyOwnWriter.h"
#define PLUGIN_NAME "My_Own_Writer_Reader"
#define PLUGIN_VERSION "1.0"
#define PLUGIN_EXTENSION "ABC"
FbxWriter* CreateMyOwnWriter(FbxManager& pManager, FbxExporter& pExporter, int /*pSubID*/, int pPluginID)
{
// Create your own writer.
// And your writer will get a pPluginID and pSubID.
FbxWriter* lWriter = FbxNew< MyOwnWriter >(pManager, pPluginID);
lWriter->SetIOSettings(pExporter.GetIOSettings());
return lWriter;
}
void* GetMyOwnWriterInfo(FbxWriter::EInfoRequest pRequest, int pId)
{
// Get extension, description or version info about MyOwnWriter
if(pId!=0)
return NULL;
static char const* sExt[] = {PLUGIN_EXTENSION, 0};
static char const* sDesc[] = {PLUGIN_NAME" Writer", 0};
switch( pRequest )
{
case FbxWriter::eInfoExtension: return sExt;
case FbxWriter::eInfoDescriptions: return sDesc;
case FbxWriter::eInfoVersions: return NULL;
default: return NULL;
}
}
void FillOwnWriterIOSettings(FbxIOSettings& pIOS)
{
// Here you can write your own FbxIOSettings and parse them.
FbxProperty FBXExtentionsSDKGroup = pIOS.GetProperty(EXP_FBX_EXT_SDK_GRP);
if( !FBXExtentionsSDKGroup.IsValid() ) return;
FbxProperty IOPluginGroup = pIOS.AddPropertyGroup(FBXExtentionsSDKGroup, PLUGIN_NAME, FbxStringDT, PLUGIN_NAME);
if( IOPluginGroup.IsValid() )
{
//Add your plugin export options here...
//Example:
bool Default_True = true;
pIOS.AddProperty(IOPluginGroup, "Test", FbxBoolDT, "Test", &Default_True);
}
}
FbxReader* CreateMyOwnReader(FbxManager& pManager, FbxImporter& pImporter, int /*pSubID*/, int pPluginID)
{
// Creates a MyOwnReader in the Sdk Manager
FbxReader* lReader = FbxNew< MyOwnReader >(pManager, pPluginID);
lReader->SetIOSettings(pImporter.GetIOSettings());
return lReader;
}
void *GetMyOwnReaderInfo(FbxReader::EInfoRequest pRequest, int pId)
{
// Get extension, description or version info about MyOwnReader
if(pId!=0)
return NULL;
static char const* sExt[] = {PLUGIN_EXTENSION, 0};
static char const* sDesc[] = {PLUGIN_NAME" Reader", 0};
switch( pRequest )
{
case FbxReader::eInfoExtension: return sExt;
case FbxReader::eInfoDescriptions: return sDesc;
default: return NULL;
}
}
void FillOwnReaderIOSettings(FbxIOSettings& pIOS)
{
// Here you can write your own FbxIOSettings and parse them.
FbxProperty FBXExtentionsSDKGroup = pIOS.GetProperty(IMP_FBX_EXT_SDK_GRP);
if( !FBXExtentionsSDKGroup.IsValid() ) return;
FbxProperty IOPluginGroup = pIOS.AddPropertyGroup(FBXExtentionsSDKGroup, PLUGIN_NAME, FbxStringDT, PLUGIN_NAME);
if( IOPluginGroup.IsValid() )
{
//Add your plugin import options here...
//Example:
bool Default_True = true;
pIOS.AddProperty(IOPluginGroup, "Test", FbxBoolDT, "Test", &Default_True);
}
}