示例#1
0
        private static void WriteBonesFileOBJ(string filename, ModelBase.BoneDefRoot boneTree)
        {
            // Write information about each bone, whether it's a parent or child to file
            // This is specific to this editor and will need re-added when re-importing if model modified

            StreamWriter bonesWriter = new StreamWriter(filename);

            foreach (ModelBase.BoneDef bone in boneTree)
            {
                bonesWriter.Write("newbone " + bone.m_ID + "\n");
                // Offset in bones to parent bone (signed 16-bit. 0=no parent, -1=parent is the previous bone, ...)
                bonesWriter.Write("parent_offset " + boneTree.GetParentOffset(bone) + "\n");
                // 1 if the bone has children, 0 otherwise
                bonesWriter.Write("has_children " + ((bone.m_HasChildren) ? "1" : "0") + "\n");
                // Offset in bones to the next sibling bone (0=bone is last child of its parent)
                bonesWriter.Write("sibling_offset " + boneTree.GetNextSiblingOffset(bone) + "\n");
                // Scale component
                bonesWriter.Write("scale " + bone.m_20_12Scale[0].ToString("X8") + " " + bone.m_20_12Scale[1].ToString("X8") + " " +
                    bone.m_20_12Scale[2].ToString("X8") + "\n");
                // Rotation component
                bonesWriter.Write("rotation " + bone.m_4_12Rotation[0].ToString("X4") + " " + bone.m_4_12Rotation[1].ToString("X4") + " " +
                    bone.m_4_12Rotation[2].ToString("X4") + "\n");
                // Translation component
                bonesWriter.Write("translation " + bone.m_20_12Translation[0].ToString("X8") + " " + bone.m_20_12Translation[0].ToString("X8") +
                    " " + bone.m_20_12Translation[2].ToString("X8") + "\n\n");
            }

            bonesWriter.Close();
        }