#ifndef ABCIMPORT_NODE_ITERATOR_HELPER_H_
#define ABCIMPORT_NODE_ITERATOR_HELPER_H_
#include <maya/cxx17_enter_legacy_scope.hpp>
#include <Alembic/Abc/IArrayProperty.h>
#include <Alembic/Abc/IScalarProperty.h>
#include <Alembic/Abc/IObject.h>
#include <Alembic/AbcGeom/ICamera.h>
#include <Alembic/AbcGeom/ICurves.h>
#include <Alembic/AbcGeom/INuPatch.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 <maya/MObject.h>
#include <maya/MPlug.h>
#include <maya/MDataHandle.h>
#include <maya/MArrayDataHandle.h>
#include <maya/MString.h>
#include <maya/MFnNumericAttribute.h>
#include <maya/MFnNumericData.h>
#include <vector>
#include <string>
struct Prop
{
Alembic::Abc::IArrayProperty mArray;
Alembic::Abc::IScalarProperty mScalar;
};
void addProps(Alembic::Abc::ICompoundProperty & iParent,
MObject & iObject,
bool iUnmarkedFaceVaryingColors);
bool addArrayProp(Alembic::Abc::IArrayProperty & iProp,
MObject & iParent);
bool addScalarProp(Alembic::Abc::IScalarProperty & iProp,
MObject & iParent);
enum AddPropResult
{
INVALID = 0,
VALID_DONE = 1,
VALID_NOTDONE = 2
};
template<class PODTYPE>
AddPropResult
addScalarExtentOneProp(Alembic::Abc::IScalarProperty& iProp,
Alembic::Util::uint8_t extent,
PODTYPE defaultVal,
template <class PODTYPE>
AddPropResult
addScalarExtentThreeProp(Alembic::Abc::IScalarProperty& iProp,
Alembic::Util::uint8_t extent,
PODTYPE defaultVal,
template <class PODTYPE>
AddPropResult
addScalarExtentFourProp(Alembic::Abc::IScalarProperty& iProp,
Alembic::Util::uint8_t extent,
PODTYPE defaultVal,
void readProp(double iFrame,
Alembic::Abc::IArrayProperty & iProp,
void readProp(double iFrame,
Alembic::Abc::IScalarProperty & iProp,
void getAnimatedProps(Alembic::Abc::ICompoundProperty & iParent,
std::vector<Prop> & oPropList, bool iUnmarkedFaceVaryingColors);
void getAnimatedArrayProp(Alembic::Abc::IArrayProperty prop,
std::vector<Prop> & oPropList);
void getAnimatedScalarProp(Alembic::Abc::IScalarProperty prop,
std::vector<Prop> & oPropList);
class SampledPair
{
public:
SampledPair(
MObject & iObject, std::vector<std::string> & sN):
mObject(iObject), sampleNameList(sN)
{
}
{
return mObject;
}
unsigned int sampledChannelSize()
{
return static_cast<unsigned int>(sampleNameList.size());
}
std::string getSampleElement(unsigned int index)
{
if (index < sampleNameList.size())
return sampleNameList[index];
else
return std::string();
}
private:
std::vector<std::string> sampleNameList;
};
class PolyMeshAndFriends
{
public:
Alembic::AbcGeom::IPolyMesh mMesh;
std::vector< Alembic::AbcGeom::IV2fGeomParam > mV2s;
std::vector< Alembic::AbcGeom::IC3fGeomParam > mC3s;
std::vector< Alembic::AbcGeom::IC4fGeomParam > mC4s;
};
class SubDAndFriends
{
public:
Alembic::AbcGeom::ISubD mMesh;
std::vector< Alembic::AbcGeom::IV2fGeomParam > mV2s;
std::vector< Alembic::AbcGeom::IC3fGeomParam > mC3s;
std::vector< Alembic::AbcGeom::IC4fGeomParam > mC4s;
};
class WriterData
{
public:
WriterData();
~WriterData();
WriterData(const WriterData & rhs);
WriterData & operator=(const WriterData & rhs);
void getFrameRange(double & oMin, double & oMax);
std::vector<MObject> mCameraObjList;
std::vector<MObject> mLocObjList;
std::vector<MObject> mNurbsObjList;
std::vector<MObject> mNurbsCurveObjList;
std::vector<MObject> mPointsObjList;
std::vector<MObject> mPolyMeshObjList;
std::vector<MObject> mSubDObjList;
std::vector<Prop> mPropList;
std::vector<Alembic::AbcGeom::ICamera> mCameraList;
std::vector<Alembic::AbcGeom::ICurves> mCurvesList;
std::vector<Alembic::AbcGeom::IXform> mLocList;
std::vector<Alembic::AbcGeom::INuPatch> mNurbsList;
std::vector< PolyMeshAndFriends > mPolyMeshList;
std::vector<Alembic::AbcGeom::IPoints> mPointsList;
std::vector< SubDAndFriends > mSubDList;
std::vector<Alembic::AbcGeom::IXform> mXformList;
std::vector<Alembic::AbcGeom::IObject> mAnimVisStaticObjList;
std::vector<std::size_t> mNumCurves;
std::vector<bool> mIsComplexXform;
std::vector<SampledPair> mXformOpList;
std::vector<SampledPair> mPropObjList;
};
class ArgData
{
public:
ArgData(std::vector<std::string>& iFileNames,
bool iDebugOn = false,
bool iConnect = false,
bool iCreateIfNotFound = false,
bool iRemoveIfNoUpdate = false,
bool iRecreateColorSets = false,
ArgData(const ArgData & rhs);
ArgData & operator=(const ArgData & rhs);
std::vector<std::string> mFileNames;
double mSequenceStartTime;
double mSequenceEndTime;
bool mDebugOn;
bool mRecreateColorSets;
bool mConnect;
bool mCreateIfNotFound;
bool mRemoveIfNoUpdate;
WriterData mData;
};
MString createScene(ArgData & iArgData);
MString connectAttr(ArgData & iArgData);
bool getUVandColorAttrs( Alembic::Abc::ICompoundProperty & iParent,
std::vector< Alembic::AbcGeom::IV2fGeomParam > & ioV2s,
std::vector< Alembic::AbcGeom::IC3fGeomParam > & ioC3s,
std::vector< Alembic::AbcGeom::IC4fGeomParam > & ioC4s,
bool iUnmarkedFaceVaryingColors);
#endif // ABCIMPORT_NODE_ITERATOR_HELPER_H_