boxbox
boxbox copied to clipboard
want to load json object generated by physics-body-editor
I was looking for the json object to load in canvas which is generated by physics body editor. But I was not able to find any example in your document if it's possible.
What physics body editor are you using, and is there any documentation or example of the json format?
https://code.google.com/p/box2d-editor/ put image and it will auto trace and generate the object for you.
It would be awesome to add support for this. Do you know if it supports box2dweb?
On Mon, Nov 17, 2014 at 9:10 PM, nirmal bhagwani [email protected] wrote:
https://code.google.com/p/box2d-editor/ put image and it will auto trace and generate the object for you.
— Reply to this email directly or view it on GitHub https://github.com/incompl/boxbox/issues/36#issuecomment-63411720.
It gives the json file we can send xhr request. In return we can get array of object.
But main problem is shape
if you can create a direct library function to support this json parsing.
I kept one cycle image and it generated json file it's like below...Sorry it's long code.
{
"rigidBodies":[
{
"name":"cycle",
"imagePath":"assets/cycke.png",
"origin":{ },
"polygons":[
[
{
"x":0.3466666638851166,
"y":0.7599999904632568
},
{
"x":0.4266666769981384,
"y":0.7766666412353516
},
{
"x":0.40666666626930237,
"y":0.7900000214576721
},
{
"x":0.2933333218097687,
"y":0.7900000214576721
},
{
"x":0.2800000011920929,
"y":0.7799999713897705
},
{
"x":0.2866666615009308,
"y":0.753333330154419
}
],
[
{
"x":0.2866666615009308,
"y":0.753333330154419
},
{
"x":0.3166666626930237,
"y":0.7266666889190674
},
{
"x":0.3466666638851166,
"y":0.7433333396911621
},
{
"x":0.3466666638851166,
"y":0.7599999904632568
}
],
[
{
"x":0.3166666626930237,
"y":0.7266666889190674
},
{
"x":0.3166666626930237,
"y":0.6966666579246521
},
{
"x":0.3700000047683716,
"y":0.7266666889190674
},
{
"x":0.3466666638851166,
"y":0.7433333396911621
}
],
[
{
"x":0.36666667461395264,
"y":0.4166666865348816
},
{
"x":0.38333332538604736,
"y":0.4300000071525574
},
{
"x":0.2633333206176758,
"y":0.6100000143051147
}
],
[
{
"x":0.2633333206176758,
"y":0.6100000143051147
},
{
"x":0.19333332777023315,
"y":0.6266666650772095
},
{
"x":0.1366666704416275,
"y":0.6200000047683716
},
{
"x":0.08666666597127914,
"y":0.596666693687439
},
{
"x":0.03999999910593033,
"y":0.550000011920929
}
],
[
{
"x":0.03999999910593033,
"y":0.550000011920929
},
{
"x":0.013333333656191826,
"y":0.49000000953674316
},
{
"x":0.009999999776482582,
"y":0.4266666769981384
},
{
"x":0.02666666731238365,
"y":0.3700000047683716
},
{
"x":0.0533333346247673,
"y":0.32999998331069946
},
{
"x":0.2633333206176758,
"y":0.6100000143051147
}
],
[
{
"x":0.0533333346247673,
"y":0.32999998331069946
},
{
"x":0.10333333164453506,
"y":0.2900000214576721
},
{
"x":0.15000000596046448,
"y":0.2733333110809326
},
{
"x":0.2133333384990692,
"y":0.26999998092651367
},
{
"x":0.2666666805744171,
"y":0.2866666913032532
}
],
[
{
"x":0.2666666805744171,
"y":0.2866666913032532
},
{
"x":0.31333333253860474,
"y":0.3199999928474426
},
{
"x":0.35333332419395447,
"y":0.3733333349227905
},
{
"x":0.36666667461395264,
"y":0.4166666865348816
},
{
"x":0.2633333206176758,
"y":0.6100000143051147
},
{
"x":0.0533333346247673,
"y":0.32999998331069946
}
],
[
{
"x":0.476666659116745,
"y":0.3633333444595337
},
{
"x":0.4533333480358124,
"y":0.36000001430511475
},
{
"x":0.47333332896232605,
"y":0.34666669368743896
},
{
"x":0.5,
"y":0.35333335399627686
}
],
[
{
"x":0.5,
"y":0.35333335399627686
},
{
"x":0.5,
"y":0.4100000262260437
},
{
"x":0.4833333194255829,
"y":0.3999999761581421
},
{
"x":0.476666659116745,
"y":0.3633333444595337
}
],
[
{
"x":0.5,
"y":0.4100000262260437
},
{
"x":0.5366666913032532,
"y":0.4766666889190674
},
{
"x":0.4699999988079071,
"y":0.4300000071525574
},
{
"x":0.4833333194255829,
"y":0.3999999761581421
}
],
[
{
"x":0.5366666913032532,
"y":0.4766666889190674
},
{
"x":0.6899999976158142,
"y":0.6666666269302368
},
{
"x":0.6233333349227905,
"y":0.7266666889190674
},
{
"x":0.3700000047683716,
"y":0.7266666889190674
},
{
"x":0.3166666626930237,
"y":0.6966666579246521
},
{
"x":0.2633333206176758,
"y":0.6100000143051147
},
{
"x":0.38333332538604736,
"y":0.4300000071525574
},
{
"x":0.4699999988079071,
"y":0.4300000071525574
}
],
[
{
"x":0.7233333587646484,
"y":0.6033333539962769
},
{
"x":0.6600000262260437,
"y":0.5466666221618652
},
{
"x":0.6366666555404663,
"y":0.4933333396911621
},
{
"x":0.6299999952316284,
"y":0.4399999976158142
},
{
"x":0.6433333158493042,
"y":0.3799999952316284
},
{
"x":0.6733333468437195,
"y":0.3333333134651184
}
],
[
{
"x":0.6733333468437195,
"y":0.3333333134651184
},
{
"x":0.7200000286102295,
"y":0.29333335161209106
},
{
"x":0.7699999809265137,
"y":0.2733333110809326
},
{
"x":0.8333333134651184,
"y":0.26999998092651367
},
{
"x":0.8899999856948853,
"y":0.2866666913032532
},
{
"x":0.7233333587646484,
"y":0.6033333539962769
}
],
[
{
"x":0.8899999856948853,
"y":0.2866666913032532
},
{
"x":0.9366666674613953,
"y":0.3199999928474426
},
{
"x":0.9733333587646484,
"y":0.3700000047683716
},
{
"x":0.9866666793823242,
"y":0.4166666865348816
},
{
"x":0.9866666793823242,
"y":0.49000000953674316
},
{
"x":0.9700000286102295,
"y":0.5333333015441895
}
],
[
{
"x":0.9700000286102295,
"y":0.5333333015441895
},
{
"x":0.9300000071525574,
"y":0.5833333730697632
},
{
"x":0.8833333253860474,
"y":0.6133333444595337
},
{
"x":0.8266666531562805,
"y":0.6266666650772095
},
{
"x":0.7733333110809326,
"y":0.6233333349227905
},
{
"x":0.7233333587646484,
"y":0.6033333539962769
},
{
"x":0.8899999856948853,
"y":0.2866666913032532
}
],
[
{
"x":0.7733333110809326,
"y":0.6233333349227905
},
{
"x":0.7099999785423279,
"y":0.6499999761581421
},
{
"x":0.7233333587646484,
"y":0.6033333539962769
}
],
[
{
"x":0.7733333110809326,
"y":0.6233333349227905
},
{
"x":0.7300000190734863,
"y":0.6866666674613953
},
{
"x":0.6733333468437195,
"y":0.7400000095367432
},
{
"x":0.6233333349227905,
"y":0.7266666889190674
},
{
"x":0.6899999976158142,
"y":0.6666666269302368
},
{
"x":0.7099999785423279,
"y":0.6499999761581421
}
],
[
{
"x":0.7300000190734863,
"y":0.6866666674613953
},
{
"x":0.6866666674613953,
"y":0.79666668176651
},
{
"x":0.6566666960716248,
"y":0.7766666412353516
},
{
"x":0.6733333468437195,
"y":0.7400000095367432
}
],
[
{
"x":0.6866666674613953,
"y":0.79666668176651
},
{
"x":0.6666666865348816,
"y":0.8133333325386047
},
{
"x":0.5733333230018616,
"y":0.8133333325386047
},
{
"x":0.5633333325386047,
"y":0.7933333516120911
},
{
"x":0.5733333230018616,
"y":0.7799999713897705
},
{
"x":0.6566666960716248,
"y":0.7766666412353516
}
]
],
"circles":[
],
"shapes":[
{
"type":"POLYGON",
"vertices":[
{
"x":0.5733333230018616,
"y":0.8133333325386047
},
{
"x":0.6666666865348816,
"y":0.8133333325386047
},
{
"x":0.6866666674613953,
"y":0.79666668176651
},
{
"x":0.7300000190734863,
"y":0.6866666674613953
},
{
"x":0.7733333110809326,
"y":0.6233333349227905
},
{
"x":0.8266666531562805,
"y":0.6266666650772095
},
{
"x":0.8833333253860474,
"y":0.6133333444595337
},
{
"x":0.9300000071525574,
"y":0.5833333730697632
},
{
"x":0.9700000286102295,
"y":0.5333333015441895
},
{
"x":0.9866666793823242,
"y":0.49000000953674316
},
{
"x":0.9866666793823242,
"y":0.4166666865348816
},
{
"x":0.9733333587646484,
"y":0.3700000047683716
},
{
"x":0.9366666674613953,
"y":0.3199999928474426
},
{
"x":0.8899999856948853,
"y":0.2866666913032532
},
{
"x":0.8333333134651184,
"y":0.26999998092651367
},
{
"x":0.7699999809265137,
"y":0.2733333110809326
},
{
"x":0.7200000286102295,
"y":0.29333335161209106
},
{
"x":0.6733333468437195,
"y":0.3333333134651184
},
{
"x":0.6433333158493042,
"y":0.3799999952316284
},
{
"x":0.6299999952316284,
"y":0.4399999976158142
},
{
"x":0.6366666555404663,
"y":0.4933333396911621
},
{
"x":0.6600000262260437,
"y":0.5466666221618652
},
{
"x":0.7233333587646484,
"y":0.6033333539962769
},
{
"x":0.7099999785423279,
"y":0.6499999761581421
},
{
"x":0.6899999976158142,
"y":0.6666666269302368
},
{
"x":0.5366666913032532,
"y":0.4766666889190674
},
{
"x":0.5,
"y":0.4100000262260437
},
{
"x":0.5,
"y":0.35333335399627686
},
{
"x":0.47333332896232605,
"y":0.34666669368743896
},
{
"x":0.4533333480358124,
"y":0.36000001430511475
},
{
"x":0.476666659116745,
"y":0.3633333444595337
},
{
"x":0.4833333194255829,
"y":0.3999999761581421
},
{
"x":0.4699999988079071,
"y":0.4300000071525574
},
{
"x":0.38333332538604736,
"y":0.4300000071525574
},
{
"x":0.36666667461395264,
"y":0.4166666865348816
},
{
"x":0.35333332419395447,
"y":0.3733333349227905
},
{
"x":0.31333333253860474,
"y":0.3199999928474426
},
{
"x":0.2666666805744171,
"y":0.2866666913032532
},
{
"x":0.2133333384990692,
"y":0.26999998092651367
},
{
"x":0.15000000596046448,
"y":0.2733333110809326
},
{
"x":0.10333333164453506,
"y":0.2900000214576721
},
{
"x":0.0533333346247673,
"y":0.32999998331069946
},
{
"x":0.02666666731238365,
"y":0.3700000047683716
},
{
"x":0.009999999776482582,
"y":0.4266666769981384
},
{
"x":0.013333333656191826,
"y":0.49000000953674316
},
{
"x":0.03999999910593033,
"y":0.550000011920929
},
{
"x":0.08666666597127914,
"y":0.596666693687439
},
{
"x":0.1366666704416275,
"y":0.6200000047683716
},
{
"x":0.19333332777023315,
"y":0.6266666650772095
},
{
"x":0.2633333206176758,
"y":0.6100000143051147
},
{
"x":0.3166666626930237,
"y":0.6966666579246521
},
{
"x":0.3166666626930237,
"y":0.7266666889190674
},
{
"x":0.2866666615009308,
"y":0.753333330154419
},
{
"x":0.2800000011920929,
"y":0.7799999713897705
},
{
"x":0.2933333218097687,
"y":0.7900000214576721
},
{
"x":0.40666666626930237,
"y":0.7900000214576721
},
{
"x":0.4266666769981384,
"y":0.7766666412353516
},
{
"x":0.3466666638851166,
"y":0.7599999904632568
},
{
"x":0.3466666638851166,
"y":0.7433333396911621
},
{
"x":0.3700000047683716,
"y":0.7266666889190674
},
{
"x":0.6233333349227905,
"y":0.7266666889190674
},
{
"x":0.6733333468437195,
"y":0.7400000095367432
},
{
"x":0.6566666960716248,
"y":0.7766666412353516
},
{
"x":0.5733333230018616,
"y":0.7799999713897705
},
{
"x":0.5633333325386047,
"y":0.7933333516120911
}
]
}
]
}
],
"dynamicObjects":[
]
}
On Nov 18, 2014 8:41 PM, "Greg" [email protected] wrote:
It would be awesome to add support for this. Do you know if it supports box2dweb?
On Mon, Nov 17, 2014 at 9:10 PM, nirmal bhagwani [email protected]
wrote:
https://code.google.com/p/box2d-editor/ put image and it will auto trace and generate the object for you.
— Reply to this email directly or view it on GitHub https://github.com/incompl/boxbox/issues/36#issuecomment-63411720.
— Reply to this email directly or view it on GitHub https://github.com/incompl/boxbox/issues/36#issuecomment-63484997.