#ifndef ABCIMPORT_CREATE_SCENE_H_
#define ABCIMPORT_CREATE_SCENE_H_
#include <maya/cxx17_enter_legacy_scope.hpp>
#include <Alembic/AbcGeom/ICamera.h>
#include <Alembic/AbcGeom/ICurves.h>
#include <Alembic/AbcGeom/IPoints.h>
#include <Alembic/AbcGeom/IPolyMesh.h>
#include <Alembic/AbcGeom/ISubD.h>
#include <Alembic/AbcGeom/IXform.h>
#include <maya/cxx17_exit_legacy_scope.hpp>
#include "NodeIteratorVisitorHelper.h"
#include <maya/MObject.h>
#include <maya/MString.h>
#include <maya/MDagPath.h>
#include <maya/MDataHandle.h>
#include <maya/MSelectionList.h>
#include <maya/MFnMesh.h>
#include <set>
#include <map>
#include <vector>
struct ltMObj
{
{
return (&s1) < (&s2);
}
};
class AlembicObject;
typedef Alembic::Util::shared_ptr<AlembicObject> AlembicObjectPtr;
class AlembicObject
{
public:
AlembicObject(const Alembic::Abc::IObject& iObject) : mObject( iObject ) {}
const Alembic::Abc::IObject& object() const { return mObject; }
Alembic::Abc::IObject& object() { return mObject; }
void addChild(AlembicObjectPtr iChild) { mChildren.push_back(iChild); }
size_t getNumChildren() { return mChildren.size(); }
AlembicObjectPtr getChild(size_t index){ return mChildren[index]; }
private:
Alembic::Abc::IObject mObject;
std::vector<AlembicObjectPtr> mChildren;
};
class CreateSceneVisitor
{
public:
enum Action
{
NONE = 0,
CONNECT = 1,
CREATE = 2,
REMOVE = 3,
CREATE_REMOVE = 4
};
CreateSceneVisitor(double iFrame = 0,
bool iUnmarkedFaceVaryingColors = false,
~CreateSceneVisitor();
AlembicObjectPtr previsit(AlembicObjectPtr iParentObj);
MStatus walk(Alembic::Abc::IArchive & iRoot);
void visit(AlembicObjectPtr iAlembicObj);
MStatus operator()(Alembic::AbcGeom::ICamera & iNode);
MStatus operator()(Alembic::AbcGeom::ICurves & iNode);
MStatus operator()(Alembic::AbcGeom::INuPatch & iNode);
MStatus operator()(Alembic::AbcGeom::IPoints & iNode);
MStatus operator()(Alembic::AbcGeom::IPolyMesh & iNode);
MStatus operator()(Alembic::AbcGeom::ISubD & iNode);
MStatus operator()(Alembic::AbcGeom::IXform & iNode,
AlembicObjectPtr iNodeObject);
MStatus createEmptyObject(AlembicObjectPtr iNodeObject);
bool hasSampledData();
void getData(WriterData & oData);
void applyShaderSelection();
void addFaceSetsAfterConnection();
private:
void checkShaderSelection(
MFnMesh & iMesh,
unsigned int iInst);
void addToPropList(std::size_t iFirst,
MObject & iParent);
std::string searchRootNames(const std::string & iName);
double mFrame;
std::set<std::string> mRootNodes;
bool mAnyRoots;
bool mUnmarkedFaceVaryingColors;
Action mAction;
WriterData mData;
std::map < MObject, MSelectionList, ltMObj > mShaderMeshMap;
std::map < MObject, Alembic::Abc::IObject, ltMObj > mAddFaceSetsMap;
};
#endif // ABCIMPORT_CREATE_SCENE_H_