I need to bother you and the community again ;).
I have the weights and their indices, now i am trying to get the bone information from the scene. Here is the Root Node:
<node id="4">
<attribute name="Is Enabled" value="true" />
<attribute name="Name" value="RootNode" />
<attribute name="Tags" />
<attribute name="Position" value="0 0 -0" />
<attribute name="Rotation" value="1 0 0 0" />
<attribute name="Scale" value="0.01 0.01 0.01" />
<attribute name="Variables" />
<node id="5">
<attribute name="Is Enabled" value="true" />
<attribute name="Name" value="world_offset" />
<attribute name="Tags" />
<attribute name="Position" value="0 0 -0" />
<attribute name="Rotation" value="1 0 0 0" />
<attribute name="Scale" value="1 1 1" />
<attribute name="Variables" />
<node id="6">
<attribute name="Is Enabled" value="true" />
<attribute name="Name" value="base" />
<attribute name="Tags" />
<attribute name="Position" value="0.010468 0.883459 -0.008136" />
<attribute name="Rotation" value="1 0 0 0" />
<attribute name="Scale" value="1 1 1" />
<attribute name="Variables" />
<node id="7">
<attribute name="Is Enabled" value="true" />
<attribute name="Name" value="spine1" />
<attribute name="Tags" />
<attribute name="Position" value="-0.000507 0.179195 0.015135" />
<attribute name="Rotation" value="1 0 0 0" />
<attribute name="Scale" value="1 1 1" />
<attribute name="Variables" />
<node id="8">
<attribute name="Is Enabled" value="true" />
<attribute name="Name" value="spine2" />
<attribute name="Tags" />
<attribute name="Position" value="-6.3e-05 0.144263 0.002484" />
<attribute name="Rotation" value="1 0 0 0" />
<attribute name="Scale" value="1 1 1" />
<attribute name="Variables" />
<node id="9">
<attribute name="Is Enabled" value="true" />
<attribute name="Name" value="spine3" />
<attribute name="Tags" />
<attribute name="Position" value="-0.003294 0.206917 0.022406" />
<attribute name="Rotation" value="1 0 0 0" />
<attribute name="Scale" value="1 1 1" />
<attribute name="Variables" />
<node id="10">
<attribute name="Is Enabled" value="true" />
<attribute name="Name" value="spine4" />
<attribute name="Tags" />
<attribute name="Position" value="-0.010595 0.112027 -0.018882" />
<attribute name="Rotation" value="1 0 0 0" />
<attribute name="Scale" value="1 1 1" />
<attribute name="Variables" />
<node id="11">
<attribute name="Is Enabled" value="true" />
<attribute name="Name" value="spine5" />
<attribute name="Tags" />
<attribute name="Position" value="-0.000212 0.034025 -0.001683" />
<attribute name="Rotation" value="1 0 0 0" />
<attribute name="Scale" value="1 1 1" />
<attribute name="Variables" />
<node id="12">
<attribute name="Is Enabled" value="true" />
<attribute name="Name" value="skullbase" />
<attribute name="Tags" />
<attribute name="Position" value="-0.005587 0.065566 -0.009266" />
<attribute name="Rotation" value="1 0 0 0" />
<attribute name="Scale" value="1 1 1" />
<attribute name="Variables" />
<node id="13">
<attribute name="Is Enabled" value="true" />
<attribute name="Name" value="head" />
<attribute name="Tags" />
<attribute name="Position" value="-0.003432 0.063759 -0.005846" />
<attribute name="Rotation" value="1 0 0 0" />
<attribute name="Scale" value="1 1 1" />
<attribute name="Variables" />
</node>
</node>
</node>
</node>
<node id="14">
<attribute name="Is Enabled" value="true" />
<attribute name="Name" value="r_shoulder" />
<attribute name="Tags" />
<attribute name="Position" value="-0.1955 -0.047464 0.045533" />
<attribute name="Rotation" value="0.998081 0.0525232 -0.0219416 0.0243751" />
<attribute name="Scale" value="1 1 1" />
<attribute name="Variables" />
<node id="15">
<attribute name="Is Enabled" value="true" />
<attribute name="Name" value="r_elbow" />
<attribute name="Tags" />
<attribute name="Position" value="-0.117085 -0.24122 0.035155" />
<attribute name="Rotation" value="0.996067 0.0461258 -0.0196229 0.0730643" />
<attribute name="Scale" value="1 1 1" />
<attribute name="Variables" />
<node id="16">
<attribute name="Is Enabled" value="true" />
<attribute name="Name" value="r_wrist" />
<attribute name="Tags" />
<attribute name="Position" value="-0.173698 -0.228774 0.048215" />
<attribute name="Rotation" value="0.986227 -0.154335 0.0435345 0.0405159" />
<attribute name="Scale" value="1 1 1" />
<attribute name="Variables" />
<node id="17">
<attribute name="Is Enabled" value="true" />
<attribute name="Name" value="r_hand" />
<attribute name="Tags" />
<attribute name="Position" value="-0.019034 -0.021876 -0.048998" />
<attribute name="Rotation" value="1 -0.00034527 0 0" />
<attribute name="Scale" value="1 1 1" />
<attribute name="Variables" />
</node>
</node>
</node>
</node>
<node id="18">
<attribute name="Is Enabled" value="true" />
<attribute name="Name" value="l_shoulder" />
<attribute name="Tags" />
<attribute name="Position" value="0.207959 -0.029926 -0.012704" />
<attribute name="Rotation" value="0.998255 -0.025097 -0.0123939 -0.0519856" />
<attribute name="Scale" value="1 1 1" />
<attribute name="Variables" />
<node id="19">
<attribute name="Is Enabled" value="true" />
<attribute name="Name" value="l_elbow" />
<attribute name="Tags" />
<attribute name="Position" value="0.131096 -0.22705 -0.009158" />
<attribute name="Rotation" value="0.998264 0.0218539 0.0196249 -0.0510582" />
<attribute name="Scale" value="1 1 1" />
<attribute name="Variables" />
<node id="20">
<attribute name="Is Enabled" value="true" />
<attribute name="Name" value="l_wrist" />
<attribute name="Tags" />
<attribute name="Position" value="0.167438 -0.226738 -0.015483" />
<attribute name="Rotation" value="0.998184 0.0328593 0.0485305 -0.0139181" />
<attribute name="Scale" value="1 1 1" />
<attribute name="Variables" />
<node id="21">
<attribute name="Is Enabled" value="true" />
<attribute name="Name" value="l_hand" />
<attribute name="Tags" />
<attribute name="Position" value="0.029413 -0.037956 -0.062907" />
<attribute name="Rotation" value="1 -0.00034527 0 0" />
<attribute name="Scale" value="1 1 1" />
<attribute name="Variables" />
</node>
</node>
</node>
</node>
</node>
</node>
</node>
<node id="22">
<attribute name="Is Enabled" value="true" />
<attribute name="Name" value="r_hip" />
<attribute name="Tags" />
<attribute name="Position" value="-0.094009 0.00271 1e-05" />
<attribute name="Rotation" value="0.999917 -0.0125657 0.00120387 0.00274575" />
<attribute name="Scale" value="1 1 1" />
<attribute name="Variables" />
<node id="23">
<attribute name="Is Enabled" value="true" />
<attribute name="Name" value="r_knee" />
<attribute name="Tags" />
<attribute name="Position" value="-0.026486 -0.404262 0.056034" />
<attribute name="Rotation" value="0.999748 0.0218696 -0.00155574 0.00483476" />
<attribute name="Scale" value="1 1 1" />
<attribute name="Variables" />
<node id="24">
<attribute name="Is Enabled" value="true" />
<attribute name="Name" value="r_ankle" />
<attribute name="Tags" />
<attribute name="Position" value="-0.029707 -0.43241 -0.004766" />
<attribute name="Rotation" value="0.994716 -0.0682225 0.0767137 -0.000671012" />
<attribute name="Scale" value="1 1 1" />
<attribute name="Variables" />
<node id="25">
<attribute name="Is Enabled" value="true" />
<attribute name="Name" value="r_forefoot" />
<attribute name="Tags" />
<attribute name="Position" value="-0.039961 -0.036539 -0.114447" />
<attribute name="Rotation" value="1 0 0 0" />
<attribute name="Scale" value="1 1 1" />
<attribute name="Variables" />
<node id="26">
<attribute name="Is Enabled" value="true" />
<attribute name="Name" value="r_toe" />
<attribute name="Tags" />
<attribute name="Position" value="-0.002013 3.9e-05 -0.059707" />
<attribute name="Rotation" value="1 0 0 0" />
<attribute name="Scale" value="1 1 1" />
<attribute name="Variables" />
</node>
</node>
</node>
</node>
</node>
<node id="27">
<attribute name="Is Enabled" value="true" />
<attribute name="Name" value="l_hip" />
<attribute name="Tags" />
<attribute name="Position" value="0.094852 -0.010535 -0.00648" />
<attribute name="Rotation" value="0.998716 -0.0150379 -0.00910026 -0.0475184" />
<attribute name="Scale" value="1 1 1" />
<attribute name="Variables" />
<node id="28">
<attribute name="Is Enabled" value="true" />
<attribute name="Name" value="l_knee" />
<attribute name="Tags" />
<attribute name="Position" value="0.058439 -0.390751 0.056339" />
<attribute name="Rotation" value="0.99998 -0.00315468 -0.000490237 0.0055404" />
<attribute name="Scale" value="1 1 1" />
<attribute name="Variables" />
<node id="29">
<attribute name="Is Enabled" value="true" />
<attribute name="Name" value="l_ankle" />
<attribute name="Tags" />
<attribute name="Position" value="0.042653 -0.429339 -0.013703" />
<attribute name="Rotation" value="0.992421 -0.0870902 -0.0855505 -0.0140242" />
<attribute name="Scale" value="1 1 1" />
<attribute name="Variables" />
<node id="30">
<attribute name="Is Enabled" value="true" />
<attribute name="Name" value="l_forefoot" />
<attribute name="Tags" />
<attribute name="Position" value="0.050877 -0.031824 -0.121819" />
<attribute name="Rotation" value="1 0 0 0" />
<attribute name="Scale" value="1 1 1" />
<attribute name="Variables" />
<node id="31">
<attribute name="Is Enabled" value="true" />
<attribute name="Name" value="l_toe" />
<attribute name="Tags" />
<attribute name="Position" value="-0.000362 0.001208 -0.06159" />
<attribute name="Rotation" value="1 0 0 0" />
<attribute name="Scale" value="1 1 1" />
<attribute name="Variables" />
</node>
</node>
</node>
</node>
</node>
</node>
</node>
<node id="32">
<attribute name="Is Enabled" value="true" />
<attribute name="Name" value="model" />
<attribute name="Tags" />
<attribute name="Position" value="0 0 -0" />
<attribute name="Rotation" value="1 0 0 0" />
<attribute name="Scale" value="1 1 1" />
<attribute name="Variables" />
<component type="AnimatedModel" id="6">
<attribute name="Model" value="Model;Models/model.mdl" />
<attribute name="Material" value="Material;Materials/noname.xml" />
<attribute name="Animation States">
<variant type="Int" value="0" />
</attribute>
</component>
</node>
So how i can get the joint information of those nodes? I tried
Node *bufNode = scene_a_->GetChild("RootNode")->Clone();
bufNode->GetDerivedComponents<StaticModel>(modelComponents, true);
bufNode->GetComponent<StaticModel>()->GetModel()->GetSkeleton();
But the bones are empty and have no transformation information. My second approach was
Vector<SharedPtr<Node> > bones = bufNode->GetChild("world_offset")->GetChildren(true);
skinningMatrices.resize(bones.Size());
skinningMatrices.push_back(bufNode->GetChild("world_offset")->GetWorldTransform());
for(int i = 0; i < bones.Size(); i++){
Matrix3x4 skinMat = bones[i]->GetWorldTransform();
skinningMatrices.push_back(skinMat);
}
Which leads to weird model morphing.
EDIT 2.0:
Was wrong i just had the world transformation of my parent node in each bone. So the following code was not working.
Vector<Bone> sk = animatedModel->GetModel()->GetSkeleton().GetBones();
for(int i = 0; i < sk.Size(); i++){
if(sk[i].node_)
Matrix3x4 skinMat = sk[i].node_->GetWorldTransform();
Matrix3x4 skinMat = bufNode->GetWorldTransform();
skinningMatrices.push_back(skinMat);
}
The checking if the node exists makes the code runnable but the Skeleton from the AnimatedModel
seems not to refer to the scene nodes.