Exemplo n.º 1
0
        private Collada141.node[] ParseNode(DNode dNode)
        {
            Matrix4 matrix = Matrix4.CreateTranslation(dNode.Position);

            List<Collada141.node> nodes = new List<Collada141.node>();

            if (dNode.NextSibling_NodeIndex != -1) nodes.AddRange(ParseNode(this.Nodes[dNode.NextSibling_NodeIndex]));

            var location = dNode.Position;
            var rotation = Matrix4.Rotate(dNode.Rotation);

            var current_node = new Collada141.node()
            {
                type = Collada141.NodeType.JOINT,
                name = "bone",
                sid = "bone",
                Items = new object[]{
                    new Collada141.TargetableFloat3() { sid = "location", Values = dNode.Position.ToArray() },
                    new Collada141.matrix(){ sid = "rotation", Values = Matrix4ToFloatArray(rotation) },
                    new Collada141.TargetableFloat3() { sid = "scale", Values =new double[] { 1f, 1f, 1f} },
                },
                ItemsElementName = new Collada141.ItemsChoiceType2[]{
                    Collada141.ItemsChoiceType2.translate,
                    Collada141.ItemsChoiceType2.matrix,
                    Collada141.ItemsChoiceType2.scale
                }
            };

            if (dNode.FirstChild_NodeIndex != -1) current_node.node1 = ParseNode(this.Nodes[dNode.FirstChild_NodeIndex]);

            nodes.Add(current_node);

            return nodes.ToArray();
        }
Exemplo n.º 2
0
 private Collada141.node GenerateColladaNode(DNode dNode)
 {
     var mat = Matrix4.Translation(dNode.Position);
     mat *= Matrix4.Rotate(dNode.Rotation);
     //Root node
     Collada141.node node = new Collada141.node()
     {
         name = "Armature",
         id = "Armature",
         type = Collada141.NodeType.NODE,
         Items = new object[] {
             new Collada141.TargetableFloat3() { sid = "location", Values = new double[]{ dNode.Position.X,  dNode.Position.Y,  dNode.Position.Z } },
             new Collada141.rotate(){ sid = "rotationX", Values =new double[]{ 1f, 0f, 0f } },
             new Collada141.rotate(){ sid = "rotationY", Values =new double[]{ 0f, 1f, 0f } },
             new Collada141.rotate(){ sid = "rotationZ", Values =new double[]{ 0f, 0f, 1f } },
             new Collada141.TargetableFloat3() { sid = "scale", Values =new double[] { 1f, 1f, 1f} },
         },
         ItemsElementName = new Collada141.ItemsChoiceType2[]{
             Collada141.ItemsChoiceType2.translate,
             Collada141.ItemsChoiceType2.rotate,
             Collada141.ItemsChoiceType2.rotate,
             Collada141.ItemsChoiceType2.rotate,
             Collada141.ItemsChoiceType2.scale
         },
         node1 = ParseNode(dNode)
     };
     return node;
 }