#include "MayaLocatorWriter.h"
#include "MayaUtility.h"
MayaLocatorWriter::MayaLocatorWriter(
MDagPath & iDag,
Alembic::Abc::OObject & iParent,
Alembic::Util::uint32_t iTimeIndex,
const JobArgs & iArgs) :
mIsAnimated(false), mDagPath(iDag)
{
if ( !status )
{
"Failed to initialize MFnDagNode object for locator" );
}
name = util::stripNamespaces(name, iArgs.stripNamespace);
mXform = Alembic::AbcGeom::OXform(iParent, name.
asChar(), iTimeIndex);
Alembic::Abc::OCompoundProperty cp = mXform.getProperties();
Alembic::AbcCoreAbstract::DataType dType(Alembic::Util::kFloat64POD, 6);
if ( iTimeIndex != 0 && (util::getSampledType(posX) != 0 ||
util::getSampledType(posY) != 0 ||
util::getSampledType(posZ) != 0 ||
util::getSampledType(pos) != 0 ||
util::getSampledType(scaleX) != 0 ||
util::getSampledType(scaleY) != 0 ||
util::getSampledType(scaleZ) != 0 ||
util::getSampledType(scale) != 0) )
{
mIsAnimated = true;
mSp = Alembic::Abc::OScalarProperty(cp,
"locator", dType, iTimeIndex);
}
else
{
mSp = Alembic::Abc::OScalarProperty(cp,
"locator", dType);
}
double val[6];
if (!mIsAnimated || iArgs.setFirstAnimShape)
{
mSp.set(val);
}
Alembic::Abc::OCompoundProperty arbGeom;
Alembic::Abc::OCompoundProperty userProps;
if (AttributesWriter::hasAnyAttr(fnLocator, iArgs))
{
arbGeom = mXform.getSchema().getArbGeomParams();
userProps = mXform.getSchema().getUserProperties();
}
mAttrs = AttributesWriterPtr(new AttributesWriter(arbGeom, userProps,
mXform, fnLocator,
iTimeIndex, iArgs, true));
}
MayaLocatorWriter::~MayaLocatorWriter()
{
mSp.reset();
}
void MayaLocatorWriter::write()
{
if ( !status )
{
"Failed to initialize MFnDagNode object for locator" );
}
double val[6];
val[0] = fnLocator.findPlug("localPositionX", true).asDouble();
val[1] = fnLocator.findPlug("localPositionY", true).asDouble();
val[2] = fnLocator.findPlug("localPositionZ", true).asDouble();
val[3] = fnLocator.findPlug("localScaleX", true).asDouble();
val[4] = fnLocator.findPlug("localScaleY", true).asDouble();
val[5] = fnLocator.findPlug("localScaleZ", true).asDouble();
mSp.set(val);
}
bool MayaLocatorWriter::isAnimated() const
{
return mIsAnimated;
}