Skip to content
Snippets Groups Projects
Commit a8b30de9 authored by Shon Ferguson's avatar Shon Ferguson
Browse files

Removed code to re-position NiTriBasedGeom nodes as part of...

Removed code to re-position NiTriBasedGeom nodes as part of GoToSkeletonBindPosition since correct vertex positions can now be retrieved without doing this.
parent 3408f2ce
No related branches found
No related tags found
No related merge requests found
......@@ -208,74 +208,4 @@ void NiNode::GoToSkeletonBindPosition() {
}
}
}
//Search for any NiTriBasedGeom classes lower in the scene graph and
//reposition them
RepositionGeom(this);
}
void NiNode::RepositionGeom( NiAVObjectRef root ) {
//Check if this is a NiTriBasedGeom
NiTriBasedGeomRef geom = DynamicCast<NiTriBasedGeom>(root);
if ( geom != NULL ) {
//This is a NiTriBasedGeom class
//Get NiSkinInstance and NiSkinData
NiSkinInstanceRef skin_inst = geom->GetSkinInstance();
if ( skin_inst == NULL ) {
return;
}
NiSkinDataRef skin_data = skin_inst->GetSkinData();
if ( skin_data == NULL ) {
return;
}
//Get bone nodes
vector<NiNodeRef> bone_nodes = skin_inst->GetBones();
//Make sure the counts match
if ( bone_nodes.size() != skin_data->GetBoneCount() ) {
throw runtime_error( "Bone counts in NiSkinInstance and attached NiSkinData must match" );
}
//There must be at least one bone to do anything
if ( bone_nodes.size() == 0 ) {
return;
}
//Use first bone (arbitrary choice)
Matrix44 offset_mat = skin_data->GetBoneTransform(0);
//Get built up rotations to the root of the skeleton from this bone
Matrix44 bone_mat = bone_nodes[0]->GetWorldTransform();
Matrix44 world_mat = offset_mat * bone_mat;
Matrix44 result_mat = world_mat * geom->GetParent()->GetWorldTransform().Inverse();
//--Set TriShape Local Position to Result--//
geom->SetLocalRotation( result_mat.GetRotation() );
geom->SetLocalTranslation( result_mat.GetTranslation() );
geom->SetLocalScale( 1.0f );
//TODO: Calculate the correct adjustment for the NiSkinData overall matrix
//due to this change
return;
}
//Check if this is a NiNode
NiNodeRef node = DynamicCast<NiNode>(root);
if ( node != NULL ) {
//This is a NiNode, call this function on all children
vector<NiAVObjectRef> children = node->GetChildren();
for ( uint i = 0; i < children.size(); ++i ) {
RepositionGeom( children[i] );
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment