Collada骨架与控制器关系
Collada skeleton and controller relation
我正在为 android OpenGL ES2 开发一个 collada 加载器,场景有很多我可以加载的网格和灯光,现在我正在处理骨骼和动画,我可以从 visual_scene 节点并将它们存储在骨架列表 class 中,该列表具有一个 Id 和一个联合列表,我从 library_controllers 解析控制器,我可以 link 使用网格抛出 rhe url 的 instance_controller 的视觉场景节点,现在我想 link 带有骨架的控制器例如:
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>
我的问题是,如果有许多具有不同骨架和控制器的网格物体,我可以 link 控制器和来自 Id 字符串的骨架
试试 AssimpLib,它很好地支持 Collada 的骨骼动画,它完成了所有艰巨的工作
我正在为 android OpenGL ES2 开发一个 collada 加载器,场景有很多我可以加载的网格和灯光,现在我正在处理骨骼和动画,我可以从 visual_scene 节点并将它们存储在骨架列表 class 中,该列表具有一个 Id 和一个联合列表,我从 library_controllers 解析控制器,我可以 link 使用网格抛出 rhe url 的 instance_controller 的视觉场景节点,现在我想 link 带有骨架的控制器例如: 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>
我的问题是,如果有许多具有不同骨架和控制器的网格物体,我可以 link 控制器和来自 Id 字符串的骨架
试试 AssimpLib,它很好地支持 Collada 的骨骼动画,它完成了所有艰巨的工作