Collada骨架和控制器关系

时间:2017-01-25 09:31:29

标签: opengl-es-2.0 collada

我正在开发一个用于Android OpenGL ES2的collada加载器,场景有很多网格和灯光,我可以加载它们,现在我正在研究lodes骨架和动画,我可以从visual_scene节点解析骨架并将它们存储在一个列表中Skeleton类有一个Id和一个Joint列表,我从library_controllers解析控制器,我可以用视觉场景节点的instance_controller的mesh throw rhe url链接,现在我想链接控制器和骨架,例如: visual_scene库中的骨架部分是:

  <node id="Armature_001" name="Armature_001" type="NODE">
    <translate sid="location">0 5 -3.883436</translate>
    <rotate sid="rotationZ">0 0 1 0</rotate>
    <rotate sid="rotationY">0 1 0 0</rotate>
    <rotate sid="rotationX">1 0 0 0</rotate>
    <scale sid="scale">1 1 1</scale>
    <node id="Bone" name="Bone" sid="Bone" type="JOINT">
      <matrix sid="transform">1 0 0 0 0 0 -1 0 0 1 0 0 0 0 0 1</matrix>
      <node id="Bone_001" name="Bone.001" sid="Bone_001" type="JOINT">
        <matrix sid="transform">1 0 0 0 0 1 0 1 0 0 1 0 0 0 0 1</matrix>
      </node>
    </node>
  </node>

来自visual_scene的网格是:

  <node id="Cube" name="Cube" type="NODE">
    <translate sid="location">0 0 0</translate>
    <rotate sid="rotationZ">0 0 1 0</rotate>
    <rotate sid="rotationY">0 1 0 0</rotate>
    <rotate sid="rotationX">1 0 0 0</rotate>
    <scale sid="scale">1 1 1</scale>
    <instance_controller url="#Armature_001_Cube-skin">
      <skeleton>#Bone</skeleton>
      <bind_material>
        <technique_common>
          <instance_material symbol="Material_001-material" target="#Material_001-material"/>
        </technique_common>
      </bind_material>
    </instance_controller>
  </node>

来自library_controllers的控制器是:

<controller id="Armature_Cube_001-skin" name="Armature">
  <skin source="#Cube_001-mesh">
    <bind_shape_matrix>1 0 0 0 0 1 0 -5 0 2.78181e-8 3 -1.39091e-7 0 0 0 1</bind_shape_matrix>
    <source id="Armature_Cube_001-skin-joints">
      <Name_array id="Armature_Cube_001-skin-joints-array" count="2">Bone Bone_002</Name_array>
      <technique_common>
        <accessor source="#Armature_Cube_001-skin-joints-array" count="2" stride="1">
          <param name="JOINT" type="name"/>
        </accessor>
      </technique_common>
    </source>
    <source id="Armature_Cube_001-skin-bind_poses">
      <float_array id="Armature_Cube_001-skin-bind_poses-array" count="32">1 0 0 0 0 0 -1 2.5 0 1 0 5 0 0 0 1 1 0 0 0 0 0 -1 1.5 0 1 0 5 0 0 0 1</float_array>
      <technique_common>
        <accessor source="#Armature_Cube_001-skin-bind_poses-array" count="2" stride="16">
          <param name="TRANSFORM" type="float4x4"/>
        </accessor>
      </technique_common>
    </source>
    <source id="Armature_Cube_001-skin-weights">
      <float_array id="Armature_Cube_001-skin-weights-array" count="20">1 0.9464464 0.05355352 1 0.9444246 0.05557531 1 0.9444246 0.05557531 1 0.9464464 0.05355352 0.02067142 0.9793285 0.02056819 0.9794319 0.02067142 0.9793285 0.02056819 0.9794319</float_array>
      <technique_common>
        <accessor source="#Armature_Cube_001-skin-weights-array" count="20" stride="1">
          <param name="WEIGHT" type="float"/>
        </accessor>
      </technique_common>
    </source>
    <joints>
      <input semantic="JOINT" source="#Armature_Cube_001-skin-joints"/>
      <input semantic="INV_BIND_MATRIX" source="#Armature_Cube_001-skin-bind_poses"/>
    </joints>
    <vertex_weights count="12">
      <input semantic="JOINT" source="#Armature_Cube_001-skin-joints" offset="0"/>
      <input semantic="WEIGHT" source="#Armature_Cube_001-skin-weights" offset="1"/>
      <vcount>1 2 1 2 1 2 1 2 2 2 2 2 </vcount>
      <v>1 0 0 1 1 2 1 3 0 4 1 5 1 6 0 7 1 8 1 9 0 10 1 11 0 12 1 13 0 14 1 15 0 16 1 17 0 18 1 19</v>
    </vertex_weights>
  </skin>
</controller>

我的问题是,如果有许多网格有不同的骨架和控制器,我可以从Id字符串链接控制器和骨架

1 个答案:

答案 0 :(得分:0)

尝试AssimpLib,很好地支持Collada骨骼动画,它做了所有的努力