在JavaScript中将Qubble模型转换为Techne模型

时间:2016-04-15 21:49:18

标签: javascript json minecraft

我需要转换这个JSON对象,一个由Qubble生成的模型:

{
  "name": "Brachiosaurus-Mature.tcn",
  "author": "TechneToTabulaImporter",
  "version": 1,
  "textureWidth": 512,
  "textureHeight": 256,
  "cubes": [
    {
      "name": "hips",
      "children": [
        {
          "name": "body Middle",
          "children": [
            {
              "name": "body Shoulders",
              "children": [
                {
                  "name": "Neck 1",
                  "children": [
                    {
                      "name": "neck2",
                      "children": [
                        {
                          "name": "neck3",
                          "children": [
                            {
                              "name": "neck4",
                              "children": [
                                {
                                  "name": "neck5",
                                  "children": [
                                    {
                                      "name": "neck6",
                                      "children": [
                                        {
                                          "name": "neck7",
                                          "children": [
                                            {
                                              "name": "neck8",
                                              "children": [
                                                {
                                                  "name": "head",
                                                  "children": [
                                                    {
                                                      "name": "snout",
                                                      "children": [],
                                                      "dimensionX": 5,
                                                      "dimensionY": 4,
                                                      "dimensionZ": 6,
                                                      "positionX": 0.0,
                                                      "positionY": 3.5,
                                                      "positionZ": -6.6,
                                                      "offsetX": -2.5,
                                                      "offsetY": -2.0,
                                                      "offsetZ": -6.0,
                                                      "rotationX": 0.0,
                                                      "rotationY": -0.0,
                                                      "rotationZ": 0.0,
                                                      "scaleX": 1.0,
                                                      "scaleY": 1.0,
                                                      "scaleZ": 1.0,
                                                      "textureX": 45,
                                                      "textureY": 13,
                                                      "textureMirrored": false,
                                                      "opacity": 100.0
                                                    },
                                                    {
                                                      "name": "jaw",
                                                      "children": [],
                                                      "dimensionX": 4,
                                                      "dimensionY": 1,
                                                      "dimensionZ": 5,
                                                      "positionX": 0.0,
                                                      "positionY": 5.5,
                                                      "positionZ": -6.7,
                                                      "offsetX": -2.0,
                                                      "offsetY": 0.0,
                                                      "offsetZ": -5.0,
                                                      "rotationX": -0.0,
                                                      "rotationY": -0.0,
                                                      "rotationZ": 0.0,
                                                      "scaleX": 1.0,
                                                      "scaleY": 1.0,
                                                      "scaleZ": 1.0,
                                                      "textureX": 0,
                                                      "textureY": 23,
                                                      "textureMirrored": false,
                                                      "opacity": 100.0
                                                    },
                                                    {
                                                      "name": "nose",
                                                      "children": [],
                                                      "dimensionX": 2,
                                                      "dimensionY": 7,
                                                      "dimensionZ": 8,
                                                      "positionX": 0.0,
                                                      "positionY": 1.0,
                                                      "positionZ": -2.0,
                                                      "offsetX": -1.0,
                                                      "offsetY": -4.0,
                                                      "offsetZ": -8.0,
                                                      "rotationX": 0.0,
                                                      "rotationY": -0.0,
                                                      "rotationZ": 0.0,
                                                      "scaleX": 1.0,
                                                      "scaleY": 1.0,
                                                      "scaleZ": 1.0,
                                                      "textureX": 35,
                                                      "textureY": 30,
                                                      "textureMirrored": false,
                                                      "opacity": 100.0
                                                    }
                                                  ]

        {
          "name": "tail1",
          "children": [
            {
              "name": "tail2",
              "children": [
                {
                  "name": "tail3",
                  "children": [
                    {
                      "name": "tail4",
                      "children": [
                        {
                          "name": "tail5",
                          "children": [
                            {
                              "name": "tail5",
                              "children": [],
                              "dimensionX": 3,
                              "dimensionY": 5,
                              "dimensionZ": 7,
                              "positionX": 0.0,
                              "positionY": 0.5,
                              "positionZ": 6.9,
                              "offsetX": -1.5,
                              "offsetY": 0.0,
                              "offsetZ": 0.0,
                              "rotationX": -7.83,
                              "rotationY": 0.0,
                              "rotationZ": 0.0,
                              "scaleX": 1.0,
                              "scaleY": 1.0,
                              "scaleZ": 1.0,
                              "textureX": 229,
                              "textureY": 222,
                              "textureMirrored": false,
                              "opacity": 100.0
                            }
                          ],
                          "dimensionX": 4,
                          "dimensionY": 7,
                          "dimensionZ": 7,
                          "positionX": 0.0,
                          "positionY": 0.6,
                          "positionZ": 8.0,
                          "offsetX": -2.0,
                          "offsetY": 0.0,
                          "offsetZ": 0.0,
                          "rotationX": -7.83,
                          "rotationY": -0.0,
                          "rotationZ": 0.0,
                          "scaleX": 1.0,
                          "scaleY": 1.0,
                          "scaleZ": 1.0,
                          "textureX": 249,
                          "textureY": 222,
                          "textureMirrored": false,
                          "opacity": 100.0
                        }
                      ],
                      "dimensionX": 5,
                      "dimensionY": 9,
                      "dimensionZ": 8,
                      "positionX": 0.0,
                      "positionY": 0.5,
                      "positionZ": 9.8,
                      "offsetX": -2.5,
                      "offsetY": 0.0,
                      "offsetZ": 0.0,
                      "rotationX": -7.83,
                      "rotationY": -0.0,
                      "rotationZ": 0.0,
                      "scaleX": 1.0,
                      "scaleY": 1.0,
                      "scaleZ": 1.0,
                      "textureX": 99,
                      "textureY": 223,
                      "textureMirrored": false,
                      "opacity": 100.0
                    }
                  ],
                  "dimensionX": 8,
                  "dimensionY": 11,
                  "dimensionZ": 10,
                  "positionX": 0.0,
                  "positionY": 1.0,
                  "positionZ": 9.8,
                  "offsetX": -4.0,
                  "offsetY": 0.0,
                  "offsetZ": 0.0,
                  "rotationX": 2.61,
                  "rotationY": -0.0,
                  "rotationZ": 0.0,
                  "scaleX": 1.0,
                  "scaleY": 1.0,
                  "scaleZ": 1.0,
                  "textureX": 165,
                  "textureY": 215,
                  "textureMirrored": false,
                  "opacity": 100.0
                }
              ],
              "dimensionX": 12,
              "dimensionY": 13,
              "dimensionZ": 11,
              "positionX": 0.0,
              "positionY": 1.4,
              "positionZ": 7.0,
              "offsetX": -6.0,
              "offsetY": 0.0,
              "offsetZ": 0.0,
              "rotationX": 7.83,
              "rotationY": -0.0,
              "rotationZ": 0.0,
              "scaleX": 1.0,
              "scaleY": 1.0,
              "scaleZ": 1.0,
              "textureX": 78,
              "textureY": 189,
              "textureMirrored": false,
              "opacity": 100.0
            }

      ],
      "dimensionX": 7,
      "dimensionY": 16,
      "dimensionZ": 9,
      "positionX": -7.8,
      "positionY": -6.5,
      "positionZ": 0.0,
      "offsetX": -7.0,
      "offsetY": -2.5,
      "offsetZ": -4.5,
      "rotationX": -5.22,
      "rotationY": -0.0,
      "rotationZ": 0.0,
      "scaleX": 0.9,
      "scaleY": 1.0,
      "scaleZ": 1.0,
      "textureX": 124,
      "textureY": 0,
      "textureMirrored": true,
      "opacity": 100.0
    }
  ]
}

使用JavaScript以这种格式,以某种方式,以便我的Techne模型查看器可以读取它:

{
    "Techne": {
        "Models": [{
            "Model": {
                "@texture": "texture.png",
                "BaseClass": "ModelBase",
                "Geometry": {
                    "Shape": [{
                        "@name": "Shape1",
                        "Offset": "0,0,0",
                        "Position": "-1,15,7",
                        "Rotation": "-6,0,0",
                        "Size": "2,9,1",
                        "TextureOffset": "0,0"
                    }, {
                        "@name": "Shape1",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "1,14,7",
                        "Rotation": "-6,18,0",
                        "Size": "2,10,1",
                        "TextureOffset": "7,0"
                    }, {
                        "@name": "Shape1",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "3.2,14,6.3",
                        "Rotation": "-6,36,0",
                        "Size": "2,10,1",
                        "TextureOffset": "14,0"
                    }, {
                        "@name": "Shape2",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "7,16,-1",
                        "Rotation": "0,0,6",
                        "Size": "1,8,2",
                        "TextureOffset": "21,0"
                    }, {
                        "@name": "Shape1",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "6.3,16,3.1",
                        "Rotation": "-6,72,0",
                        "Size": "2,8,1",
                        "TextureOffset": "28,0"
                    }, {
                        "@name": "Shape3",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "5,15,4.9",
                        "Rotation": "-6,54,0",
                        "Size": "2,9,1",
                        "TextureOffset": "35,0"
                    }, {
                        "@name": "Shape1",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "-1,14,-8",
                        "Rotation": "6,0,0",
                        "Size": "2,10,1",
                        "TextureOffset": "42,0"
                    }, {
                        "@name": "Shape2",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "-8,14,-1",
                        "Rotation": "0,0,-6",
                        "Size": "1,10,2",
                        "TextureOffset": "49,0"
                    }, {
                        "@name": "Shape1",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "-3.4,15,-7.3",
                        "Rotation": "6,18,0",
                        "Size": "2,9,1",
                        "TextureOffset": "56,0"
                    }, {
                        "@name": "Shape1",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "-5.5,15,-5.9",
                        "Rotation": "6,36,0",
                        "Size": "2,9,1",
                        "TextureOffset": "63,0"
                    }, {
                        "@name": "Shape3",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "-7.1,14,-3.8",
                        "Rotation": "6,58,0",
                        "Size": "2,10,1",
                        "TextureOffset": "70,0"
                    }, {
                        "@name": "Shape1",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "-8,14,-1.5",
                        "Rotation": "6,72,0",
                        "Size": "2,10,1",
                        "TextureOffset": "77,0"
                    }, {
                        "@name": "Shape4",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "1.5,14,-7.9",
                        "Rotation": "6,-18,0",
                        "Size": "2,10,1",
                        "TextureOffset": "84,0"
                    }, {
                        "@name": "Shape4",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "3.9,14,-7",
                        "Rotation": "6,-36,0",
                        "Size": "2,10,1",
                        "TextureOffset": "91,0"
                    }, {
                        "@name": "Shape4",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "6,14,-5.4",
                        "Rotation": "6,-54,0",
                        "Size": "2,10,1",
                        "TextureOffset": "98,0"
                    }, {
                        "@name": "Shape4",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "7.4,14,-3.4",
                        "Rotation": "6,-72,0",
                        "Size": "2,10,1",
                        "TextureOffset": "105,0"
                    }, {
                        "@name": "Shape4",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "-6.9,15,1.2",
                        "Rotation": "-6,-72,0",
                        "Size": "2,9,1",
                        "TextureOffset": "112,0"
                    }, {
                        "@name": "Shape4",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "-6,15,3.3",
                        "Rotation": "-6,-54,0",
                        "Size": "2,9,1",
                        "TextureOffset": "119,0"
                    }, {
                        "@name": "Shape4",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "-4.7,16,5.1",
                        "Rotation": "-6,-36,0",
                        "Size": "2,8,1",
                        "TextureOffset": "0,20"
                    }, {
                        "@name": "Shape4",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "-3.1,16,6.2",
                        "Rotation": "-6,-18,0",
                        "Size": "2,8,1",
                        "TextureOffset": "7,20"
                    }, {
                        "@name": "Shape5",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "7,19,0",
                        "Rotation": "0,0,0",
                        "Size": "1,1,1",
                        "TextureOffset": "0,12"
                    }, {
                        "@name": "Shape6",
                        "IsMirrored": "False",
                        "Offset": "0,0,0",
                        "Position": "-7,23,-7",
                        "Rotation": "0,0,0",
                        "Size": "14,1,14",
                        "TextureOffset": "14,13"
                    }]
                },
                "GlScale": "1,1,1",
                "Name": "Barrel",
                "TextureSize": "128,32"
            }
        }],
        "Name": "Barrel",
        "PreviewImage": "",
        "ProjectName": "Barrel",
        "ProjectType": "Minecraft"
    }
}

有没有办法可以将Qubble模型转换为JavaScript中的Techne模型?

0 个答案:

没有答案