If you want use a custom skeleton format you can extend atoms with a new skeleton loader. To add a new skeleton format you must create a new class definition extending the Atoms::BaseSkeletonLoader. Then you must register the new loader class from inside an atoms plugin.
Class definition
#include <Atoms/Globals.h> #include <AtomsCore/Metadata/MapMetadata.h> #include <Atoms/Loaders/BaseSkeletonLoader.h> #define kFooSkeletonLoaderId 101 namespace Atoms { class ATOMSPLUGIN_EXPORT FooSkeletonLoader : public BaseSkeletonLoader { public: //! Type string /*! \return Class type string */ std::string typeStr() const; //! Class static type string. This is also the file extension of your file format static std::string const staticTypeStr; //! Type id /*! \return Class type id */ unsigned int typeId() const; //! Class static type id static const unsigned int staticTypeId; //! Constructor FooMeshLoader(); //! Destructor ~FooMeshLoader(); //! Creator function /*! \return Return a new AlembicMeshLoader object */ static AtomsPtr<BaseMeshLoader> creator(); //! load /*! Load an atoms file */ AtomsPtr<AtomsCore::MapMetadata> load(const std::string &filePath, const std::string& filter = "*"); }; } namespace Atoms { std::string const FooSkeletonLoader::staticTypeStr = "foo"; // the file extension std::string FooSkeletonLoader::typeStr() const { return FooSkeletonLoader::staticTypeStr; } const unsigned int FooSkeletonLoader::staticTypeId = kFooSkeletonLoaderId ; unsigned int FooSkeletonLoader::typeId() const { return FooSkeletonLoader::staticTypeId; } FooSkeletonLoader::FooSkeletonLoader() : BaseMeshLoader() { } FooMeshLoader::~FooMeshLoader() { } AtomsPtr<BaseMeshLoader> FooSkeletonLoader::creator() { return std::dynamic_pointer_cast<BaseSkeletonLoader>(std::make_shared<FooSkeletonLoader>()); } AtomsCore::Skeleton FooSkeletonLoader::load(const std::string &filePath) { // This is the actual loader that atoms use to load the atomsskel // Change it to support your custom format // If the skeleton is not valid, always return a valid skeleton like in this example AtomsCore::Skeleton skel(1); AtomsCore::Archive skinGeoArc; if (!skinGeoArc.readFromFile(filePath)) { AtomsUtils::Logger::warning() << "Could not read " << filePath; AtomsUtils::Logger::warning() << "Creating default skeleton"; skel.addPelvis(0); skel.setRoot(0); skel.joint(0).setName("root"); skel.buildIkData(); skel.buildDetachedJointsList(); skel.buildJointNameMap(); return skel; } skinGeoArc >> skel; return std::move(skel); } }
Atoms calls the load function to read the new skeleton format. This function must fill and return a Skeleton object.
Register the new loader to atoms
extern "C" { ATOMSPLUGIN_EXPORT bool initializePlugin() { SkeletonLoaderFactory& factory = SkeletonLoaderFactory::instance(); factory.registerSkeletonLoader(FooSkeletonLoader::staticTypeStr, &FooSkeletonLoader::creator); } }
Compile the behaviour module
Since the loader is used also by the procedurals you must compile your new plugin 2 times. The first time link to the Atoms.so/lib library. The second time link to the AtomsProcedural.so/lib library.
Windows:
In visual studio create a dll projects, add the atoms, tbb and openexr includes and add
BUILD_ATOMSPLUGIN,WIN,_CRT_SECURE_NO_WARNINGS,_CRT_NONSTDC_NO_DEPRECATE,FBXSDK_SHARED
to the preprocessor definitions.
Then create another target and link AtomsProcedural instead to link Atoms.
Linux:
Compile as a shared object adding the atoms, tbb and opendexr includes and BUILD_ATOMSPLUGIN to the preprocessor definitions.
Then create another target and link AtomsProcedural instead to link Atoms.
Use the plugin
Add to the ATOMS_PLUGINS_PATH environment variable, the folder where the library compiles against Atoms is located, while add to the ATOMS_PROCEDURAL_PLUGINS_PATH env variable the path where the library compiled against AtomsProcedural is located