Morph animation support for collada
This commit is contained in:
@@ -585,6 +585,12 @@ void ColladaParser::ReadAnimationSampler( Collada::AnimationChannel& pChannel)
|
||||
pChannel.mSourceTimes = source;
|
||||
else if( strcmp( semantic, "OUTPUT") == 0)
|
||||
pChannel.mSourceValues = source;
|
||||
else if( strcmp( semantic, "IN_TANGENT") == 0)
|
||||
pChannel.mInTanValues = source;
|
||||
else if( strcmp( semantic, "OUT_TANGENT") == 0)
|
||||
pChannel.mOutTanValues = source;
|
||||
else if( strcmp( semantic, "INTERPOLATION") == 0)
|
||||
pChannel.mInterpolationValues = source;
|
||||
|
||||
if( !mReader->isEmptyElement())
|
||||
SkipElement();
|
||||
@@ -647,6 +653,9 @@ void ColladaParser::ReadControllerLibrary()
|
||||
// Reads a controller into the given mesh structure
|
||||
void ColladaParser::ReadController( Collada::Controller& pController)
|
||||
{
|
||||
// initial values
|
||||
pController.mType = Skin;
|
||||
pController.mMethod = Normalized;
|
||||
while( mReader->read())
|
||||
{
|
||||
if( mReader->getNodeType() == irr::io::EXN_ELEMENT)
|
||||
@@ -654,8 +663,15 @@ void ColladaParser::ReadController( Collada::Controller& pController)
|
||||
// two types of controllers: "skin" and "morph". Only the first one is relevant, we skip the other
|
||||
if( IsElement( "morph"))
|
||||
{
|
||||
// should skip everything inside, so there's no danger of catching elements in between
|
||||
SkipElement();
|
||||
pController.mType = Morph;
|
||||
int baseIndex = GetAttribute("source");
|
||||
pController.mMeshId = mReader->getAttributeValue(baseIndex) + 1;
|
||||
int methodIndex = GetAttribute("method");
|
||||
if (methodIndex > 0) {
|
||||
const char *method = mReader->getAttributeValue(methodIndex);
|
||||
if (strcmp(method, "RELATIVE") == 0)
|
||||
pController.mMethod = Relative;
|
||||
}
|
||||
}
|
||||
else if( IsElement( "skin"))
|
||||
{
|
||||
@@ -693,6 +709,32 @@ void ColladaParser::ReadController( Collada::Controller& pController)
|
||||
{
|
||||
ReadControllerWeights( pController);
|
||||
}
|
||||
else if ( IsElement( "targets" ))
|
||||
{
|
||||
while (mReader->read()) {
|
||||
if( mReader->getNodeType() == irr::io::EXN_ELEMENT) {
|
||||
if ( IsElement( "input")) {
|
||||
int semanticsIndex = GetAttribute("semantic");
|
||||
int sourceIndex = GetAttribute("source");
|
||||
|
||||
const char *semantics = mReader->getAttributeValue(semanticsIndex);
|
||||
const char *source = mReader->getAttributeValue(sourceIndex);
|
||||
if (strcmp(semantics, "MORPH_TARGET") == 0) {
|
||||
pController.mMorphTarget = source + 1;
|
||||
}
|
||||
else if (strcmp(semantics, "MORPH_WEIGHT") == 0)
|
||||
{
|
||||
pController.mMorphWeight = source + 1;
|
||||
}
|
||||
}
|
||||
} else if( mReader->getNodeType() == irr::io::EXN_ELEMENT_END) {
|
||||
if( strcmp( mReader->getNodeName(), "targets") == 0)
|
||||
break;
|
||||
else
|
||||
ThrowException( "Expected end of <targets> element.");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// ignore the rest
|
||||
@@ -703,7 +745,7 @@ void ColladaParser::ReadController( Collada::Controller& pController)
|
||||
{
|
||||
if( strcmp( mReader->getNodeName(), "controller") == 0)
|
||||
break;
|
||||
else if( strcmp( mReader->getNodeName(), "skin") != 0)
|
||||
else if( strcmp( mReader->getNodeName(), "skin") != 0 && strcmp( mReader->getNodeName(), "morph") != 0)
|
||||
ThrowException( "Expected end of <controller> element.");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user