summaryrefslogtreecommitdiff
path: root/indra/newview/llfloatermodelpreview.cpp
diff options
context:
space:
mode:
authorprep <prep@lindenlab.com>2010-11-15 14:02:03 -0500
committerprep <prep@lindenlab.com>2010-11-15 14:02:03 -0500
commitf9a35fc4c622cf5b151900dd4590818d965a506b (patch)
treef18754406e1f307f178306f6263ac5911c3f2224 /indra/newview/llfloatermodelpreview.cpp
parent26b3b37e87da0dae46d5e12a9ab4cae809df22de (diff)
Implemented support for getting at the child translational element if the SID fails to resolved.
Diffstat (limited to 'indra/newview/llfloatermodelpreview.cpp')
-rw-r--r--indra/newview/llfloatermodelpreview.cpp85
1 files changed, 52 insertions, 33 deletions
diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp
index 1c73a6cb31..a37469422d 100644
--- a/indra/newview/llfloatermodelpreview.cpp
+++ b/indra/newview/llfloatermodelpreview.cpp
@@ -1424,41 +1424,49 @@ void LLModelLoader::run()
char str[64]={0};
sprintf(str,"./%s",(*jointIt).second.c_str() );
//llwarns<<"Joint "<< str <<llendl;
+
+ //Setup the resolver
+ daeSIDResolver resolver( pSkeletonRootNode, str );
+
+ //Look for the joint
+ domNode* pJoint = daeSafeCast<domNode>( resolver.getElement() );
+ if ( pJoint )
+ {
+ //Pull out the translate id and store it in the jointTranslations map
+ daeSIDResolver jointResolver( pJoint, "./translate" );
+ domTranslate* pTranslate = daeSafeCast<domTranslate>( jointResolver.getElement() );
+
+ LLMatrix4 workingTransform;
+
+ //Translation via SID
+ if ( pTranslate )
+ {
+ domFloat3 jointTrans = pTranslate->getValue();
+ LLVector3 singleJointTranslation( jointTrans[0], jointTrans[1], jointTrans[2] );
+ workingTransform.setTranslation( singleJointTranslation );
+ }
+ else
+ {
+ //Translation via child from element
+ daeElement* pTranslateElement = getChildFromElement( pJoint, "translate" );
+ if ( pTranslateElement && pTranslateElement->typeID() != domTranslate::ID() )
+ {
+ llwarns<< "The found element is not a translate node" <<llendl;
+ missingID = true;
+ }
+ else
+ {
+ domTranslate* pTranslateChild = dynamic_cast<domTranslate*>( pTranslateElement );
+ domFloat3 translateChild = pTranslateChild->getValue();
+ LLVector3 singleJointTranslation( translateChild[0], translateChild[1], translateChild[2] );
+ workingTransform.setTranslation( singleJointTranslation );
+ }
+ }
+ //Store the joint transform w/respect to it's name.
+ jointTransforms[(*jointIt).second.c_str()] = workingTransform;
+ }
- //Setup the resolver
- daeSIDResolver resolver( pSkeletonRootNode, str );
- //Look for the joint
- domNode* pJoint = daeSafeCast<domNode>(resolver.getElement());
- if ( pJoint )
- {
- //Pull out the translate id and store it in the jointTranslations map
- daeSIDResolver jointResolver( pJoint, "./translate" );
- domTranslate* pTranslate = daeSafeCast<domTranslate>( jointResolver.getElement() );
-
- LLMatrix4 workingTransform;
-
- //Translation
- if ( pTranslate )
- {
- domFloat3 jointTrans = pTranslate->getValue();
- LLVector3 singleJointTranslation( jointTrans[0], jointTrans[1], jointTrans[2] );
- workingTransform.setTranslation( singleJointTranslation );
- }
- else
- {
- missingID = true;
- llwarns<< "No translation sid!" << llendl;
- }
- //Store the joint transform w/respect to it's name.
- jointTransforms[(*jointIt).second.c_str()] = workingTransform;
-
- }
- else
- {
- missingID = true;
- llwarns<< "Missing joint." << llendl;
- }
}
//If anything failed in regards to extracting the skeleton, joints or translation id,
@@ -1759,6 +1767,17 @@ void LLModelLoader::run()
mPreview->loadModelCallback(mLod);
}
}
+
+daeElement* LLModelLoader::getChildFromElement( daeElement* pElement, std::string const & name )
+{
+ daeElement* pChildOfElement = pElement->getChild( name.c_str() );
+ if ( pChildOfElement )
+ {
+ return pChildOfElement;
+ }
+ llwarns<< "Could not find a child [" << name << "] for the element: \"" << pElement->getAttribute("id") << "\"" << llendl;
+ return NULL;
+}
void LLModelLoader::processElement(daeElement* element)
{