#include "util.h"
#include "LocatorHelper.h"
#include "NodeIteratorVisitorHelper.h"
#include <maya/MObject.h>
#include <maya/MFnTransform.h>
#include <maya/MString.h>
#include <maya/MVector.h>
#include <maya/MGlobal.h>
#include <maya/MDagModifier.h>
MObject create(Alembic::AbcGeom::IXform & iLocator,
Alembic::Abc::IScalarProperty & iLocProp)
{
MString name(iLocator.getName().c_str());
locatorObj = modifier.createNode("locator", iParent, &status);
status = modifier.doIt();
if (status != MS::kSuccess)
{
MString theError(
"Failed to create locator node ");
theError += name;
printError(theError);
return locatorObj;
}
if (iLocProp.isConstant())
{
double oSample[6];
iLocProp.get(oSample, 0);
dstPlug = fnLocator.
findPlug(
"localPositionX",
true);
dstPlug = fnLocator.
findPlug(
"localPositionY",
true);
dstPlug = fnLocator.
findPlug(
"localPositionZ",
true);
dstPlug = fnLocator.
findPlug(
"localScaleX",
true);
dstPlug = fnLocator.
findPlug(
"localScaleY",
true);
dstPlug = fnLocator.
findPlug(
"localScaleZ",
true);
}
return locatorObj;
}
void read(double iFrame,
Alembic::AbcGeom::IXform & iLocator,
std::vector< double > & oArray)
{
oArray.resize(6);
Alembic::Abc::ICompoundProperty props = iLocator.getProperties();
Alembic::Abc::IScalarProperty locProp(props, "locator");
Alembic::AbcCoreAbstract::index_t index, ceilIndex;
double alpha = getWeightAndIndex(iFrame,
locProp.getTimeSampling(),
locProp.getNumSamples(),
index,
ceilIndex);
double samp[6];
locProp.get(samp, index);
if (fabs(alpha) > 1e-6)
{
double ceilSamp[6];
locProp.get(ceilSamp, ceilIndex);
for (unsigned int i = 0; i < 6; i++)
oArray[i] = simpleLerp< double >(alpha, samp[i], ceilSamp[i]);
}
else
{
for (unsigned int i = 0; i < 6; i++)
oArray[i] = samp[i];
}
}