Normalize all the line endings

This commit is contained in:
Emux
2016-07-04 20:57:46 +03:00
parent 53cafa2f3b
commit d6a65ff731
35 changed files with 16275 additions and 16275 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,177 +1,177 @@
{ {
"version": [ 0, 1], "version": [ 0, 1],
"id": "", "id": "",
"meshes": [ "meshes": [
{ {
"attributes": ["POSITION", "NORMAL", "TEXCOORD0"], "attributes": ["POSITION", "NORMAL", "TEXCOORD0"],
"vertices": [ "vertices": [
-0.003717, -0.043092, 0.000001, 0.000000, -1.000000, 0.000000, 0.000000, 0.000000, -0.003717, -0.043092, 0.000001, 0.000000, -1.000000, 0.000000, 0.000000, 0.000000,
-0.003717, -0.043092, -0.019798, 0.000000, -0.609973, -0.792383, 0.000000, 0.000000, -0.003717, -0.043092, -0.019798, 0.000000, -0.609973, -0.792383, 0.000000, 0.000000,
0.013430, -0.043092, -0.009898, 0.686239, -0.609973, -0.396191, 0.000000, 0.000000, 0.013430, -0.043092, -0.009898, 0.686239, -0.609973, -0.396191, 0.000000, 0.000000,
-0.003717, 0.527242, 0.000001, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, -0.003717, 0.527242, 0.000001, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000,
0.013430, 0.527242, -0.009898, 0.686239, 0.609973, -0.396191, 0.000000, 0.000000, 0.013430, 0.527242, -0.009898, 0.686239, 0.609973, -0.396191, 0.000000, 0.000000,
-0.003717, 0.527242, -0.019798, 0.000000, 0.609973, -0.792383, 0.000000, 0.000000, -0.003717, 0.527242, -0.019798, 0.000000, 0.609973, -0.792383, 0.000000, 0.000000,
0.013430, -0.043092, 0.009901, 0.686239, -0.609973, 0.396191, 0.000000, 0.000000, 0.013430, -0.043092, 0.009901, 0.686239, -0.609973, 0.396191, 0.000000, 0.000000,
0.013430, 0.527242, 0.009901, 0.686239, 0.609973, 0.396191, 0.000000, 0.000000, 0.013430, 0.527242, 0.009901, 0.686239, 0.609973, 0.396191, 0.000000, 0.000000,
-0.003717, -0.043092, 0.019801, 0.000000, -0.609973, 0.792383, 0.000000, 0.000000, -0.003717, -0.043092, 0.019801, 0.000000, -0.609973, 0.792383, 0.000000, 0.000000,
-0.003717, 0.527242, 0.019801, 0.000000, 0.609973, 0.792383, 0.000000, 0.000000, -0.003717, 0.527242, 0.019801, 0.000000, 0.609973, 0.792383, 0.000000, 0.000000,
-0.020865, -0.043092, 0.009901, -0.686239, -0.609973, 0.396191, 0.000000, 0.000000, -0.020865, -0.043092, 0.009901, -0.686239, -0.609973, 0.396191, 0.000000, 0.000000,
-0.020865, 0.527242, 0.009901, -0.686239, 0.609973, 0.396191, 0.000000, 0.000000, -0.020865, 0.527242, 0.009901, -0.686239, 0.609973, 0.396191, 0.000000, 0.000000,
-0.020865, -0.043092, -0.009898, -0.686239, -0.609973, -0.396191, 0.000000, 0.000000, -0.020865, -0.043092, -0.009898, -0.686239, -0.609973, -0.396191, 0.000000, 0.000000,
-0.020865, 0.527242, -0.009898, -0.686239, 0.609973, -0.396191, 0.000000, 0.000000, -0.020865, 0.527242, -0.009898, -0.686239, 0.609973, -0.396191, 0.000000, 0.000000,
-0.000052, 1.708732, 0.000001, 0.000000, 1.000000, 0.000000, 0.627643, 0.963260, -0.000052, 1.708732, 0.000001, 0.000000, 1.000000, 0.000000, 0.627643, 0.963260,
-0.056858, 1.692897, -0.056805, -0.359325, 0.861232, -0.359325, 0.811107, 0.943917, -0.056858, 1.692897, -0.056805, -0.359325, 0.861232, -0.359325, 0.811107, 0.943917,
-0.080388, 1.692897, 0.000001, -0.508194, 0.861232, 0.000000, 0.930977, 0.971962, -0.080388, 1.692897, 0.000001, -0.508194, 0.861232, 0.000000, 0.930977, 0.971962,
-0.112293, 1.619116, -0.112239, -0.584552, 0.562639, -0.584552, 0.871491, 0.884983, -0.112293, 1.619116, -0.112239, -0.584552, 0.562639, -0.584552, 0.871491, 0.884983,
-0.158784, 1.619116, 0.000001, -0.826655, 0.562639, 0.000000, 1.012361, 0.910828, -0.158784, 1.619116, 0.000001, -0.826655, 0.562639, 0.000000, 1.012361, 0.910828,
-0.176420, 1.422079, -0.176367, -0.675863, 0.293832, -0.675863, 0.903795, 0.728324, -0.176420, 1.422079, -0.176367, -0.675863, 0.293832, -0.675863, 0.903795, 0.728324,
-0.249474, 1.422079, 0.000001, -0.955840, 0.293832, 0.000000, 1.035246, 0.751852, -0.249474, 1.422079, 0.000001, -0.955840, 0.293832, 0.000000, 1.035246, 0.751852,
-0.210746, 1.159339, -0.210693, -0.704306, 0.088870, -0.704306, 0.922129, 0.451029, -0.210746, 1.159339, -0.210693, -0.704306, 0.088870, -0.704306, 0.922129, 0.451029,
-0.298019, 1.159339, 0.000001, -0.996033, 0.088870, 0.000000, 1.045340, 0.473093, -0.298019, 1.159339, 0.000001, -0.996033, 0.088870, 0.000000, 1.045340, 0.473093,
-0.210605, 0.903175, -0.210552, -0.705252, -0.072024, -0.705252, 0.936767, 0.254108, -0.210605, 0.903175, -0.210552, -0.705252, -0.072024, -0.705252, 0.936767, 0.254108,
-0.297820, 0.903175, 0.000001, -0.997375, -0.072024, 0.000000, 1.052424, 0.274946, -0.297820, 0.903175, 0.000001, -0.997375, -0.072024, 0.000000, 1.052424, 0.274946,
-0.180964, 0.617981, -0.180911, -0.685263, -0.246529, -0.685263, 0.956801, 0.142573, -0.180964, 0.617981, -0.180911, -0.685263, -0.246529, -0.685263, 0.956801, 0.142573,
-0.255900, 0.617981, 0.000001, -0.969115, -0.246529, 0.000000, 1.061122, 0.161660, -0.255900, 0.617981, 0.000001, -0.969115, -0.246529, 0.000000, 1.061122, 0.161660,
-0.116291, 0.378825, -0.116238, -0.610279, -0.505051, -0.610279, 0.991689, 0.079506, -0.116291, 0.378825, -0.116238, -0.610279, -0.505051, -0.610279, 0.991689, 0.079506,
-0.164439, 0.378825, 0.000001, -0.863063, -0.505051, 0.000000, 1.074527, 0.095355, -0.164439, 0.378825, 0.000001, -0.863063, -0.505051, 0.000000, 1.074527, 0.095355,
-0.059153, 0.290116, -0.059100, -0.407514, -0.817194, -0.407544, 1.038003, 0.052079, -0.059153, 0.290116, -0.059100, -0.407514, -0.817194, -0.407544, 1.038003, 0.052079,
-0.083634, 0.290116, 0.000001, -0.576312, -0.817194, 0.000000, 1.090933, 0.063214, -0.083634, 0.290116, 0.000001, -0.576312, -0.817194, 0.000000, 1.090933, 0.063214,
-0.083634, 0.290116, 0.000001, -0.576312, -0.817194, 0.000000, 0.090933, 0.063214, -0.083634, 0.290116, 0.000001, -0.576312, -0.817194, 0.000000, 0.090933, 0.063214,
-0.059153, 0.290116, -0.059100, -0.407514, -0.817194, -0.407544, 0.038003, 0.052079, -0.059153, 0.290116, -0.059100, -0.407514, -0.817194, -0.407544, 0.038003, 0.052079,
-0.000125, 0.265210, -0.000071, -0.000244, -0.999969, -0.000244, 0.127500, 0.036749, -0.000125, 0.265210, -0.000071, -0.000244, -0.999969, -0.000244, 0.127500, 0.036749,
-0.000051, 0.290116, -0.083580, 0.000000, -0.817194, -0.576312, 0.994047, 0.033372, -0.000051, 0.290116, -0.083580, 0.000000, -0.817194, -0.576312, 0.994047, 0.033372,
-0.000125, 0.265210, -0.000071, -0.000244, -0.999969, -0.000244, 1.127500, 0.036749, -0.000125, 0.265210, -0.000071, -0.000244, -0.999969, -0.000244, 1.127500, 0.036749,
-0.000051, 0.378825, -0.164386, 0.000000, -0.505051, -0.863063, 0.893772, 0.053663, -0.000051, 0.378825, -0.164386, 0.000000, -0.505051, -0.863063, 0.893772, 0.053663,
-0.000052, 0.617981, -0.255847, 0.000000, -0.246529, -0.969115, 0.836458, 0.114704, -0.000052, 0.617981, -0.255847, 0.000000, -0.246529, -0.969115, 0.836458, 0.114704,
-0.000052, 0.903175, -0.297766, 0.000000, -0.072024, -0.997375, 0.812221, 0.226047, -0.000052, 0.903175, -0.297766, 0.000000, -0.072024, -0.997375, 0.812221, 0.226047,
-0.000052, 1.159339, -0.297966, 0.000000, 0.088870, -0.996033, 0.797565, 0.423137, -0.000052, 1.159339, -0.297966, 0.000000, 0.088870, -0.996033, 0.797565, 0.423137,
-0.000052, 1.422079, -0.249421, 0.000000, 0.293832, -0.955840, 0.781975, 0.700922, -0.000052, 1.422079, -0.249421, 0.000000, 0.293832, -0.955840, 0.781975, 0.700922,
-0.000052, 1.619116, -0.158731, 0.000000, 0.562639, -0.826655, 0.759783, 0.858997, -0.000052, 1.619116, -0.158731, 0.000000, 0.562639, -0.826655, 0.759783, 0.858997,
-0.000052, 1.692897, -0.080335, 0.000000, 0.861232, -0.508194, 0.728165, 0.921879, -0.000052, 1.692897, -0.080335, 0.000000, 0.861232, -0.508194, 0.728165, 0.921879,
0.056754, 1.692897, -0.056805, 0.359325, 0.861232, -0.359325, 0.652361, 0.910987, 0.056754, 1.692897, -0.056805, 0.359325, 0.861232, -0.359325, 0.652361, 0.910987,
0.112189, 1.619116, -0.112239, 0.584552, 0.562639, -0.584552, 0.659906, 0.845090, 0.112189, 1.619116, -0.112239, 0.584552, 0.562639, -0.584552, 0.659906, 0.845090,
0.176316, 1.422079, -0.176367, 0.675863, 0.293832, -0.675863, 0.665734, 0.684958, 0.176316, 1.422079, -0.176367, 0.675863, 0.293832, -0.675863, 0.665734, 0.684958,
0.210643, 1.159339, -0.210693, 0.704306, 0.088870, -0.704306, 0.670277, 0.405750, 0.210643, 1.159339, -0.210693, 0.704306, 0.088870, -0.704306, 0.670277, 0.405750,
0.210502, 0.903175, -0.210552, 0.705252, -0.072024, -0.705252, 0.675032, 0.207335, 0.210502, 0.903175, -0.210552, 0.705252, -0.072024, -0.705252, 0.675032, 0.207335,
0.180860, 0.617981, -0.180910, 0.685263, -0.246529, -0.685263, 0.684415, 0.093825, 0.180860, 0.617981, -0.180910, 0.685263, -0.246529, -0.685263, 0.684415, 0.093825,
0.116188, 0.378825, -0.116237, 0.610279, -0.505051, -0.610279, 0.723612, 0.027920, 0.116188, 0.378825, -0.116237, 0.610279, -0.505051, -0.610279, 0.723612, 0.027920,
0.059050, 0.290116, -0.059099, 0.407483, -0.817255, -0.407422, 1.018456, 0.011649, 0.059050, 0.290116, -0.059099, 0.407483, -0.817255, -0.407422, 1.018456, 0.011649,
0.059050, 0.290116, -0.059099, 0.407483, -0.817255, -0.407422, 0.018456, 0.011649, 0.059050, 0.290116, -0.059099, 0.407483, -0.817255, -0.407422, 0.018456, 0.011649,
0.083530, 0.290116, 0.000002, 0.576159, -0.817316, 0.000000, 0.267608, 0.018648, 0.083530, 0.290116, 0.000002, 0.576159, -0.817316, 0.000000, 0.267608, 0.018648,
0.164335, 0.378825, 0.000002, 0.863063, -0.505051, 0.000000, 0.457225, 0.035136, 0.164335, 0.378825, 0.000002, 0.863063, -0.505051, 0.000000, 0.457225, 0.035136,
0.255796, 0.617981, 0.000002, 0.969115, -0.246529, 0.000000, 0.515690, 0.098717, 0.255796, 0.617981, 0.000002, 0.969115, -0.246529, 0.000000, 0.515690, 0.098717,
0.297716, 0.903175, 0.000002, 0.997375, -0.072024, 0.000000, 0.532803, 0.211513, 0.297716, 0.903175, 0.000002, 0.997375, -0.072024, 0.000000, 0.532803, 0.211513,
0.297915, 1.159339, 0.000002, 0.996033, 0.088870, 0.000000, 0.541872, 0.409545, 0.297915, 1.159339, 0.000002, 0.996033, 0.088870, 0.000000, 0.541872, 0.409545,
0.249370, 1.422079, 0.000002, 0.955840, 0.293832, 0.000000, 0.550746, 0.688375, 0.249370, 1.422079, 0.000002, 0.955840, 0.293832, 0.000000, 0.550746, 0.688375,
0.158680, 1.619116, 0.000002, 0.826655, 0.562639, 0.000000, 0.562378, 0.848006, 0.158680, 1.619116, 0.000002, 0.826655, 0.562639, 0.000000, 0.562378, 0.848006,
0.080284, 1.692897, 0.000001, 0.508194, 0.861232, 0.000000, 0.577714, 0.913236, 0.080284, 1.692897, 0.000001, 0.508194, 0.861232, 0.000000, 0.577714, 0.913236,
0.056754, 1.692897, 0.056808, 0.359325, 0.861232, 0.359325, 0.500528, 0.928224, 0.056754, 1.692897, 0.056808, 0.359325, 0.861232, 0.359325, 0.500528, 0.928224,
0.112188, 1.619116, 0.112242, 0.584552, 0.562670, 0.584552, 0.459880, 0.866817, 0.112188, 1.619116, 0.112242, 0.584552, 0.562670, 0.584552, 0.459880, 0.866817,
0.176316, 1.422079, 0.176370, 0.675863, 0.293832, 0.675863, 0.433163, 0.709519, 0.176316, 1.422079, 0.176370, 0.675863, 0.293832, 0.675863, 0.433163, 0.709519,
0.210642, 1.159339, 0.210696, 0.704306, 0.088870, 0.704306, 0.415507, 0.432148, 0.210642, 1.159339, 0.210696, 0.704306, 0.088870, 0.704306, 0.415507, 0.432148,
0.210501, 0.903175, 0.210555, 0.705252, -0.072024, 0.705252, 0.399773, 0.235351, 0.210501, 0.903175, 0.210555, 0.705252, -0.072024, 0.705252, 0.399773, 0.235351,
0.180860, 0.617981, 0.180914, 0.685263, -0.246529, 0.685263, 0.375517, 0.124299, 0.180860, 0.617981, 0.180914, 0.685263, -0.246529, 0.685263, 0.375517, 0.124299,
0.116187, 0.378825, 0.116241, 0.610279, -0.505051, 0.610279, 0.325269, 0.063109, 0.116187, 0.378825, 0.116241, 0.610279, -0.505051, 0.610279, 0.325269, 0.063109,
0.059049, 0.290116, 0.059103, 0.407361, -0.817347, 0.407392, 0.248452, 0.040330, 0.059049, 0.290116, 0.059103, 0.407361, -0.817347, 0.407392, 0.248452, 0.040330,
-0.000053, 0.290116, 0.083583, 0.000000, -0.817316, 0.576159, 0.199939, 0.056802, -0.000053, 0.290116, 0.083583, 0.000000, -0.817316, 0.576159, 0.199939, 0.056802,
-0.000053, 0.378825, 0.164389, 0.000000, -0.505051, 0.863063, 0.234895, 0.086200, -0.000053, 0.378825, 0.164389, 0.000000, -0.505051, 0.863063, 0.234895, 0.086200,
-0.000053, 0.617981, 0.255850, 0.000000, -0.246529, 0.969115, 0.262269, 0.150492, -0.000053, 0.617981, 0.255850, 0.000000, -0.246529, 0.969115, 0.262269, 0.150492,
-0.000052, 0.903175, 0.297769, 0.000000, -0.072024, 0.997375, 0.278892, 0.262611, -0.000052, 0.903175, 0.297769, 0.000000, -0.072024, 0.997375, 0.278892, 0.262611,
-0.000052, 1.159339, 0.297968, 0.000000, 0.088870, 0.996033, 0.291619, 0.459894, -0.000052, 1.159339, 0.297968, 0.000000, 0.088870, 0.996033, 0.291619, 0.459894,
-0.000052, 1.422079, 0.249424, 0.000000, 0.293832, 0.955840, 0.308400, 0.737559, -0.000052, 1.422079, 0.249424, 0.000000, 0.293832, 0.955840, 0.308400, 0.737559,
-0.000052, 1.619116, 0.158734, 0.000000, 0.562670, 0.826655, 0.340691, 0.894603, -0.000052, 1.619116, 0.158734, 0.000000, 0.562670, 0.826655, 0.340691, 0.894603,
-0.000052, 1.692897, 0.080338, 0.000000, 0.861232, 0.508194, 0.411564, 0.953109, -0.000052, 1.692897, 0.080338, 0.000000, 0.861232, 0.508194, 0.411564, 0.953109,
-0.056858, 1.692897, 0.056808, -0.359325, 0.861232, 0.359325, 0.247502, 0.980115, -0.056858, 1.692897, 0.056808, -0.359325, 0.861232, 0.359325, 0.247502, 0.980115,
-0.112293, 1.619116, 0.112242, -0.584552, 0.562670, 0.584552, 0.186319, 0.915857, -0.112293, 1.619116, 0.112242, -0.584552, 0.562670, 0.584552, 0.186319, 0.915857,
-0.176420, 1.422079, 0.176369, -0.675863, 0.293832, 0.675863, 0.173739, 0.755927, -0.176420, 1.422079, 0.176369, -0.675863, 0.293832, 0.675863, 0.173739, 0.755927,
-0.210747, 1.159339, 0.210696, -0.704306, 0.088870, 0.704306, 0.168491, 0.476740, -0.210747, 1.159339, 0.210696, -0.704306, 0.088870, 0.704306, 0.168491, 0.476740,
-0.210606, 0.903175, 0.210555, -0.705252, -0.072024, 0.705252, 0.164886, 0.278291, -0.210606, 0.903175, 0.210555, -0.705252, -0.072024, 0.705252, 0.164886, 0.278291,
-0.180964, 0.617981, 0.180913, -0.685263, -0.246529, 0.685263, 0.160531, 0.164632, -0.180964, 0.617981, 0.180913, -0.685263, -0.246529, 0.685263, 0.160531, 0.164632,
-0.116292, 0.378825, 0.116240, -0.610279, -0.505051, 0.610279, 0.153922, 0.097744, -0.116292, 0.378825, 0.116240, -0.610279, -0.505051, 0.610279, 0.153922, 0.097744,
-0.059154, 0.290116, 0.059102, -0.407453, -0.817255, 0.407483, 0.145909, 0.064880, -0.059154, 0.290116, 0.059102, -0.407453, -0.817255, 0.407483, 0.145909, 0.064880,
-0.164439, 0.378825, 0.000001, -0.863063, -0.505051, 0.000000, 0.074527, 0.095355, -0.164439, 0.378825, 0.000001, -0.863063, -0.505051, 0.000000, 0.074527, 0.095355,
-0.255900, 0.617981, 0.000001, -0.969115, -0.246529, 0.000000, 0.061122, 0.161660, -0.255900, 0.617981, 0.000001, -0.969115, -0.246529, 0.000000, 0.061122, 0.161660,
-0.297820, 0.903175, 0.000001, -0.997375, -0.072024, 0.000000, 0.052424, 0.274946, -0.297820, 0.903175, 0.000001, -0.997375, -0.072024, 0.000000, 0.052424, 0.274946,
-0.298019, 1.159339, 0.000001, -0.996033, 0.088870, 0.000000, 0.045340, 0.473093, -0.298019, 1.159339, 0.000001, -0.996033, 0.088870, 0.000000, 0.045340, 0.473093,
-0.249474, 1.422079, 0.000001, -0.955840, 0.293832, 0.000000, 0.035246, 0.751852, -0.249474, 1.422079, 0.000001, -0.955840, 0.293832, 0.000000, 0.035246, 0.751852,
-0.158784, 1.619116, 0.000001, -0.826655, 0.562639, 0.000000, 0.012361, 0.910828, -0.158784, 1.619116, 0.000001, -0.826655, 0.562639, 0.000000, 0.012361, 0.910828,
-0.056858, 1.692897, 0.056808, -0.359325, 0.861232, 0.359325, 1.247502, 0.980115, -0.056858, 1.692897, 0.056808, -0.359325, 0.861232, 0.359325, 1.247502, 0.980115,
-0.112293, 1.619116, 0.112242, -0.584552, 0.562670, 0.584552, 1.186319, 0.915857 -0.112293, 1.619116, 0.112242, -0.584552, 0.562670, 0.584552, 1.186319, 0.915857
], ],
"parts": [ "parts": [
{ {
"id": "mpart1", "id": "mpart1",
"type": "TRIANGLES", "type": "TRIANGLES",
"indices": [ "indices": [
0, 1, 2, 3, 4, 5, 0, 2, 6, 3, 7, 4, 0, 1, 2, 3, 4, 5, 0, 2, 6, 3, 7, 4,
0, 6, 8, 3, 9, 7, 0, 8, 10, 3, 11, 9, 0, 6, 8, 3, 9, 7, 0, 8, 10, 3, 11, 9,
0, 10, 12, 3, 13, 11, 12, 1, 0, 3, 5, 13, 0, 10, 12, 3, 13, 11, 12, 1, 0, 3, 5, 13,
1, 5, 4, 1, 4, 2, 2, 4, 7, 2, 7, 6, 1, 5, 4, 1, 4, 2, 2, 4, 7, 2, 7, 6,
6, 7, 9, 6, 9, 8, 8, 9, 11, 8, 11, 10, 6, 7, 9, 6, 9, 8, 8, 9, 11, 8, 11, 10,
10, 11, 13, 10, 13, 12, 5, 1, 12, 5, 12, 13, 10, 11, 13, 10, 13, 12, 5, 1, 12, 5, 12, 13,
14, 15, 16, 16, 15, 17, 16, 17, 18, 18, 17, 19, 14, 15, 16, 16, 15, 17, 16, 17, 18, 18, 17, 19,
18, 19, 20, 20, 19, 21, 20, 21, 22, 22, 21, 23, 18, 19, 20, 20, 19, 21, 20, 21, 22, 22, 21, 23,
22, 23, 24, 24, 23, 25, 24, 25, 26, 26, 25, 27, 22, 23, 24, 24, 23, 25, 24, 25, 26, 26, 25, 27,
26, 27, 28, 28, 27, 29, 28, 29, 30, 31, 32, 33, 26, 27, 28, 28, 27, 29, 28, 29, 30, 31, 32, 33,
29, 34, 35, 27, 36, 34, 27, 34, 29, 25, 37, 36, 29, 34, 35, 27, 36, 34, 27, 34, 29, 25, 37, 36,
25, 36, 27, 23, 38, 37, 23, 37, 25, 21, 39, 38, 25, 36, 27, 23, 38, 37, 23, 37, 25, 21, 39, 38,
21, 38, 23, 19, 40, 39, 19, 39, 21, 17, 41, 40, 21, 38, 23, 19, 40, 39, 19, 39, 21, 17, 41, 40,
17, 40, 19, 15, 42, 41, 15, 41, 17, 15, 14, 42, 17, 40, 19, 15, 42, 41, 15, 41, 17, 15, 14, 42,
42, 14, 43, 42, 43, 44, 42, 44, 41, 41, 44, 45, 42, 14, 43, 42, 43, 44, 42, 44, 41, 41, 44, 45,
41, 45, 40, 40, 45, 46, 40, 46, 39, 39, 46, 47, 41, 45, 40, 40, 45, 46, 40, 46, 39, 39, 46, 47,
39, 47, 38, 38, 47, 48, 38, 48, 37, 37, 48, 49, 39, 47, 38, 38, 47, 48, 38, 48, 37, 37, 48, 49,
37, 49, 36, 36, 49, 50, 36, 50, 34, 34, 50, 35, 37, 49, 36, 36, 49, 50, 36, 50, 34, 34, 50, 35,
51, 52, 33, 49, 53, 52, 49, 52, 50, 48, 54, 53, 51, 52, 33, 49, 53, 52, 49, 52, 50, 48, 54, 53,
48, 53, 49, 47, 55, 54, 47, 54, 48, 46, 56, 55, 48, 53, 49, 47, 55, 54, 47, 54, 48, 46, 56, 55,
46, 55, 47, 45, 57, 56, 45, 56, 46, 44, 58, 57, 46, 55, 47, 45, 57, 56, 45, 56, 46, 44, 58, 57,
44, 57, 45, 43, 59, 58, 43, 58, 44, 43, 14, 59, 44, 57, 45, 43, 59, 58, 43, 58, 44, 43, 14, 59,
59, 14, 60, 59, 60, 61, 59, 61, 58, 58, 61, 62, 59, 14, 60, 59, 60, 61, 59, 61, 58, 58, 61, 62,
58, 62, 57, 57, 62, 63, 57, 63, 56, 56, 63, 64, 58, 62, 57, 57, 62, 63, 57, 63, 56, 56, 63, 64,
56, 64, 55, 55, 64, 65, 55, 65, 54, 54, 65, 66, 56, 64, 55, 55, 64, 65, 55, 65, 54, 54, 65, 66,
54, 66, 53, 53, 66, 67, 53, 67, 52, 52, 67, 33, 54, 66, 53, 53, 66, 67, 53, 67, 52, 52, 67, 33,
67, 68, 33, 66, 69, 68, 66, 68, 67, 65, 70, 69, 67, 68, 33, 66, 69, 68, 66, 68, 67, 65, 70, 69,
65, 69, 66, 64, 71, 70, 64, 70, 65, 63, 72, 71, 65, 69, 66, 64, 71, 70, 64, 70, 65, 63, 72, 71,
63, 71, 64, 62, 73, 72, 62, 72, 63, 61, 74, 73, 63, 71, 64, 62, 73, 72, 62, 72, 63, 61, 74, 73,
61, 73, 62, 60, 75, 74, 60, 74, 61, 60, 14, 75, 61, 73, 62, 60, 75, 74, 60, 74, 61, 60, 14, 75,
75, 14, 76, 75, 76, 77, 75, 77, 74, 74, 77, 78, 75, 14, 76, 75, 76, 77, 75, 77, 74, 74, 77, 78,
74, 78, 73, 73, 78, 79, 73, 79, 72, 72, 79, 80, 74, 78, 73, 73, 78, 79, 73, 79, 72, 72, 79, 80,
72, 80, 71, 71, 80, 81, 71, 81, 70, 70, 81, 82, 72, 80, 71, 71, 80, 81, 71, 81, 70, 70, 81, 82,
70, 82, 69, 69, 82, 83, 69, 83, 68, 68, 83, 33, 70, 82, 69, 69, 82, 83, 69, 83, 68, 68, 83, 33,
83, 31, 33, 82, 84, 31, 82, 31, 83, 81, 85, 84, 83, 31, 33, 82, 84, 31, 82, 31, 83, 81, 85, 84,
81, 84, 82, 80, 86, 85, 80, 85, 81, 79, 87, 86, 81, 84, 82, 80, 86, 85, 80, 85, 81, 79, 87, 86,
79, 86, 80, 78, 88, 87, 78, 87, 79, 77, 89, 88, 79, 86, 80, 78, 88, 87, 78, 87, 79, 77, 89, 88,
77, 88, 78, 90, 16, 18, 90, 18, 91, 90, 14, 16 77, 88, 78, 90, 16, 18, 90, 18, 91, 90, 14, 16
] ]
} }
] ]
} }
], ],
"materials": [ "materials": [
{ {
"id": "_tree.png", "id": "_tree.png",
"diffuse": [ 0.900000, 0.900000, 0.900000], "diffuse": [ 0.900000, 0.900000, 0.900000],
"specular": [ 0.100000, 0.100000, 0.100000], "specular": [ 0.100000, 0.100000, 0.100000],
"textures": [ "textures": [
{ {
"id": "_tree.png", "id": "_tree.png",
"filename": "tree.png", "filename": "tree.png",
"type": "DIFFUSE" "type": "DIFFUSE"
} }
] ]
} }
], ],
"nodes": [ "nodes": [
{ {
"id": "treeA_root", "id": "treeA_root",
"parts": [ "parts": [
{ {
"meshpartid": "mpart1", "meshpartid": "mpart1",
"materialid": "_tree.png", "materialid": "_tree.png",
"uvMapping": [[ 0]] "uvMapping": [[ 0]]
} }
] ]
} }
], ],
"animations": [] "animations": []
} }

180
gradlew.bat vendored
View File

@@ -1,90 +1,90 @@
@if "%DEBUG%" == "" @echo off @if "%DEBUG%" == "" @echo off
@rem ########################################################################## @rem ##########################################################################
@rem @rem
@rem Gradle startup script for Windows @rem Gradle startup script for Windows
@rem @rem
@rem ########################################################################## @rem ##########################################################################
@rem Set local scope for the variables with windows NT shell @rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS= set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0 set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=. if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0 set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME% set APP_HOME=%DIRNAME%
@rem Find java.exe @rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1 %JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init if "%ERRORLEVEL%" == "0" goto init
echo. echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo. echo.
echo Please set the JAVA_HOME variable in your environment to match the echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation. echo location of your Java installation.
goto fail goto fail
:findJavaFromJavaHome :findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=% set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init if exist "%JAVA_EXE%" goto init
echo. echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo. echo.
echo Please set the JAVA_HOME variable in your environment to match the echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation. echo location of your Java installation.
goto fail goto fail
:init :init
@rem Get command-line arguments, handling Windowz variants @rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args :win9xME_args
@rem Slurp the command line arguments. @rem Slurp the command line arguments.
set CMD_LINE_ARGS= set CMD_LINE_ARGS=
set _SKIP=2 set _SKIP=2
:win9xME_args_slurp :win9xME_args_slurp
if "x%~1" == "x" goto execute if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%* set CMD_LINE_ARGS=%*
goto execute goto execute
:4NT_args :4NT_args
@rem Get arguments from the 4NT Shell from JP Software @rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$ set CMD_LINE_ARGS=%$
:execute :execute
@rem Setup the command line @rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle @rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end :end
@rem End local scope for the variables with windows NT shell @rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd if "%ERRORLEVEL%"=="0" goto mainEnd
:fail :fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code! rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1 exit /b 1
:mainEnd :mainEnd
if "%OS%"=="Windows_NT" endlocal if "%OS%"=="Windows_NT" endlocal
:omega :omega

View File

@@ -1,14 +1,14 @@
LOCAL_PATH:= $(call my-dir) LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_MODULE := vtm-jni LOCAL_MODULE := vtm-jni
LOCAL_C_INCLUDES := . libtess2/Include LOCAL_C_INCLUDES := . libtess2/Include
LOCAL_CFLAGS := $(LOCAL_C_INCLUDES:%=-I%) -O2 -Wall -D__ANDROID__ -Wall -std=c99 -O2 -ffast-math -DNDEBUG LOCAL_CFLAGS := $(LOCAL_C_INCLUDES:%=-I%) -O2 -Wall -D__ANDROID__ -Wall -std=c99 -O2 -ffast-math -DNDEBUG
LOCAL_CPPFLAGS := $(LOCAL_C_INCLUDES:%=-I%) -O2 -Wall -D__ANDROID__ -Wall -std=c99 -O2 -ffast-math -DNDEBUG LOCAL_CPPFLAGS := $(LOCAL_C_INCLUDES:%=-I%) -O2 -Wall -D__ANDROID__ -Wall -std=c99 -O2 -ffast-math -DNDEBUG
LOCAL_LDLIBS := -lm -llog LOCAL_LDLIBS := -lm -llog
LOCAL_ARM_MODE := arm LOCAL_ARM_MODE := arm
LOCAL_SRC_FILES := org.oscim.utils.TessJNI.cpp\ LOCAL_SRC_FILES := org.oscim.utils.TessJNI.cpp\
libtess2/Source/sweep.c\ libtess2/Source/sweep.c\
libtess2/Source/priorityq.c\ libtess2/Source/priorityq.c\
@@ -18,5 +18,5 @@ LOCAL_SRC_FILES := org.oscim.utils.TessJNI.cpp\
libtess2/Source/dict.c\ libtess2/Source/dict.c\
libtess2/Source/mesh.c\ libtess2/Source/mesh.c\
gl/utils.c gl/utils.c
include $(BUILD_SHARED_LIBRARY) include $(BUILD_SHARED_LIBRARY)

View File

@@ -1,33 +1,33 @@
<project name="android-natives" basedir="." default="postcompile"> <project name="android-natives" basedir="." default="postcompile">
<property environment="env" /> <property environment="env" />
<!-- the suffix ndk-build executable --> <!-- the suffix ndk-build executable -->
<property name="ndkSuffix" value="" /> <property name="ndkSuffix" value="" />
<target name="clean" depends="check-for-ndk" if="has-ndk-build"> <target name="clean" depends="check-for-ndk" if="has-ndk-build">
<exec executable="${env.NDK_HOME}/ndk-build${ndkSuffix}" failonerror="true"> <exec executable="${env.NDK_HOME}/ndk-build${ndkSuffix}" failonerror="true">
<arg value="clean"/> <arg value="clean"/>
</exec> </exec>
</target> </target>
<target name="precompile" depends="check-for-ndk"> <target name="precompile" depends="check-for-ndk">
</target> </target>
<target name="compile-natives" depends="precompile" if="has-ndk-build"> <target name="compile-natives" depends="precompile" if="has-ndk-build">
<echo>ndk_home: ${env.NDK_HOME}</echo> <echo>ndk_home: ${env.NDK_HOME}</echo>
<exec executable="${env.NDK_HOME}/ndk-build${ndkSuffix}" failonerror="true"/> <exec executable="${env.NDK_HOME}/ndk-build${ndkSuffix}" failonerror="true"/>
</target> </target>
<target name="postcompile" depends="compile-natives"> <target name="postcompile" depends="compile-natives">
</target> </target>
<target name="check-for-ndk"> <target name="check-for-ndk">
<condition property="ndk-build-found"> <condition property="ndk-build-found">
<available file="ndk-build${ndkSuffix}" filepath="${env.NDK_HOME}"/> <available file="ndk-build${ndkSuffix}" filepath="${env.NDK_HOME}"/>
</condition> </condition>
<condition property="has-ndk-build"> <condition property="has-ndk-build">
<equals arg1="${ndk-build-found}" arg2="true"/> <equals arg1="${ndk-build-found}" arg2="true"/>
</condition> </condition>
</target> </target>
</project> </project>

View File

@@ -1,24 +1,24 @@
<project name="vtm-jni-Linux-64" basedir="." default="postcompile"> <project name="vtm-jni-Linux-64" basedir="." default="postcompile">
<!-- include the environment --> <!-- include the environment -->
<property environment="env"/> <property environment="env"/>
<!-- output directory for temporary object files --> <!-- output directory for temporary object files -->
<property name="buildDir" value="target/linux64" /> <property name="buildDir" value="target/linux64" />
<!-- output directory for the shared library --> <!-- output directory for the shared library -->
<property name="libsDir" value="../libs/linux64" /> <property name="libsDir" value="../libs/linux64" />
<!-- the name of the shared library --> <!-- the name of the shared library -->
<property name="libName" value="libvtm-jni64.so"/> <property name="libName" value="libvtm-jni64.so"/>
<!-- the jni header jniPlatform to use --> <!-- the jni header jniPlatform to use -->
<property name="jniPlatform" value="linux"/> <property name="jniPlatform" value="linux"/>
<!-- the compilerPrefix for the C & C++ compilers --> <!-- the compilerPrefix for the C & C++ compilers -->
<property name="compilerPrefix" value=""/> <property name="compilerPrefix" value=""/>
<!-- the compilerSuffix for the C & C++ compilers --> <!-- the compilerSuffix for the C & C++ compilers -->
<property name="compilerSuffix" value="" /> <property name="compilerSuffix" value="" />
<!-- define gcc compiler, options and files to compile --> <!-- define gcc compiler, options and files to compile -->
<property name="gcc" value="${compilerPrefix}gcc${compilerSuffix}"/> <property name="gcc" value="${compilerPrefix}gcc${compilerSuffix}"/>
<property name="gcc-opts" value="-c -Wall -O2 -mfpmath=sse -msse -fmessage-length=0 -m64 -fPIC -Wall -std=c99 -O2 -ffast-math -DNDEBUG"/> <property name="gcc-opts" value="-c -Wall -O2 -mfpmath=sse -msse -fmessage-length=0 -m64 -fPIC -Wall -std=c99 -O2 -ffast-math -DNDEBUG"/>
<fileset id="gcc-files" dir="./"> <fileset id="gcc-files" dir="./">
<exclude name="target/"/> <exclude name="target/"/>
<include name="memcpy_wrap.c"/> <include name="memcpy_wrap.c"/>
<include name="gl/utils.c"/> <include name="gl/utils.c"/>
<include name="libtess2/Source/bucketalloc.c"/> <include name="libtess2/Source/bucketalloc.c"/>
@@ -28,126 +28,126 @@
<include name="libtess2/Source/priorityq.c"/> <include name="libtess2/Source/priorityq.c"/>
<include name="libtess2/Source/sweep.c"/> <include name="libtess2/Source/sweep.c"/>
<include name="libtess2/Source/tess.c"/> <include name="libtess2/Source/tess.c"/>
</fileset> </fileset>
<!-- define g++ compiler, options and files to compile --> <!-- define g++ compiler, options and files to compile -->
<property name="g++" value="${compilerPrefix}g++${compilerSuffix}"/> <property name="g++" value="${compilerPrefix}g++${compilerSuffix}"/>
<property name="g++-opts" value="-c -Wall -O2 -mfpmath=sse -msse -fmessage-length=0 -m64 -fPIC -Wall -std=c99 -O2 -ffast-math -DNDEBUG"/> <property name="g++-opts" value="-c -Wall -O2 -mfpmath=sse -msse -fmessage-length=0 -m64 -fPIC -Wall -std=c99 -O2 -ffast-math -DNDEBUG"/>
<fileset id="g++-files" dir="./"> <fileset id="g++-files" dir="./">
<exclude name="target/"/> <exclude name="target/"/>
<include name="**/*.cpp"/> <include name="**/*.cpp"/>
</fileset> </fileset>
<!-- define linker and options --> <!-- define linker and options -->
<property name="linker" value="${compilerPrefix}g++${compilerSuffix}"/> <property name="linker" value="${compilerPrefix}g++${compilerSuffix}"/>
<property name="linker-opts" value="-shared -m64 -Wl,-wrap,memcpy"/> <property name="linker-opts" value="-shared -m64 -Wl,-wrap,memcpy"/>
<property name="libraries" value=""/> <property name="libraries" value=""/>
<!-- cleans the build directory, removes all object files and shared libs --> <!-- cleans the build directory, removes all object files and shared libs -->
<target name="clean"> <target name="clean">
<delete includeemptydirs="true" quiet="true"> <delete includeemptydirs="true" quiet="true">
<fileset dir="${buildDir}"/> <fileset dir="${buildDir}"/>
<fileset dir="${libsDir}" includes="**/*" excludes="**/.svn"/> <fileset dir="${libsDir}" includes="**/*" excludes="**/.svn"/>
</delete> </delete>
</target> </target>
<target name="precompile"> <target name="precompile">
<condition property="compiler-found"> <condition property="compiler-found">
<and> <and>
<or> <or>
<!-- Include both b/c Windows might be either --> <!-- Include both b/c Windows might be either -->
<available file="${g++}" filepath="${env.PATH}"/> <available file="${g++}" filepath="${env.PATH}"/>
<available file="${g++}" filepath="${env.Path}"/> <available file="${g++}" filepath="${env.Path}"/>
</or> </or>
<or> <or>
<!-- Include both b/c Windows might be either --> <!-- Include both b/c Windows might be either -->
<available file="${gcc}" filepath="${env.PATH}"/> <available file="${gcc}" filepath="${env.PATH}"/>
<available file="${gcc}" filepath="${env.Path}"/> <available file="${gcc}" filepath="${env.Path}"/>
</or> </or>
</and> </and>
</condition> </condition>
<condition property="has-compiler"> <condition property="has-compiler">
<equals arg1="${compiler-found}" arg2="true"/> <equals arg1="${compiler-found}" arg2="true"/>
</condition> </condition>
</target> </target>
<target name="create-build-dir" depends="precompile" if="has-compiler"> <target name="create-build-dir" depends="precompile" if="has-compiler">
<!-- FIXME this is pretty nasty :/ --> <!-- FIXME this is pretty nasty :/ -->
<copy todir="${buildDir}"> <copy todir="${buildDir}">
<fileset refid="g++-files"/> <fileset refid="g++-files"/>
<fileset refid="gcc-files"/> <fileset refid="gcc-files"/>
</copy> </copy>
<delete> <delete>
<fileset dir="${buildDir}"> <fileset dir="${buildDir}">
<include name="*"/> <include name="*"/>
<exclude name="*.o"/> <exclude name="*.o"/>
</fileset> </fileset>
</delete> </delete>
</target> </target>
<!-- compiles all C and C++ files to object files in the build directory --> <!-- compiles all C and C++ files to object files in the build directory -->
<target name="compile" depends="create-build-dir" if="has-compiler"> <target name="compile" depends="create-build-dir" if="has-compiler">
<mkdir dir="${buildDir}"/> <mkdir dir="${buildDir}"/>
<apply failonerror="true" executable="${g++}" dest="${buildDir}" verbose="true"> <apply failonerror="true" executable="${g++}" dest="${buildDir}" verbose="true">
<arg line="${g++-opts}"/> <arg line="${g++-opts}"/>
<arg value="-Ijni-headers"/> <arg value="-Ijni-headers"/>
<arg value="-Ijni-headers/${jniPlatform}"/> <arg value="-Ijni-headers/${jniPlatform}"/>
<arg value="-I."/> <arg value="-I."/>
<arg value="-I."/> <arg value="-I."/>
<arg value="-Ilibtess2/Include"/> <arg value="-Ilibtess2/Include"/>
<srcfile/> <srcfile/>
<arg value="-o"/> <arg value="-o"/>
<targetfile/> <targetfile/>
<fileset refid="g++-files"/> <fileset refid="g++-files"/>
<compositemapper> <compositemapper>
<mapper type="glob" from="*.cpp" to="*.o"/> <mapper type="glob" from="*.cpp" to="*.o"/>
<mapper type="glob" from="*.mm" to="*.o"/> <mapper type="glob" from="*.mm" to="*.o"/>
</compositemapper> </compositemapper>
</apply> </apply>
<apply failonerror="true" executable="${gcc}" dest="${buildDir}" verbose="true"> <apply failonerror="true" executable="${gcc}" dest="${buildDir}" verbose="true">
<arg line="${gcc-opts}"/> <arg line="${gcc-opts}"/>
<arg value="-Ijni-headers"/> <arg value="-Ijni-headers"/>
<arg value="-Ijni-headers/${jniPlatform}"/> <arg value="-Ijni-headers/${jniPlatform}"/>
<arg value="-I."/> <arg value="-I."/>
<arg value="-I."/> <arg value="-I."/>
<arg value="-Ilibtess2/Include"/> <arg value="-Ilibtess2/Include"/>
<srcfile/> <srcfile/>
<arg value="-o"/> <arg value="-o"/>
<targetfile/> <targetfile/>
<fileset refid="gcc-files"/> <fileset refid="gcc-files"/>
<compositemapper> <compositemapper>
<mapper type="glob" from="*.c" to="*.o"/> <mapper type="glob" from="*.c" to="*.o"/>
<mapper type="glob" from="*.m" to="*.o"/> <mapper type="glob" from="*.m" to="*.o"/>
</compositemapper> </compositemapper>
</apply> </apply>
</target> </target>
<!-- links the shared library based on the previously compiled object files --> <!-- links the shared library based on the previously compiled object files -->
<target name="link" depends="compile" if="has-compiler"> <target name="link" depends="compile" if="has-compiler">
<fileset dir="${buildDir}" id="objFileSet"> <fileset dir="${buildDir}" id="objFileSet">
<patternset> <patternset>
<include name="**/*.o" /> <include name="**/*.o" />
</patternset> </patternset>
</fileset> </fileset>
<pathconvert pathsep=" " property="objFiles" refid="objFileSet" /> <pathconvert pathsep=" " property="objFiles" refid="objFileSet" />
<mkdir dir="${libsDir}" /> <mkdir dir="${libsDir}" />
<exec executable="${linker}" failonerror="true" dir="${buildDir}"> <exec executable="${linker}" failonerror="true" dir="${buildDir}">
<arg line="${linker-opts}" /> <arg line="${linker-opts}" />
<arg value="-o" /> <arg value="-o" />
<arg path="${libsDir}/${libName}" /> <arg path="${libsDir}/${libName}" />
<arg line="${objFiles}"/> <arg line="${objFiles}"/>
<arg line="${libraries}" /> <arg line="${libraries}" />
</exec> </exec>
</target> </target>
<target name="postcompile" depends="link"> <target name="postcompile" depends="link">
</target> </target>
</project> </project>

View File

@@ -1,73 +1,73 @@
/* /*
* Copyright 2014 Hannes Janetzek * Copyright 2014 Hannes Janetzek
* *
* This program is free software: you can redistribute it and/or modify it under the * This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software * terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version. * Foundation, either version 3 of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT ANY * This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License along with * You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>. * this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.oscim.android.test; package org.oscim.android.test;
import static org.oscim.tiling.source.bitmap.DefaultSources.STAMEN_TONER; import static org.oscim.tiling.source.bitmap.DefaultSources.STAMEN_TONER;
import org.oscim.android.MapView; import org.oscim.android.MapView;
import org.oscim.layers.TileGridLayer; import org.oscim.layers.TileGridLayer;
import org.oscim.layers.tile.bitmap.BitmapTileLayer; import org.oscim.layers.tile.bitmap.BitmapTileLayer;
import org.oscim.layers.tile.buildings.BuildingLayer; import org.oscim.layers.tile.buildings.BuildingLayer;
import org.oscim.layers.tile.vector.VectorTileLayer; import org.oscim.layers.tile.vector.VectorTileLayer;
import org.oscim.renderer.MapRenderer; import org.oscim.renderer.MapRenderer;
import org.oscim.theme.IRenderTheme; import org.oscim.theme.IRenderTheme;
import org.oscim.theme.ThemeLoader; import org.oscim.theme.ThemeLoader;
import org.oscim.theme.VtmThemes; import org.oscim.theme.VtmThemes;
import org.oscim.tiling.TileSource; import org.oscim.tiling.TileSource;
import org.oscim.tiling.source.geojson.HighroadJsonTileSource; import org.oscim.tiling.source.geojson.HighroadJsonTileSource;
import org.oscim.tiling.source.geojson.OsmBuildingJsonTileSource; import org.oscim.tiling.source.geojson.OsmBuildingJsonTileSource;
import org.oscim.tiling.source.geojson.OsmLanduseJsonTileSource; import org.oscim.tiling.source.geojson.OsmLanduseJsonTileSource;
import org.oscim.tiling.source.geojson.OsmWaterJsonTileSource; import org.oscim.tiling.source.geojson.OsmWaterJsonTileSource;
import android.os.Bundle; import android.os.Bundle;
public class OsmJsonMapActivity extends MapActivity { public class OsmJsonMapActivity extends MapActivity {
MapView mMapView; MapView mMapView;
VectorTileLayer mBaseLayer; VectorTileLayer mBaseLayer;
TileSource mTileSource; TileSource mTileSource;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
mTileSource = new OsmWaterJsonTileSource(); mTileSource = new OsmWaterJsonTileSource();
mMap.setBaseMap(new BitmapTileLayer(mMap, STAMEN_TONER.build())); mMap.setBaseMap(new BitmapTileLayer(mMap, STAMEN_TONER.build()));
mMap.layers().add(new TileGridLayer(mMap)); mMap.layers().add(new TileGridLayer(mMap));
IRenderTheme theme = ThemeLoader.load(VtmThemes.OSMARENDER); IRenderTheme theme = ThemeLoader.load(VtmThemes.OSMARENDER);
MapRenderer.setBackgroundColor(theme.getMapBackground()); MapRenderer.setBackgroundColor(theme.getMapBackground());
VectorTileLayer l; VectorTileLayer l;
l = new VectorTileLayer(mMap, new OsmLanduseJsonTileSource()); l = new VectorTileLayer(mMap, new OsmLanduseJsonTileSource());
l.setRenderTheme(theme); l.setRenderTheme(theme);
l.tileRenderer().setOverdrawColor(0); l.tileRenderer().setOverdrawColor(0);
mMap.layers().add(l); mMap.layers().add(l);
l = new VectorTileLayer(mMap, new HighroadJsonTileSource()); l = new VectorTileLayer(mMap, new HighroadJsonTileSource());
l.setRenderTheme(theme); l.setRenderTheme(theme);
l.tileRenderer().setOverdrawColor(0); l.tileRenderer().setOverdrawColor(0);
mMap.layers().add(l); mMap.layers().add(l);
l = new VectorTileLayer(mMap, new OsmBuildingJsonTileSource()); l = new VectorTileLayer(mMap, new OsmBuildingJsonTileSource());
l.setRenderTheme(theme); l.setRenderTheme(theme);
l.tileRenderer().setOverdrawColor(0); l.tileRenderer().setOverdrawColor(0);
mMap.layers().add(l); mMap.layers().add(l);
mMap.layers().add(new BuildingLayer(mMap, l)); mMap.layers().add(new BuildingLayer(mMap, l));
mMap.setMapPosition(53.08, 8.83, Math.pow(2, 16)); mMap.setMapPosition(53.08, 8.83, Math.pow(2, 16));
} }
} }

View File

@@ -1,32 +1,32 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.oscim.gdx" package="org.oscim.gdx"
android:versionCode="1" android:versionCode="1"
android:versionName="1.0" > android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-sdk <uses-sdk
android:minSdkVersion="10" android:minSdkVersion="10"
android:targetSdkVersion="22" /> android:targetSdkVersion="22" />
<application <application
android:icon="@drawable/ic_launcher" android:icon="@drawable/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:allowBackup="true" > android:allowBackup="true" >
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:label="@string/app_name" android:label="@string/app_name"
android:screenOrientation="portrait" android:screenOrientation="portrait"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"> android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
</application> </application>
</manifest> </manifest>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical" > android:orientation="vertical" >
</LinearLayout> </LinearLayout>

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="app_name">VtmGdx</string> <string name="app_name">VtmGdx</string>
</resources> </resources>

View File

@@ -1,90 +1,90 @@
/* /*
* Copyright 2013 Hannes Janetzek * Copyright 2013 Hannes Janetzek
* Copyright 2016 devemux86 * Copyright 2016 devemux86
* *
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
* *
* This program is free software: you can redistribute it and/or modify it under the * This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software * terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version. * Foundation, either version 3 of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT ANY * This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License along with * You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>. * this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.oscim.gdx; package org.oscim.gdx;
import org.oscim.awt.AwtGraphics; import org.oscim.awt.AwtGraphics;
import org.oscim.backend.GLAdapter; import org.oscim.backend.GLAdapter;
import org.oscim.core.Tile; import org.oscim.core.Tile;
import org.oscim.tiling.TileSource; import org.oscim.tiling.TileSource;
import org.oscim.tiling.source.oscimap4.OSciMap4TileSource; import org.oscim.tiling.source.oscimap4.OSciMap4TileSource;
import org.oscim.utils.FastMath; import org.oscim.utils.FastMath;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.badlogic.gdx.backends.jglfw.JglfwApplication; import com.badlogic.gdx.backends.jglfw.JglfwApplication;
import com.badlogic.gdx.backends.jglfw.JglfwApplicationConfiguration; import com.badlogic.gdx.backends.jglfw.JglfwApplicationConfiguration;
import com.badlogic.gdx.utils.SharedLibraryLoader; import com.badlogic.gdx.utils.SharedLibraryLoader;
public class GdxMapApp extends GdxMap { public class GdxMapApp extends GdxMap {
public static final Logger log = LoggerFactory.getLogger(GdxMapApp.class); public static final Logger log = LoggerFactory.getLogger(GdxMapApp.class);
public static void init() { public static void init() {
// load native library // load native library
new SharedLibraryLoader().load("vtm-jni"); new SharedLibraryLoader().load("vtm-jni");
// init globals // init globals
AwtGraphics.init(); AwtGraphics.init();
GdxAssets.init("assets/"); GdxAssets.init("assets/");
GLAdapter.init(new GdxGL()); GLAdapter.init(new GdxGL());
GLAdapter.GDX_DESKTOP_QUIRKS = true; GLAdapter.GDX_DESKTOP_QUIRKS = true;
} }
public static void main(String[] args) { public static void main(String[] args) {
Tile.SIZE = 360; Tile.SIZE = 360;
init(); init();
new JglfwApplication(new GdxMapApp(), getConfig()); new JglfwApplication(new GdxMapApp(), getConfig());
} }
public static void run(GdxMap map, JglfwApplicationConfiguration config, int tileSize) { public static void run(GdxMap map, JglfwApplicationConfiguration config, int tileSize) {
Tile.SIZE = FastMath.clamp(tileSize, 128, 512); Tile.SIZE = FastMath.clamp(tileSize, 128, 512);
new JglfwApplication(map, (config == null ? getConfig() : config)); new JglfwApplication(map, (config == null ? getConfig() : config));
} }
public static void run(JglfwApplicationConfiguration config, int tileSize, GdxMap map) { public static void run(JglfwApplicationConfiguration config, int tileSize, GdxMap map) {
run(map, config, tileSize); run(map, config, tileSize);
} }
static protected JglfwApplicationConfiguration getConfig() { static protected JglfwApplicationConfiguration getConfig() {
JglfwApplicationConfiguration cfg = new JglfwApplicationConfiguration(); JglfwApplicationConfiguration cfg = new JglfwApplicationConfiguration();
cfg.title = "vtm-gdx"; cfg.title = "vtm-gdx";
cfg.width = 800; cfg.width = 800;
cfg.height = 600; cfg.height = 600;
cfg.stencil = 8; cfg.stencil = 8;
//cfg.samples = 2; //cfg.samples = 2;
cfg.foregroundFPS = 30; cfg.foregroundFPS = 30;
cfg.backgroundFPS = 10; cfg.backgroundFPS = 10;
return cfg; return cfg;
} }
@Override @Override
public void createLayers() { public void createLayers() {
TileSource tileSource = new OSciMap4TileSource(); TileSource tileSource = new OSciMap4TileSource();
// TileSource tileSource = new MapFileTileSource(); // TileSource tileSource = new MapFileTileSource();
// tileSource.setOption("file", "/home/jeff/germany.map"); // tileSource.setOption("file", "/home/jeff/germany.map");
initDefaultLayers(tileSource, false, true, true); initDefaultLayers(tileSource, false, true, true);
//mMap.getLayers().add(new BitmapTileLayer(mMap, new ImagicoLandcover(), 20)); //mMap.getLayers().add(new BitmapTileLayer(mMap, new ImagicoLandcover(), 20));
//mMap.getLayers().add(new BitmapTileLayer(mMap, new OSMTileSource(), 20)); //mMap.getLayers().add(new BitmapTileLayer(mMap, new OSMTileSource(), 20));
//mMap.getLayers().add(new BitmapTileLayer(mMap, new ArcGISWorldShaded(), 20)); //mMap.getLayers().add(new BitmapTileLayer(mMap, new ArcGISWorldShaded(), 20));
mMap.setMapPosition(0, 0, 1 << 2); mMap.setMapPosition(0, 0, 1 << 2);
} }
} }

View File

@@ -1,350 +1,350 @@
/* /*
* Copyright 2014 Hannes Janetzek * Copyright 2014 Hannes Janetzek
* *
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
* *
* This program is free software: you can redistribute it and/or modify it under the * This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software * terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version. * Foundation, either version 3 of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT ANY * This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License along with * You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>. * this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.oscim.tiling.source.geojson; package org.oscim.tiling.source.geojson;
import static com.fasterxml.jackson.core.JsonToken.END_ARRAY; import static com.fasterxml.jackson.core.JsonToken.END_ARRAY;
import static com.fasterxml.jackson.core.JsonToken.END_OBJECT; import static com.fasterxml.jackson.core.JsonToken.END_OBJECT;
import static com.fasterxml.jackson.core.JsonToken.FIELD_NAME; import static com.fasterxml.jackson.core.JsonToken.FIELD_NAME;
import static com.fasterxml.jackson.core.JsonToken.START_ARRAY; import static com.fasterxml.jackson.core.JsonToken.START_ARRAY;
import static com.fasterxml.jackson.core.JsonToken.START_OBJECT; import static com.fasterxml.jackson.core.JsonToken.START_OBJECT;
import static com.fasterxml.jackson.core.JsonToken.VALUE_NUMBER_FLOAT; import static com.fasterxml.jackson.core.JsonToken.VALUE_NUMBER_FLOAT;
import static com.fasterxml.jackson.core.JsonToken.VALUE_NUMBER_INT; import static com.fasterxml.jackson.core.JsonToken.VALUE_NUMBER_INT;
import static com.fasterxml.jackson.core.JsonToken.VALUE_STRING; import static com.fasterxml.jackson.core.JsonToken.VALUE_STRING;
import static org.oscim.core.MercatorProjection.latitudeToY; import static org.oscim.core.MercatorProjection.latitudeToY;
import static org.oscim.core.MercatorProjection.longitudeToX; import static org.oscim.core.MercatorProjection.longitudeToX;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import org.oscim.core.GeometryBuffer.GeometryType; import org.oscim.core.GeometryBuffer.GeometryType;
import org.oscim.core.MapElement; import org.oscim.core.MapElement;
import org.oscim.core.Tile; import org.oscim.core.Tile;
import org.oscim.tiling.ITileDataSink; import org.oscim.tiling.ITileDataSink;
import org.oscim.tiling.source.ITileDecoder; import org.oscim.tiling.source.ITileDecoder;
import org.oscim.utils.ArrayUtils; import org.oscim.utils.ArrayUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.core.JsonToken;
public class GeoJsonTileDecoder implements ITileDecoder { public class GeoJsonTileDecoder implements ITileDecoder {
static final Logger log = LoggerFactory.getLogger(GeoJsonTileDecoder.class); static final Logger log = LoggerFactory.getLogger(GeoJsonTileDecoder.class);
private final MapElement mMapElement; private final MapElement mMapElement;
private final GeoJsonTileSource mTileSource; private final GeoJsonTileSource mTileSource;
private final LinkedHashMap<String, Object> mTagMap; private final LinkedHashMap<String, Object> mTagMap;
private final JsonFactory mJsonFactory; private final JsonFactory mJsonFactory;
private final static char[] FIELD_FEATURES = "features".toCharArray(); private final static char[] FIELD_FEATURES = "features".toCharArray();
private final static char[] FIELD_GEOMETRY = "geometry".toCharArray(); private final static char[] FIELD_GEOMETRY = "geometry".toCharArray();
private final static char[] FIELD_PROPERTIES = "properties".toCharArray(); private final static char[] FIELD_PROPERTIES = "properties".toCharArray();
private final static char[] FIELD_COORDINATES = "coordinates".toCharArray(); private final static char[] FIELD_COORDINATES = "coordinates".toCharArray();
private final static char[] FIELD_TYPE = "type".toCharArray(); private final static char[] FIELD_TYPE = "type".toCharArray();
private final static char[] LINETRING = "LineString".toCharArray(); private final static char[] LINETRING = "LineString".toCharArray();
private final static char[] POLYGON = "Polygon".toCharArray(); private final static char[] POLYGON = "Polygon".toCharArray();
private final static char[] POINT = "Point".toCharArray(); private final static char[] POINT = "Point".toCharArray();
private final static char[] MULTI_LINESTRING = "MultiLineString".toCharArray(); private final static char[] MULTI_LINESTRING = "MultiLineString".toCharArray();
private final static char[] MULTI_POLYGON = "MultiPolygon".toCharArray(); private final static char[] MULTI_POLYGON = "MultiPolygon".toCharArray();
private final static char[] MULTI_POINT = "MultiPoint".toCharArray(); private final static char[] MULTI_POINT = "MultiPoint".toCharArray();
private ITileDataSink mTileDataSink; private ITileDataSink mTileDataSink;
private double mTileY, mTileX, mTileScale; private double mTileY, mTileX, mTileScale;
public GeoJsonTileDecoder(GeoJsonTileSource tileSource) { public GeoJsonTileDecoder(GeoJsonTileSource tileSource) {
mTileSource = tileSource; mTileSource = tileSource;
mTagMap = new LinkedHashMap<String, Object>(); mTagMap = new LinkedHashMap<String, Object>();
mJsonFactory = new JsonFactory(); mJsonFactory = new JsonFactory();
mMapElement = new MapElement(); mMapElement = new MapElement();
mMapElement.layer = 5; mMapElement.layer = 5;
} }
@Override @Override
public boolean decode(Tile tile, ITileDataSink sink, InputStream is) throws IOException { public boolean decode(Tile tile, ITileDataSink sink, InputStream is) throws IOException {
mTileDataSink = sink; mTileDataSink = sink;
mTileScale = 1 << tile.zoomLevel; mTileScale = 1 << tile.zoomLevel;
mTileX = tile.tileX / mTileScale; mTileX = tile.tileX / mTileScale;
mTileY = tile.tileY / mTileScale; mTileY = tile.tileY / mTileScale;
mTileScale *= Tile.SIZE; mTileScale *= Tile.SIZE;
JsonParser jp = mJsonFactory.createParser(new InputStreamReader(is)); JsonParser jp = mJsonFactory.createParser(new InputStreamReader(is));
for (JsonToken t; (t = jp.nextToken()) != null;) { for (JsonToken t; (t = jp.nextToken()) != null;) {
if (t == FIELD_NAME) { if (t == FIELD_NAME) {
if (match(jp, FIELD_FEATURES)) { if (match(jp, FIELD_FEATURES)) {
if (jp.nextToken() != START_ARRAY) if (jp.nextToken() != START_ARRAY)
continue; continue;
while ((t = jp.nextToken()) != null) { while ((t = jp.nextToken()) != null) {
if (t == START_OBJECT) if (t == START_OBJECT)
parseFeature(jp); parseFeature(jp);
if (t == END_ARRAY) if (t == END_ARRAY)
break; break;
} }
} }
} }
} }
return true; return true;
} }
private void parseFeature(JsonParser jp) private void parseFeature(JsonParser jp)
throws JsonParseException, IOException { throws JsonParseException, IOException {
mMapElement.clear(); mMapElement.clear();
mMapElement.tags.clear(); mMapElement.tags.clear();
mTagMap.clear(); mTagMap.clear();
for (JsonToken t; (t = jp.nextToken()) != null;) { for (JsonToken t; (t = jp.nextToken()) != null;) {
if (t == FIELD_NAME) { if (t == FIELD_NAME) {
if (match(jp, FIELD_GEOMETRY)) { if (match(jp, FIELD_GEOMETRY)) {
if (jp.nextToken() == START_OBJECT) if (jp.nextToken() == START_OBJECT)
parseGeometry(jp); parseGeometry(jp);
} }
if (match(jp, FIELD_PROPERTIES)) { if (match(jp, FIELD_PROPERTIES)) {
if (jp.nextToken() == START_OBJECT) if (jp.nextToken() == START_OBJECT)
parseProperties(jp); parseProperties(jp);
} }
continue; continue;
} }
if (t == END_OBJECT) if (t == END_OBJECT)
break; break;
} }
//add tag information //add tag information
mTileSource.decodeTags(mMapElement, mTagMap); mTileSource.decodeTags(mMapElement, mTagMap);
if (mMapElement.tags.numTags == 0) if (mMapElement.tags.numTags == 0)
return; return;
mTileSource.postGeomHook(mMapElement); mTileSource.postGeomHook(mMapElement);
if (mMapElement.type == GeometryType.NONE) if (mMapElement.type == GeometryType.NONE)
return; return;
//process this element //process this element
mTileDataSink.process(mMapElement); mTileDataSink.process(mMapElement);
} }
private void parseProperties(JsonParser jp) private void parseProperties(JsonParser jp)
throws JsonParseException, IOException { throws JsonParseException, IOException {
for (JsonToken t; (t = jp.nextToken()) != null;) { for (JsonToken t; (t = jp.nextToken()) != null;) {
if (t == FIELD_NAME) { if (t == FIELD_NAME) {
String text = jp.getCurrentName(); String text = jp.getCurrentName();
t = jp.nextToken(); t = jp.nextToken();
if (t == VALUE_STRING) { if (t == VALUE_STRING) {
mTagMap.put(text, jp.getText()); mTagMap.put(text, jp.getText());
} else if (t == VALUE_NUMBER_INT) { } else if (t == VALUE_NUMBER_INT) {
mTagMap.put(text, jp.getNumberValue()); mTagMap.put(text, jp.getNumberValue());
} }
continue; continue;
} }
if (t == END_OBJECT) if (t == END_OBJECT)
break; break;
} }
} }
private void parseGeometry(JsonParser jp) private void parseGeometry(JsonParser jp)
throws JsonParseException, IOException { throws JsonParseException, IOException {
boolean multi = false; boolean multi = false;
GeometryType type = GeometryType.NONE; GeometryType type = GeometryType.NONE;
for (JsonToken t; (t = jp.nextToken()) != null;) { for (JsonToken t; (t = jp.nextToken()) != null;) {
if (t == FIELD_NAME) { if (t == FIELD_NAME) {
if (match(jp, FIELD_COORDINATES)) { if (match(jp, FIELD_COORDINATES)) {
if (jp.nextToken() != START_ARRAY) if (jp.nextToken() != START_ARRAY)
continue; continue;
if (multi) { if (multi) {
parseMulti(jp, type); parseMulti(jp, type);
} else { } else {
if (type == GeometryType.POLY) if (type == GeometryType.POLY)
parsePolygon(jp); parsePolygon(jp);
if (type == GeometryType.LINE) if (type == GeometryType.LINE)
parseLineString(jp); parseLineString(jp);
if (type == GeometryType.POINT) if (type == GeometryType.POINT)
parseCoordinate(jp); parseCoordinate(jp);
} }
} else if (match(jp, FIELD_TYPE)) { } else if (match(jp, FIELD_TYPE)) {
multi = false; multi = false;
jp.nextToken(); jp.nextToken();
if (match(jp, LINETRING)) if (match(jp, LINETRING))
type = GeometryType.LINE; type = GeometryType.LINE;
else if (match(jp, POLYGON)) else if (match(jp, POLYGON))
type = GeometryType.POLY; type = GeometryType.POLY;
else if (match(jp, POINT)) else if (match(jp, POINT))
type = GeometryType.POINT; type = GeometryType.POINT;
else if (match(jp, MULTI_LINESTRING)) { else if (match(jp, MULTI_LINESTRING)) {
type = GeometryType.LINE; type = GeometryType.LINE;
multi = true; multi = true;
} }
else if (match(jp, MULTI_POLYGON)) { else if (match(jp, MULTI_POLYGON)) {
type = GeometryType.POLY; type = GeometryType.POLY;
multi = true; multi = true;
} }
else if (match(jp, MULTI_POINT)) { else if (match(jp, MULTI_POINT)) {
type = GeometryType.POINT; type = GeometryType.POINT;
multi = true; multi = true;
} }
if (type == GeometryType.POINT) if (type == GeometryType.POINT)
mMapElement.startPoints(); mMapElement.startPoints();
} }
continue; continue;
} }
if (t == END_OBJECT) if (t == END_OBJECT)
break; break;
} }
} }
private void parseMulti(JsonParser jp, GeometryType type) private void parseMulti(JsonParser jp, GeometryType type)
throws JsonParseException, IOException { throws JsonParseException, IOException {
for (JsonToken t; (t = jp.nextToken()) != null;) { for (JsonToken t; (t = jp.nextToken()) != null;) {
if (t == END_ARRAY) if (t == END_ARRAY)
break; break;
if (t == START_ARRAY) { if (t == START_ARRAY) {
if (type == GeometryType.POLY) if (type == GeometryType.POLY)
parsePolygon(jp); parsePolygon(jp);
else if (type == GeometryType.LINE) else if (type == GeometryType.LINE)
parseLineString(jp); parseLineString(jp);
else if (type == GeometryType.POINT) else if (type == GeometryType.POINT)
parseCoordinate(jp);; parseCoordinate(jp);;
} else { } else {
//.... //....
} }
} }
} }
private void parsePolygon(JsonParser jp) private void parsePolygon(JsonParser jp)
throws JsonParseException, IOException { throws JsonParseException, IOException {
int ring = 0; int ring = 0;
for (JsonToken t; (t = jp.nextToken()) != null;) { for (JsonToken t; (t = jp.nextToken()) != null;) {
if (t == START_ARRAY) { if (t == START_ARRAY) {
if (ring == 0) if (ring == 0)
mMapElement.startPolygon(); mMapElement.startPolygon();
else else
mMapElement.startHole(); mMapElement.startHole();
ring++; ring++;
parseCoordSequence(jp); parseCoordSequence(jp);
removeLastPoint(); removeLastPoint();
continue; continue;
} }
if (t == END_ARRAY) if (t == END_ARRAY)
break; break;
} }
} }
private void removeLastPoint() { private void removeLastPoint() {
mMapElement.pointPos -= 2; mMapElement.pointPos -= 2;
mMapElement.index[mMapElement.indexPos] -= 2; mMapElement.index[mMapElement.indexPos] -= 2;
} }
private void parseLineString(JsonParser jp) private void parseLineString(JsonParser jp)
throws JsonParseException, IOException { throws JsonParseException, IOException {
mMapElement.startLine(); mMapElement.startLine();
parseCoordSequence(jp); parseCoordSequence(jp);
} }
private void parseCoordSequence(JsonParser jp) private void parseCoordSequence(JsonParser jp)
throws JsonParseException, IOException { throws JsonParseException, IOException {
for (JsonToken t; (t = jp.nextToken()) != null;) { for (JsonToken t; (t = jp.nextToken()) != null;) {
if (t == START_ARRAY) { if (t == START_ARRAY) {
parseCoordinate(jp); parseCoordinate(jp);
continue; continue;
} }
if (t == END_ARRAY) if (t == END_ARRAY)
break; break;
} }
} }
private void parseCoordinate(JsonParser jp) private void parseCoordinate(JsonParser jp)
throws JsonParseException, IOException { throws JsonParseException, IOException {
int pos = 0; int pos = 0;
double x = 0, y = 0; //, z = 0; double x = 0, y = 0; //, z = 0;
for (JsonToken t; (t = jp.nextToken()) != null;) { for (JsonToken t; (t = jp.nextToken()) != null;) {
if (t == VALUE_NUMBER_FLOAT || t == VALUE_NUMBER_INT) { if (t == VALUE_NUMBER_FLOAT || t == VALUE_NUMBER_INT) {
// avoid String allocation (by getDouble...) // avoid String allocation (by getDouble...)
char[] val = jp.getTextCharacters(); char[] val = jp.getTextCharacters();
int offset = jp.getTextOffset(); int offset = jp.getTextOffset();
int length = jp.getTextLength(); int length = jp.getTextLength();
double c = ArrayUtils.parseNumber(val, offset, offset + length); double c = ArrayUtils.parseNumber(val, offset, offset + length);
if (pos == 0) if (pos == 0)
x = c; x = c;
if (pos == 1) if (pos == 1)
y = c; y = c;
//if (pos == 2) //if (pos == 2)
//z = c; //z = c;
pos++; pos++;
continue; continue;
} }
if (t == END_ARRAY) if (t == END_ARRAY)
break; break;
} }
mMapElement.addPoint((float) ((longitudeToX(x) - mTileX) * mTileScale), mMapElement.addPoint((float) ((longitudeToX(x) - mTileX) * mTileScale),
(float) ((latitudeToY(y) - mTileY) * mTileScale)); (float) ((latitudeToY(y) - mTileY) * mTileScale));
} }
private final static boolean match(JsonParser jp, char[] fieldName) private final static boolean match(JsonParser jp, char[] fieldName)
throws JsonParseException, IOException { throws JsonParseException, IOException {
int length = jp.getTextLength(); int length = jp.getTextLength();
if (length != fieldName.length) if (length != fieldName.length)
return false; return false;
char[] val = jp.getTextCharacters(); char[] val = jp.getTextCharacters();
int offset = jp.getTextOffset(); int offset = jp.getTextOffset();
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
if (fieldName[i] != val[i + offset]) if (fieldName[i] != val[i + offset])
return false; return false;
} }
return true; return true;
} }
} }

View File

@@ -1,71 +1,71 @@
/* /*
* Copyright 2014 Hannes Janetzek * Copyright 2014 Hannes Janetzek
* *
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
* *
* This program is free software: you can redistribute it and/or modify it under the * This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software * terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version. * Foundation, either version 3 of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT ANY * This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License along with * You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>. * this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.oscim.tiling.source.geojson; package org.oscim.tiling.source.geojson;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.oscim.core.MapElement; import org.oscim.core.MapElement;
import org.oscim.core.Tag; import org.oscim.core.Tag;
import org.oscim.tiling.ITileDataSource; import org.oscim.tiling.ITileDataSource;
import org.oscim.tiling.source.UrlTileDataSource; import org.oscim.tiling.source.UrlTileDataSource;
import org.oscim.tiling.source.UrlTileSource; import org.oscim.tiling.source.UrlTileSource;
public abstract class GeoJsonTileSource extends UrlTileSource { public abstract class GeoJsonTileSource extends UrlTileSource {
public GeoJsonTileSource(String url) { public GeoJsonTileSource(String url) {
super(url, "/{Z}/{X}/{Y}.json"); super(url, "/{Z}/{X}/{Y}.json");
Map<String, String> opt = new HashMap<String, String>(); Map<String, String> opt = new HashMap<String, String>();
opt.put("Accept-Encoding", "gzip"); opt.put("Accept-Encoding", "gzip");
setHttpRequestHeaders(opt); setHttpRequestHeaders(opt);
} }
public GeoJsonTileSource(String url, int zoomMin, int zoomMax) { public GeoJsonTileSource(String url, int zoomMin, int zoomMax) {
super(url, "/{Z}/{X}/{Y}.json", zoomMin, zoomMax); super(url, "/{Z}/{X}/{Y}.json", zoomMin, zoomMax);
Map<String, String> opt = new HashMap<String, String>(); Map<String, String> opt = new HashMap<String, String>();
opt.put("Accept-Encoding", "gzip"); opt.put("Accept-Encoding", "gzip");
setHttpRequestHeaders(opt); setHttpRequestHeaders(opt);
} }
@Override @Override
public ITileDataSource getDataSource() { public ITileDataSource getDataSource() {
return new UrlTileDataSource(this, new GeoJsonTileDecoder(this), getHttpEngine()); return new UrlTileDataSource(this, new GeoJsonTileDecoder(this), getHttpEngine());
} }
public Tag getFeatureTag() { public Tag getFeatureTag() {
return null; return null;
} }
/** allow overriding tag handling */ /** allow overriding tag handling */
public abstract void decodeTags(MapElement mapElement, Map<String, Object> properties); public abstract void decodeTags(MapElement mapElement, Map<String, Object> properties);
public Tag rewriteTag(String key, Object value) { public Tag rewriteTag(String key, Object value) {
if (value == null) if (value == null)
return null; return null;
String val = (value instanceof String) ? (String) value : String.valueOf(value); String val = (value instanceof String) ? (String) value : String.valueOf(value);
return new Tag(key, val); return new Tag(key, val);
} }
/** modify mapElement before process() */ /** modify mapElement before process() */
public void postGeomHook(MapElement mapElement) { public void postGeomHook(MapElement mapElement) {
} }
} }

View File

@@ -1,366 +1,366 @@
package org.oscim.utils; package org.oscim.utils;
import java.util.ArrayList; import java.util.ArrayList;
/** /**
* Triangulates a polygon into triangles - duh. Doesn't handle * Triangulates a polygon into triangles - duh. Doesn't handle
* holes in polys * holes in polys
* *
* @author Public Source from FlipCode * @author Public Source from FlipCode
*/ */
public class Triangulator { public class Triangulator {
/** The accepted error value */ /** The accepted error value */
private static final float EPSILON = 0.0000000001f; private static final float EPSILON = 0.0000000001f;
/** The list of points to be triangulated */ /** The list of points to be triangulated */
private final PointList poly = new PointList(); private final PointList poly = new PointList();
/** The list of points describing the triangles */ /** The list of points describing the triangles */
private final PointList tris = new PointList(); private final PointList tris = new PointList();
/** True if we've tried to triangulate */ /** True if we've tried to triangulate */
private boolean tried; private boolean tried;
/** /**
* Create a new triangulator * Create a new triangulator
*/ */
public Triangulator() { public Triangulator() {
} }
/** /**
* Add a point describing the polygon to be triangulated * Add a point describing the polygon to be triangulated
* *
* @param x The x coordinate of the point * @param x The x coordinate of the point
* @param y the y coordinate of the point * @param y the y coordinate of the point
*/ */
public void addPolyPoint(float x, float y) { public void addPolyPoint(float x, float y) {
poly.add(new Point(x, y)); poly.add(new Point(x, y));
} }
/** /**
* Cause the triangulator to split the polygon * Cause the triangulator to split the polygon
* *
* @return True if we managed the task * @return True if we managed the task
*/ */
public boolean triangulate() { public boolean triangulate() {
tried = true; tried = true;
boolean worked = process(poly, tris); boolean worked = process(poly, tris);
return worked; return worked;
} }
/** /**
* Get a count of the number of triangles produced * Get a count of the number of triangles produced
* *
* @return The number of triangles produced * @return The number of triangles produced
*/ */
public int getTriangleCount() { public int getTriangleCount() {
if (!tried) { if (!tried) {
throw new RuntimeException("Call triangulate() before accessing triangles"); throw new RuntimeException("Call triangulate() before accessing triangles");
} }
return tris.size() / 3; return tris.size() / 3;
} }
/** /**
* Get a point on a specified generated triangle * Get a point on a specified generated triangle
* *
* @param tri The index of the triangle to interegate * @param tri The index of the triangle to interegate
* @param i The index of the point within the triangle to retrieve * @param i The index of the point within the triangle to retrieve
* (0 - 2) * (0 - 2)
* @return The x,y coordinate pair for the point * @return The x,y coordinate pair for the point
*/ */
public float[] getTrianglePoint(int tri, int i) { public float[] getTrianglePoint(int tri, int i) {
if (!tried) { if (!tried) {
throw new RuntimeException("Call triangulate() before accessing triangles"); throw new RuntimeException("Call triangulate() before accessing triangles");
} }
return tris.get((tri * 3) + i).toArray(); return tris.get((tri * 3) + i).toArray();
} }
/** /**
* Find the area of a polygon defined by the series of points * Find the area of a polygon defined by the series of points
* in the list * in the list
* *
* @param contour The list of points defined the contour of the polygon * @param contour The list of points defined the contour of the polygon
* (Vector2f) * (Vector2f)
* @return The area of the polygon defined * @return The area of the polygon defined
*/ */
private static float area(PointList contour) { private static float area(PointList contour) {
int n = contour.size(); int n = contour.size();
float A = 0.0f; float A = 0.0f;
for (int p = n - 1, q = 0; q < n; p = q++) { for (int p = n - 1, q = 0; q < n; p = q++) {
Point contourP = contour.get(p); Point contourP = contour.get(p);
Point contourQ = contour.get(q); Point contourQ = contour.get(q);
A += contourP.getX() * contourQ.getY() - contourQ.getX() A += contourP.getX() * contourQ.getY() - contourQ.getX()
* contourP.getY(); * contourP.getY();
} }
return A * 0.5f; return A * 0.5f;
} }
/** /**
* Check if the point P is inside the triangle defined by * Check if the point P is inside the triangle defined by
* the points A,B,C * the points A,B,C
* *
* @param Ax Point A x-coordinate * @param Ax Point A x-coordinate
* @param Ay Point A y-coordinate * @param Ay Point A y-coordinate
* @param Bx Point B x-coordinate * @param Bx Point B x-coordinate
* @param By Point B y-coordinate * @param By Point B y-coordinate
* @param Cx Point C x-coordinate * @param Cx Point C x-coordinate
* @param Cy Point C y-coordinate * @param Cy Point C y-coordinate
* @param Px Point P x-coordinate * @param Px Point P x-coordinate
* @param Py Point P y-coordinate * @param Py Point P y-coordinate
* @return True if the point specified is within the triangle * @return True if the point specified is within the triangle
*/ */
private static boolean insideTriangle(float Ax, float Ay, float Bx, private static boolean insideTriangle(float Ax, float Ay, float Bx,
float By, float Cx, float Cy, float Px, float Py) { float By, float Cx, float Cy, float Px, float Py) {
float ax, ay, bx, by, cx, cy, apx, apy, bpx, bpy, cpx, cpy; float ax, ay, bx, by, cx, cy, apx, apy, bpx, bpy, cpx, cpy;
float cCROSSap, bCROSScp, aCROSSbp; float cCROSSap, bCROSScp, aCROSSbp;
ax = Cx - Bx; ax = Cx - Bx;
ay = Cy - By; ay = Cy - By;
bx = Ax - Cx; bx = Ax - Cx;
by = Ay - Cy; by = Ay - Cy;
cx = Bx - Ax; cx = Bx - Ax;
cy = By - Ay; cy = By - Ay;
apx = Px - Ax; apx = Px - Ax;
apy = Py - Ay; apy = Py - Ay;
bpx = Px - Bx; bpx = Px - Bx;
bpy = Py - By; bpy = Py - By;
cpx = Px - Cx; cpx = Px - Cx;
cpy = Py - Cy; cpy = Py - Cy;
aCROSSbp = ax * bpy - ay * bpx; aCROSSbp = ax * bpy - ay * bpx;
cCROSSap = cx * apy - cy * apx; cCROSSap = cx * apy - cy * apx;
bCROSScp = bx * cpy - by * cpx; bCROSScp = bx * cpy - by * cpx;
return ((aCROSSbp >= 0.0f) && (bCROSScp >= 0.0f) && (cCROSSap >= 0.0f)); return ((aCROSSbp >= 0.0f) && (bCROSScp >= 0.0f) && (cCROSSap >= 0.0f));
} }
/** /**
* Cut a the contour and add a triangle into V to describe the * Cut a the contour and add a triangle into V to describe the
* location of the cut * location of the cut
* *
* @param contour The list of points defining the polygon * @param contour The list of points defining the polygon
* @param u The index of the first point * @param u The index of the first point
* @param v The index of the second point * @param v The index of the second point
* @param w The index of the third point * @param w The index of the third point
* @param n ? * @param n ?
* @param V The array to populate with indicies of triangles * @param V The array to populate with indicies of triangles
* @return True if a triangle was found * @return True if a triangle was found
*/ */
private static boolean snip(PointList contour, int u, int v, int w, int n, private static boolean snip(PointList contour, int u, int v, int w, int n,
int[] V) { int[] V) {
int p; int p;
float Ax, Ay, Bx, By, Cx, Cy, Px, Py; float Ax, Ay, Bx, By, Cx, Cy, Px, Py;
Ax = contour.get(V[u]).getX(); Ax = contour.get(V[u]).getX();
Ay = contour.get(V[u]).getY(); Ay = contour.get(V[u]).getY();
Bx = contour.get(V[v]).getX(); Bx = contour.get(V[v]).getX();
By = contour.get(V[v]).getY(); By = contour.get(V[v]).getY();
Cx = contour.get(V[w]).getX(); Cx = contour.get(V[w]).getX();
Cy = contour.get(V[w]).getY(); Cy = contour.get(V[w]).getY();
if (EPSILON > (((Bx - Ax) * (Cy - Ay)) - ((By - Ay) * (Cx - Ax)))) { if (EPSILON > (((Bx - Ax) * (Cy - Ay)) - ((By - Ay) * (Cx - Ax)))) {
return false; return false;
} }
for (p = 0; p < n; p++) { for (p = 0; p < n; p++) {
if ((p == u) || (p == v) || (p == w)) { if ((p == u) || (p == v) || (p == w)) {
continue; continue;
} }
Px = contour.get(V[p]).getX(); Px = contour.get(V[p]).getX();
Py = contour.get(V[p]).getY(); Py = contour.get(V[p]).getY();
if (insideTriangle(Ax, Ay, Bx, By, Cx, Cy, Px, Py)) { if (insideTriangle(Ax, Ay, Bx, By, Cx, Cy, Px, Py)) {
return false; return false;
} }
} }
return true; return true;
} }
/** /**
* Process a list of points defining a polygon * Process a list of points defining a polygon
* *
* @param contour The list of points describing the polygon * @param contour The list of points describing the polygon
* @param result The list of points describing the triangles. Groups * @param result The list of points describing the triangles. Groups
* of 3 describe each triangle * of 3 describe each triangle
* @return True if we succeeded in completing triangulation * @return True if we succeeded in completing triangulation
*/ */
private static boolean process(PointList contour, PointList result) { private static boolean process(PointList contour, PointList result) {
/* allocate and initialize list of Vertices in polygon */ /* allocate and initialize list of Vertices in polygon */
int n = contour.size(); int n = contour.size();
if (n < 3) if (n < 3)
return false; return false;
int[] V = new int[n]; int[] V = new int[n];
/* we want a counter-clockwise polygon in V */ /* we want a counter-clockwise polygon in V */
if (0.0f < area(contour)) { if (0.0f < area(contour)) {
for (int v = 0; v < n; v++) for (int v = 0; v < n; v++)
V[v] = v; V[v] = v;
} else { } else {
for (int v = 0; v < n; v++) for (int v = 0; v < n; v++)
V[v] = (n - 1) - v; V[v] = (n - 1) - v;
} }
int nv = n; int nv = n;
/* remove nv-2 Vertices, creating 1 triangle every time */ /* remove nv-2 Vertices, creating 1 triangle every time */
int count = 2 * nv; /* error detection */ int count = 2 * nv; /* error detection */
//for (int m = 0, v = nv - 1; nv > 2;) { //for (int m = 0, v = nv - 1; nv > 2;) {
for (int v = nv - 1; nv > 2;) { for (int v = nv - 1; nv > 2;) {
/* if we loop, it is probably a non-simple polygon */ /* if we loop, it is probably a non-simple polygon */
if (0 >= (count--)) { if (0 >= (count--)) {
//** Triangulate: ERROR - probable bad polygon! //** Triangulate: ERROR - probable bad polygon!
return false; return false;
} }
/* three consecutive vertices in current polygon, <u,v,w> */ /* three consecutive vertices in current polygon, <u,v,w> */
int u = v; int u = v;
if (nv <= u) if (nv <= u)
u = 0; /* previous */ u = 0; /* previous */
v = u + 1; v = u + 1;
if (nv <= v) if (nv <= v)
v = 0; /* new v */ v = 0; /* new v */
int w = v + 1; int w = v + 1;
if (nv <= w) if (nv <= w)
w = 0; /* next */ w = 0; /* next */
if (snip(contour, u, v, w, nv, V)) { if (snip(contour, u, v, w, nv, V)) {
int a, b, c, s, t; int a, b, c, s, t;
/* true names of the vertices */ /* true names of the vertices */
a = V[u]; a = V[u];
b = V[v]; b = V[v];
c = V[w]; c = V[w];
/* output Triangle */ /* output Triangle */
result.add(contour.get(a)); result.add(contour.get(a));
result.add(contour.get(b)); result.add(contour.get(b));
result.add(contour.get(c)); result.add(contour.get(c));
//m++; //m++;
/* remove v from remaining polygon */ /* remove v from remaining polygon */
for (s = v, t = v + 1; t < nv; s++, t++) { for (s = v, t = v + 1; t < nv; s++, t++) {
V[s] = V[t]; V[s] = V[t];
} }
nv--; nv--;
/* resest error detection counter */ /* resest error detection counter */
count = 2 * nv; count = 2 * nv;
} }
} }
return true; return true;
} }
/** /**
* A single point handled by the triangulator * A single point handled by the triangulator
* *
* @author Kevin Glass * @author Kevin Glass
*/ */
private class Point { private class Point {
/** The x coorindate of this point */ /** The x coorindate of this point */
private final float x; private final float x;
/** The y coorindate of this point */ /** The y coorindate of this point */
private final float y; private final float y;
/** /**
* Create a new point * Create a new point
* *
* @param x The x coordindate of the point * @param x The x coordindate of the point
* @param y The y coordindate of the point * @param y The y coordindate of the point
*/ */
public Point(float x, float y) { public Point(float x, float y) {
this.x = x; this.x = x;
this.y = y; this.y = y;
} }
/** /**
* Get the x coordinate of the point * Get the x coordinate of the point
* *
* @return The x coordinate of the point * @return The x coordinate of the point
*/ */
public float getX() { public float getX() {
return x; return x;
} }
/** /**
* Get the y coordinate of the point * Get the y coordinate of the point
* *
* @return The y coordinate of the point * @return The y coordinate of the point
*/ */
public float getY() { public float getY() {
return y; return y;
} }
/** /**
* Convert this point into a float array * Convert this point into a float array
* *
* @return The contents of this point as a float array * @return The contents of this point as a float array
*/ */
public float[] toArray() { public float[] toArray() {
return new float[] { x, y }; return new float[] { x, y };
} }
} }
/** /**
* A list of type <code>Point</code> * A list of type <code>Point</code>
* *
* @author Kevin Glass * @author Kevin Glass
*/ */
private class PointList { private class PointList {
/** The list of points */ /** The list of points */
private final ArrayList<Point> points = new ArrayList<Point>(); private final ArrayList<Point> points = new ArrayList<Point>();
/** /**
* Create a new empty list * Create a new empty list
*/ */
public PointList() { public PointList() {
} }
/** /**
* Add a point to the list * Add a point to the list
* *
* @param point The point to add * @param point The point to add
*/ */
public void add(Point point) { public void add(Point point) {
points.add(point); points.add(point);
} }
///** ///**
// * Remove a point from the list // * Remove a point from the list
// * // *
// * @param point The point to remove // * @param point The point to remove
// */ // */
//public void remove(Point point) { //public void remove(Point point) {
// points.remove(point); // points.remove(point);
//} //}
/** /**
* Get the size of the list * Get the size of the list
* *
* @return The size of the list * @return The size of the list
*/ */
public int size() { public int size() {
return points.size(); return points.size();
} }
/** /**
* Get a point a specific index in the list * Get a point a specific index in the list
* *
* @param i The index of the point to retrieve * @param i The index of the point to retrieve
* @return The point * @return The point
*/ */
public Point get(int i) { public Point get(int i) {
return points.get(i); return points.get(i);
} }
} }
} }

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN" "http://google-web-toolkit.googlecode.com/svn/trunk/distro-source/core/src/gwt-module.dtd"> <!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN" "http://google-web-toolkit.googlecode.com/svn/trunk/distro-source/core/src/gwt-module.dtd">
<module> <module>
<source path="org/oscim" /> <source path="org/oscim" />
</module> </module>

View File

@@ -1,214 +1,214 @@
/* /*
* Copyright 2013 Hannes Janetzek * Copyright 2013 Hannes Janetzek
* *
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
* *
* This program is free software: you can redistribute it and/or modify it under the * This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software * terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version. * Foundation, either version 3 of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT ANY * This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License along with * You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>. * this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.oscim.gdx; package org.oscim.gdx;
import org.oscim.layers.TileGridLayer; import org.oscim.layers.TileGridLayer;
import org.oscim.layers.tile.buildings.BuildingLayer; import org.oscim.layers.tile.buildings.BuildingLayer;
import org.oscim.layers.tile.vector.VectorTileLayer; import org.oscim.layers.tile.vector.VectorTileLayer;
import org.oscim.layers.tile.vector.labeling.LabelLayer; import org.oscim.layers.tile.vector.labeling.LabelLayer;
import org.oscim.map.Layers; import org.oscim.map.Layers;
import org.oscim.map.Map; import org.oscim.map.Map;
import org.oscim.renderer.MapRenderer; import org.oscim.renderer.MapRenderer;
import org.oscim.theme.VtmThemes; import org.oscim.theme.VtmThemes;
import org.oscim.tiling.TileSource; import org.oscim.tiling.TileSource;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.badlogic.gdx.Application; import com.badlogic.gdx.Application;
import com.badlogic.gdx.ApplicationListener; import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputMultiplexer; import com.badlogic.gdx.InputMultiplexer;
import com.badlogic.gdx.utils.Timer; import com.badlogic.gdx.utils.Timer;
import com.badlogic.gdx.utils.Timer.Task; import com.badlogic.gdx.utils.Timer.Task;
public abstract class GdxMap implements ApplicationListener { public abstract class GdxMap implements ApplicationListener {
final static Logger log = LoggerFactory.getLogger(GdxMap.class); final static Logger log = LoggerFactory.getLogger(GdxMap.class);
protected Map mMap; protected Map mMap;
VectorTileLayer mMapLayer; VectorTileLayer mMapLayer;
private MapRenderer mMapRenderer; private MapRenderer mMapRenderer;
public GdxMap() { public GdxMap() {
} }
protected void initDefaultLayers(TileSource tileSource, boolean tileGrid, boolean labels, protected void initDefaultLayers(TileSource tileSource, boolean tileGrid, boolean labels,
boolean buildings) { boolean buildings) {
Layers layers = mMap.layers(); Layers layers = mMap.layers();
if (tileSource != null) { if (tileSource != null) {
mMapLayer = mMap.setBaseMap(tileSource); mMapLayer = mMap.setBaseMap(tileSource);
mMap.setTheme(VtmThemes.DEFAULT); mMap.setTheme(VtmThemes.DEFAULT);
if (buildings) if (buildings)
layers.add(new BuildingLayer(mMap, mMapLayer)); layers.add(new BuildingLayer(mMap, mMapLayer));
if (labels) if (labels)
layers.add(new LabelLayer(mMap, mMapLayer)); layers.add(new LabelLayer(mMap, mMapLayer));
} }
if (tileGrid) if (tileGrid)
layers.add(new TileGridLayer(mMap)); layers.add(new TileGridLayer(mMap));
} }
@Override @Override
public void create() { public void create() {
mMap = new MapAdapter(); mMap = new MapAdapter();
mMapRenderer = new MapRenderer(mMap); mMapRenderer = new MapRenderer(mMap);
Gdx.graphics.setContinuousRendering(false); Gdx.graphics.setContinuousRendering(false);
Gdx.app.setLogLevel(Application.LOG_DEBUG); Gdx.app.setLogLevel(Application.LOG_DEBUG);
int w = Gdx.graphics.getWidth(); int w = Gdx.graphics.getWidth();
int h = Gdx.graphics.getHeight(); int h = Gdx.graphics.getHeight();
mMap.viewport().setScreenSize(w, h); mMap.viewport().setScreenSize(w, h);
mMapRenderer.onSurfaceCreated(); mMapRenderer.onSurfaceCreated();
mMapRenderer.onSurfaceChanged(w, h); mMapRenderer.onSurfaceChanged(w, h);
InputMultiplexer mux = new InputMultiplexer(); InputMultiplexer mux = new InputMultiplexer();
mux.addProcessor(new InputHandler(this)); mux.addProcessor(new InputHandler(this));
//mux.addProcessor(new GestureDetector(20, 0.5f, 2, 0.05f, //mux.addProcessor(new GestureDetector(20, 0.5f, 2, 0.05f,
// new MapController(mMap))); // new MapController(mMap)));
mux.addProcessor(new MotionHandler(mMap)); mux.addProcessor(new MotionHandler(mMap));
Gdx.input.setInputProcessor(mux); Gdx.input.setInputProcessor(mux);
createLayers(); createLayers();
} }
protected void createLayers() { protected void createLayers() {
mMap.layers().add(new TileGridLayer(mMap)); mMap.layers().add(new TileGridLayer(mMap));
} }
@Override @Override
public void dispose() { public void dispose() {
} }
/* private */boolean mRenderWait; /* private */boolean mRenderWait;
/* private */boolean mRenderRequest; /* private */boolean mRenderRequest;
/* private */boolean mUpdateRequest; /* private */boolean mUpdateRequest;
@Override @Override
public void render() { public void render() {
if (!mRenderRequest) if (!mRenderRequest)
return; return;
mMapRenderer.onDrawFrame(); mMapRenderer.onDrawFrame();
} }
@Override @Override
public void resize(int w, int h) { public void resize(int w, int h) {
mMap.viewport().setScreenSize(w, h); mMap.viewport().setScreenSize(w, h);
mMapRenderer.onSurfaceChanged(w, h); mMapRenderer.onSurfaceChanged(w, h);
mMap.render(); mMap.render();
} }
@Override @Override
public void pause() { public void pause() {
} }
@Override @Override
public void resume() { public void resume() {
} }
protected boolean onKeyDown(int keycode) { protected boolean onKeyDown(int keycode) {
return false; return false;
} }
public Map getMap() { public Map getMap() {
return mMap; return mMap;
} }
class MapAdapter extends Map { class MapAdapter extends Map {
@Override @Override
public int getWidth() { public int getWidth() {
return Gdx.graphics.getWidth(); return Gdx.graphics.getWidth();
} }
@Override @Override
public int getHeight() { public int getHeight() {
return Gdx.graphics.getHeight(); return Gdx.graphics.getHeight();
} }
private final Runnable mRedrawCb = new Runnable() { private final Runnable mRedrawCb = new Runnable() {
@Override @Override
public void run() { public void run() {
prepareFrame(); prepareFrame();
Gdx.graphics.requestRendering(); Gdx.graphics.requestRendering();
} }
}; };
@Override @Override
public void updateMap(boolean forceRender) { public void updateMap(boolean forceRender) {
synchronized (mRedrawCb) { synchronized (mRedrawCb) {
if (!mRenderRequest) { if (!mRenderRequest) {
mRenderRequest = true; mRenderRequest = true;
Gdx.app.postRunnable(mRedrawCb); Gdx.app.postRunnable(mRedrawCb);
} else { } else {
mRenderWait = true; mRenderWait = true;
} }
} }
} }
@Override @Override
public void render() { public void render() {
synchronized (mRedrawCb) { synchronized (mRedrawCb) {
mRenderRequest = true; mRenderRequest = true;
if (mClearMap) if (mClearMap)
updateMap(false); updateMap(false);
else { else {
Gdx.graphics.requestRendering(); Gdx.graphics.requestRendering();
} }
} }
} }
@Override @Override
public boolean post(Runnable runnable) { public boolean post(Runnable runnable) {
Gdx.app.postRunnable(runnable); Gdx.app.postRunnable(runnable);
return true; return true;
} }
@Override @Override
public boolean postDelayed(final Runnable action, long delay) { public boolean postDelayed(final Runnable action, long delay) {
Timer.schedule(new Task() { Timer.schedule(new Task() {
@Override @Override
public void run() { public void run() {
action.run(); action.run();
} }
}, delay / 1000f); }, delay / 1000f);
return true; return true;
} }
@Override @Override
public void beginFrame() { public void beginFrame() {
} }
@Override @Override
public void doneFrame(boolean animate) { public void doneFrame(boolean animate) {
synchronized (mRedrawCb) { synchronized (mRedrawCb) {
mRenderRequest = false; mRenderRequest = false;
if (animate || mRenderWait) { if (animate || mRenderWait) {
mRenderWait = false; mRenderWait = false;
updateMap(true); updateMap(true);
} }
} }
} }
} }
} }

View File

@@ -1,37 +1,37 @@
/* /*
* Copyright 2013 Hannes Janetzek * Copyright 2013 Hannes Janetzek
* Copyright 2016 Longri * Copyright 2016 Longri
* *
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
* *
* This program is free software: you can redistribute it and/or modify it under the * This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software * terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version. * Foundation, either version 3 of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT ANY * This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License along with * You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>. * this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.oscim.ios; package org.oscim.ios;
import org.oscim.backend.GLAdapter; import org.oscim.backend.GLAdapter;
import org.oscim.gdx.GdxAssets; import org.oscim.gdx.GdxAssets;
import org.oscim.gdx.GdxMap; import org.oscim.gdx.GdxMap;
import org.oscim.ios.backend.IosGL; import org.oscim.ios.backend.IosGL;
import org.oscim.ios.backend.IosGraphics; import org.oscim.ios.backend.IosGraphics;
public class IOSMapApp extends GdxMap { public class IOSMapApp extends GdxMap {
public static void init() { public static void init() {
// init globals // init globals
IosGraphics.init(); IosGraphics.init();
GdxAssets.init("assets/"); GdxAssets.init("assets/");
GLAdapter.init(new IosGL()); GLAdapter.init(new IosGL());
} }
} }

File diff suppressed because it is too large Load Diff

View File

@@ -1,177 +1,177 @@
{ {
"version": [ 0, 1], "version": [ 0, 1],
"id": "", "id": "",
"meshes": [ "meshes": [
{ {
"attributes": ["POSITION", "NORMAL", "TEXCOORD0"], "attributes": ["POSITION", "NORMAL", "TEXCOORD0"],
"vertices": [ "vertices": [
-0.003717, -0.043092, 0.000001, 0.000000, -1.000000, 0.000000, 0.000000, 0.000000, -0.003717, -0.043092, 0.000001, 0.000000, -1.000000, 0.000000, 0.000000, 0.000000,
-0.003717, -0.043092, -0.019798, 0.000000, -0.609973, -0.792383, 0.000000, 0.000000, -0.003717, -0.043092, -0.019798, 0.000000, -0.609973, -0.792383, 0.000000, 0.000000,
0.013430, -0.043092, -0.009898, 0.686239, -0.609973, -0.396191, 0.000000, 0.000000, 0.013430, -0.043092, -0.009898, 0.686239, -0.609973, -0.396191, 0.000000, 0.000000,
-0.003717, 0.527242, 0.000001, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, -0.003717, 0.527242, 0.000001, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000,
0.013430, 0.527242, -0.009898, 0.686239, 0.609973, -0.396191, 0.000000, 0.000000, 0.013430, 0.527242, -0.009898, 0.686239, 0.609973, -0.396191, 0.000000, 0.000000,
-0.003717, 0.527242, -0.019798, 0.000000, 0.609973, -0.792383, 0.000000, 0.000000, -0.003717, 0.527242, -0.019798, 0.000000, 0.609973, -0.792383, 0.000000, 0.000000,
0.013430, -0.043092, 0.009901, 0.686239, -0.609973, 0.396191, 0.000000, 0.000000, 0.013430, -0.043092, 0.009901, 0.686239, -0.609973, 0.396191, 0.000000, 0.000000,
0.013430, 0.527242, 0.009901, 0.686239, 0.609973, 0.396191, 0.000000, 0.000000, 0.013430, 0.527242, 0.009901, 0.686239, 0.609973, 0.396191, 0.000000, 0.000000,
-0.003717, -0.043092, 0.019801, 0.000000, -0.609973, 0.792383, 0.000000, 0.000000, -0.003717, -0.043092, 0.019801, 0.000000, -0.609973, 0.792383, 0.000000, 0.000000,
-0.003717, 0.527242, 0.019801, 0.000000, 0.609973, 0.792383, 0.000000, 0.000000, -0.003717, 0.527242, 0.019801, 0.000000, 0.609973, 0.792383, 0.000000, 0.000000,
-0.020865, -0.043092, 0.009901, -0.686239, -0.609973, 0.396191, 0.000000, 0.000000, -0.020865, -0.043092, 0.009901, -0.686239, -0.609973, 0.396191, 0.000000, 0.000000,
-0.020865, 0.527242, 0.009901, -0.686239, 0.609973, 0.396191, 0.000000, 0.000000, -0.020865, 0.527242, 0.009901, -0.686239, 0.609973, 0.396191, 0.000000, 0.000000,
-0.020865, -0.043092, -0.009898, -0.686239, -0.609973, -0.396191, 0.000000, 0.000000, -0.020865, -0.043092, -0.009898, -0.686239, -0.609973, -0.396191, 0.000000, 0.000000,
-0.020865, 0.527242, -0.009898, -0.686239, 0.609973, -0.396191, 0.000000, 0.000000, -0.020865, 0.527242, -0.009898, -0.686239, 0.609973, -0.396191, 0.000000, 0.000000,
-0.000052, 1.708732, 0.000001, 0.000000, 1.000000, 0.000000, 0.627643, 0.963260, -0.000052, 1.708732, 0.000001, 0.000000, 1.000000, 0.000000, 0.627643, 0.963260,
-0.056858, 1.692897, -0.056805, -0.359325, 0.861232, -0.359325, 0.811107, 0.943917, -0.056858, 1.692897, -0.056805, -0.359325, 0.861232, -0.359325, 0.811107, 0.943917,
-0.080388, 1.692897, 0.000001, -0.508194, 0.861232, 0.000000, 0.930977, 0.971962, -0.080388, 1.692897, 0.000001, -0.508194, 0.861232, 0.000000, 0.930977, 0.971962,
-0.112293, 1.619116, -0.112239, -0.584552, 0.562639, -0.584552, 0.871491, 0.884983, -0.112293, 1.619116, -0.112239, -0.584552, 0.562639, -0.584552, 0.871491, 0.884983,
-0.158784, 1.619116, 0.000001, -0.826655, 0.562639, 0.000000, 1.012361, 0.910828, -0.158784, 1.619116, 0.000001, -0.826655, 0.562639, 0.000000, 1.012361, 0.910828,
-0.176420, 1.422079, -0.176367, -0.675863, 0.293832, -0.675863, 0.903795, 0.728324, -0.176420, 1.422079, -0.176367, -0.675863, 0.293832, -0.675863, 0.903795, 0.728324,
-0.249474, 1.422079, 0.000001, -0.955840, 0.293832, 0.000000, 1.035246, 0.751852, -0.249474, 1.422079, 0.000001, -0.955840, 0.293832, 0.000000, 1.035246, 0.751852,
-0.210746, 1.159339, -0.210693, -0.704306, 0.088870, -0.704306, 0.922129, 0.451029, -0.210746, 1.159339, -0.210693, -0.704306, 0.088870, -0.704306, 0.922129, 0.451029,
-0.298019, 1.159339, 0.000001, -0.996033, 0.088870, 0.000000, 1.045340, 0.473093, -0.298019, 1.159339, 0.000001, -0.996033, 0.088870, 0.000000, 1.045340, 0.473093,
-0.210605, 0.903175, -0.210552, -0.705252, -0.072024, -0.705252, 0.936767, 0.254108, -0.210605, 0.903175, -0.210552, -0.705252, -0.072024, -0.705252, 0.936767, 0.254108,
-0.297820, 0.903175, 0.000001, -0.997375, -0.072024, 0.000000, 1.052424, 0.274946, -0.297820, 0.903175, 0.000001, -0.997375, -0.072024, 0.000000, 1.052424, 0.274946,
-0.180964, 0.617981, -0.180911, -0.685263, -0.246529, -0.685263, 0.956801, 0.142573, -0.180964, 0.617981, -0.180911, -0.685263, -0.246529, -0.685263, 0.956801, 0.142573,
-0.255900, 0.617981, 0.000001, -0.969115, -0.246529, 0.000000, 1.061122, 0.161660, -0.255900, 0.617981, 0.000001, -0.969115, -0.246529, 0.000000, 1.061122, 0.161660,
-0.116291, 0.378825, -0.116238, -0.610279, -0.505051, -0.610279, 0.991689, 0.079506, -0.116291, 0.378825, -0.116238, -0.610279, -0.505051, -0.610279, 0.991689, 0.079506,
-0.164439, 0.378825, 0.000001, -0.863063, -0.505051, 0.000000, 1.074527, 0.095355, -0.164439, 0.378825, 0.000001, -0.863063, -0.505051, 0.000000, 1.074527, 0.095355,
-0.059153, 0.290116, -0.059100, -0.407514, -0.817194, -0.407544, 1.038003, 0.052079, -0.059153, 0.290116, -0.059100, -0.407514, -0.817194, -0.407544, 1.038003, 0.052079,
-0.083634, 0.290116, 0.000001, -0.576312, -0.817194, 0.000000, 1.090933, 0.063214, -0.083634, 0.290116, 0.000001, -0.576312, -0.817194, 0.000000, 1.090933, 0.063214,
-0.083634, 0.290116, 0.000001, -0.576312, -0.817194, 0.000000, 0.090933, 0.063214, -0.083634, 0.290116, 0.000001, -0.576312, -0.817194, 0.000000, 0.090933, 0.063214,
-0.059153, 0.290116, -0.059100, -0.407514, -0.817194, -0.407544, 0.038003, 0.052079, -0.059153, 0.290116, -0.059100, -0.407514, -0.817194, -0.407544, 0.038003, 0.052079,
-0.000125, 0.265210, -0.000071, -0.000244, -0.999969, -0.000244, 0.127500, 0.036749, -0.000125, 0.265210, -0.000071, -0.000244, -0.999969, -0.000244, 0.127500, 0.036749,
-0.000051, 0.290116, -0.083580, 0.000000, -0.817194, -0.576312, 0.994047, 0.033372, -0.000051, 0.290116, -0.083580, 0.000000, -0.817194, -0.576312, 0.994047, 0.033372,
-0.000125, 0.265210, -0.000071, -0.000244, -0.999969, -0.000244, 1.127500, 0.036749, -0.000125, 0.265210, -0.000071, -0.000244, -0.999969, -0.000244, 1.127500, 0.036749,
-0.000051, 0.378825, -0.164386, 0.000000, -0.505051, -0.863063, 0.893772, 0.053663, -0.000051, 0.378825, -0.164386, 0.000000, -0.505051, -0.863063, 0.893772, 0.053663,
-0.000052, 0.617981, -0.255847, 0.000000, -0.246529, -0.969115, 0.836458, 0.114704, -0.000052, 0.617981, -0.255847, 0.000000, -0.246529, -0.969115, 0.836458, 0.114704,
-0.000052, 0.903175, -0.297766, 0.000000, -0.072024, -0.997375, 0.812221, 0.226047, -0.000052, 0.903175, -0.297766, 0.000000, -0.072024, -0.997375, 0.812221, 0.226047,
-0.000052, 1.159339, -0.297966, 0.000000, 0.088870, -0.996033, 0.797565, 0.423137, -0.000052, 1.159339, -0.297966, 0.000000, 0.088870, -0.996033, 0.797565, 0.423137,
-0.000052, 1.422079, -0.249421, 0.000000, 0.293832, -0.955840, 0.781975, 0.700922, -0.000052, 1.422079, -0.249421, 0.000000, 0.293832, -0.955840, 0.781975, 0.700922,
-0.000052, 1.619116, -0.158731, 0.000000, 0.562639, -0.826655, 0.759783, 0.858997, -0.000052, 1.619116, -0.158731, 0.000000, 0.562639, -0.826655, 0.759783, 0.858997,
-0.000052, 1.692897, -0.080335, 0.000000, 0.861232, -0.508194, 0.728165, 0.921879, -0.000052, 1.692897, -0.080335, 0.000000, 0.861232, -0.508194, 0.728165, 0.921879,
0.056754, 1.692897, -0.056805, 0.359325, 0.861232, -0.359325, 0.652361, 0.910987, 0.056754, 1.692897, -0.056805, 0.359325, 0.861232, -0.359325, 0.652361, 0.910987,
0.112189, 1.619116, -0.112239, 0.584552, 0.562639, -0.584552, 0.659906, 0.845090, 0.112189, 1.619116, -0.112239, 0.584552, 0.562639, -0.584552, 0.659906, 0.845090,
0.176316, 1.422079, -0.176367, 0.675863, 0.293832, -0.675863, 0.665734, 0.684958, 0.176316, 1.422079, -0.176367, 0.675863, 0.293832, -0.675863, 0.665734, 0.684958,
0.210643, 1.159339, -0.210693, 0.704306, 0.088870, -0.704306, 0.670277, 0.405750, 0.210643, 1.159339, -0.210693, 0.704306, 0.088870, -0.704306, 0.670277, 0.405750,
0.210502, 0.903175, -0.210552, 0.705252, -0.072024, -0.705252, 0.675032, 0.207335, 0.210502, 0.903175, -0.210552, 0.705252, -0.072024, -0.705252, 0.675032, 0.207335,
0.180860, 0.617981, -0.180910, 0.685263, -0.246529, -0.685263, 0.684415, 0.093825, 0.180860, 0.617981, -0.180910, 0.685263, -0.246529, -0.685263, 0.684415, 0.093825,
0.116188, 0.378825, -0.116237, 0.610279, -0.505051, -0.610279, 0.723612, 0.027920, 0.116188, 0.378825, -0.116237, 0.610279, -0.505051, -0.610279, 0.723612, 0.027920,
0.059050, 0.290116, -0.059099, 0.407483, -0.817255, -0.407422, 1.018456, 0.011649, 0.059050, 0.290116, -0.059099, 0.407483, -0.817255, -0.407422, 1.018456, 0.011649,
0.059050, 0.290116, -0.059099, 0.407483, -0.817255, -0.407422, 0.018456, 0.011649, 0.059050, 0.290116, -0.059099, 0.407483, -0.817255, -0.407422, 0.018456, 0.011649,
0.083530, 0.290116, 0.000002, 0.576159, -0.817316, 0.000000, 0.267608, 0.018648, 0.083530, 0.290116, 0.000002, 0.576159, -0.817316, 0.000000, 0.267608, 0.018648,
0.164335, 0.378825, 0.000002, 0.863063, -0.505051, 0.000000, 0.457225, 0.035136, 0.164335, 0.378825, 0.000002, 0.863063, -0.505051, 0.000000, 0.457225, 0.035136,
0.255796, 0.617981, 0.000002, 0.969115, -0.246529, 0.000000, 0.515690, 0.098717, 0.255796, 0.617981, 0.000002, 0.969115, -0.246529, 0.000000, 0.515690, 0.098717,
0.297716, 0.903175, 0.000002, 0.997375, -0.072024, 0.000000, 0.532803, 0.211513, 0.297716, 0.903175, 0.000002, 0.997375, -0.072024, 0.000000, 0.532803, 0.211513,
0.297915, 1.159339, 0.000002, 0.996033, 0.088870, 0.000000, 0.541872, 0.409545, 0.297915, 1.159339, 0.000002, 0.996033, 0.088870, 0.000000, 0.541872, 0.409545,
0.249370, 1.422079, 0.000002, 0.955840, 0.293832, 0.000000, 0.550746, 0.688375, 0.249370, 1.422079, 0.000002, 0.955840, 0.293832, 0.000000, 0.550746, 0.688375,
0.158680, 1.619116, 0.000002, 0.826655, 0.562639, 0.000000, 0.562378, 0.848006, 0.158680, 1.619116, 0.000002, 0.826655, 0.562639, 0.000000, 0.562378, 0.848006,
0.080284, 1.692897, 0.000001, 0.508194, 0.861232, 0.000000, 0.577714, 0.913236, 0.080284, 1.692897, 0.000001, 0.508194, 0.861232, 0.000000, 0.577714, 0.913236,
0.056754, 1.692897, 0.056808, 0.359325, 0.861232, 0.359325, 0.500528, 0.928224, 0.056754, 1.692897, 0.056808, 0.359325, 0.861232, 0.359325, 0.500528, 0.928224,
0.112188, 1.619116, 0.112242, 0.584552, 0.562670, 0.584552, 0.459880, 0.866817, 0.112188, 1.619116, 0.112242, 0.584552, 0.562670, 0.584552, 0.459880, 0.866817,
0.176316, 1.422079, 0.176370, 0.675863, 0.293832, 0.675863, 0.433163, 0.709519, 0.176316, 1.422079, 0.176370, 0.675863, 0.293832, 0.675863, 0.433163, 0.709519,
0.210642, 1.159339, 0.210696, 0.704306, 0.088870, 0.704306, 0.415507, 0.432148, 0.210642, 1.159339, 0.210696, 0.704306, 0.088870, 0.704306, 0.415507, 0.432148,
0.210501, 0.903175, 0.210555, 0.705252, -0.072024, 0.705252, 0.399773, 0.235351, 0.210501, 0.903175, 0.210555, 0.705252, -0.072024, 0.705252, 0.399773, 0.235351,
0.180860, 0.617981, 0.180914, 0.685263, -0.246529, 0.685263, 0.375517, 0.124299, 0.180860, 0.617981, 0.180914, 0.685263, -0.246529, 0.685263, 0.375517, 0.124299,
0.116187, 0.378825, 0.116241, 0.610279, -0.505051, 0.610279, 0.325269, 0.063109, 0.116187, 0.378825, 0.116241, 0.610279, -0.505051, 0.610279, 0.325269, 0.063109,
0.059049, 0.290116, 0.059103, 0.407361, -0.817347, 0.407392, 0.248452, 0.040330, 0.059049, 0.290116, 0.059103, 0.407361, -0.817347, 0.407392, 0.248452, 0.040330,
-0.000053, 0.290116, 0.083583, 0.000000, -0.817316, 0.576159, 0.199939, 0.056802, -0.000053, 0.290116, 0.083583, 0.000000, -0.817316, 0.576159, 0.199939, 0.056802,
-0.000053, 0.378825, 0.164389, 0.000000, -0.505051, 0.863063, 0.234895, 0.086200, -0.000053, 0.378825, 0.164389, 0.000000, -0.505051, 0.863063, 0.234895, 0.086200,
-0.000053, 0.617981, 0.255850, 0.000000, -0.246529, 0.969115, 0.262269, 0.150492, -0.000053, 0.617981, 0.255850, 0.000000, -0.246529, 0.969115, 0.262269, 0.150492,
-0.000052, 0.903175, 0.297769, 0.000000, -0.072024, 0.997375, 0.278892, 0.262611, -0.000052, 0.903175, 0.297769, 0.000000, -0.072024, 0.997375, 0.278892, 0.262611,
-0.000052, 1.159339, 0.297968, 0.000000, 0.088870, 0.996033, 0.291619, 0.459894, -0.000052, 1.159339, 0.297968, 0.000000, 0.088870, 0.996033, 0.291619, 0.459894,
-0.000052, 1.422079, 0.249424, 0.000000, 0.293832, 0.955840, 0.308400, 0.737559, -0.000052, 1.422079, 0.249424, 0.000000, 0.293832, 0.955840, 0.308400, 0.737559,
-0.000052, 1.619116, 0.158734, 0.000000, 0.562670, 0.826655, 0.340691, 0.894603, -0.000052, 1.619116, 0.158734, 0.000000, 0.562670, 0.826655, 0.340691, 0.894603,
-0.000052, 1.692897, 0.080338, 0.000000, 0.861232, 0.508194, 0.411564, 0.953109, -0.000052, 1.692897, 0.080338, 0.000000, 0.861232, 0.508194, 0.411564, 0.953109,
-0.056858, 1.692897, 0.056808, -0.359325, 0.861232, 0.359325, 0.247502, 0.980115, -0.056858, 1.692897, 0.056808, -0.359325, 0.861232, 0.359325, 0.247502, 0.980115,
-0.112293, 1.619116, 0.112242, -0.584552, 0.562670, 0.584552, 0.186319, 0.915857, -0.112293, 1.619116, 0.112242, -0.584552, 0.562670, 0.584552, 0.186319, 0.915857,
-0.176420, 1.422079, 0.176369, -0.675863, 0.293832, 0.675863, 0.173739, 0.755927, -0.176420, 1.422079, 0.176369, -0.675863, 0.293832, 0.675863, 0.173739, 0.755927,
-0.210747, 1.159339, 0.210696, -0.704306, 0.088870, 0.704306, 0.168491, 0.476740, -0.210747, 1.159339, 0.210696, -0.704306, 0.088870, 0.704306, 0.168491, 0.476740,
-0.210606, 0.903175, 0.210555, -0.705252, -0.072024, 0.705252, 0.164886, 0.278291, -0.210606, 0.903175, 0.210555, -0.705252, -0.072024, 0.705252, 0.164886, 0.278291,
-0.180964, 0.617981, 0.180913, -0.685263, -0.246529, 0.685263, 0.160531, 0.164632, -0.180964, 0.617981, 0.180913, -0.685263, -0.246529, 0.685263, 0.160531, 0.164632,
-0.116292, 0.378825, 0.116240, -0.610279, -0.505051, 0.610279, 0.153922, 0.097744, -0.116292, 0.378825, 0.116240, -0.610279, -0.505051, 0.610279, 0.153922, 0.097744,
-0.059154, 0.290116, 0.059102, -0.407453, -0.817255, 0.407483, 0.145909, 0.064880, -0.059154, 0.290116, 0.059102, -0.407453, -0.817255, 0.407483, 0.145909, 0.064880,
-0.164439, 0.378825, 0.000001, -0.863063, -0.505051, 0.000000, 0.074527, 0.095355, -0.164439, 0.378825, 0.000001, -0.863063, -0.505051, 0.000000, 0.074527, 0.095355,
-0.255900, 0.617981, 0.000001, -0.969115, -0.246529, 0.000000, 0.061122, 0.161660, -0.255900, 0.617981, 0.000001, -0.969115, -0.246529, 0.000000, 0.061122, 0.161660,
-0.297820, 0.903175, 0.000001, -0.997375, -0.072024, 0.000000, 0.052424, 0.274946, -0.297820, 0.903175, 0.000001, -0.997375, -0.072024, 0.000000, 0.052424, 0.274946,
-0.298019, 1.159339, 0.000001, -0.996033, 0.088870, 0.000000, 0.045340, 0.473093, -0.298019, 1.159339, 0.000001, -0.996033, 0.088870, 0.000000, 0.045340, 0.473093,
-0.249474, 1.422079, 0.000001, -0.955840, 0.293832, 0.000000, 0.035246, 0.751852, -0.249474, 1.422079, 0.000001, -0.955840, 0.293832, 0.000000, 0.035246, 0.751852,
-0.158784, 1.619116, 0.000001, -0.826655, 0.562639, 0.000000, 0.012361, 0.910828, -0.158784, 1.619116, 0.000001, -0.826655, 0.562639, 0.000000, 0.012361, 0.910828,
-0.056858, 1.692897, 0.056808, -0.359325, 0.861232, 0.359325, 1.247502, 0.980115, -0.056858, 1.692897, 0.056808, -0.359325, 0.861232, 0.359325, 1.247502, 0.980115,
-0.112293, 1.619116, 0.112242, -0.584552, 0.562670, 0.584552, 1.186319, 0.915857 -0.112293, 1.619116, 0.112242, -0.584552, 0.562670, 0.584552, 1.186319, 0.915857
], ],
"parts": [ "parts": [
{ {
"id": "mpart1", "id": "mpart1",
"type": "TRIANGLES", "type": "TRIANGLES",
"indices": [ "indices": [
0, 1, 2, 3, 4, 5, 0, 2, 6, 3, 7, 4, 0, 1, 2, 3, 4, 5, 0, 2, 6, 3, 7, 4,
0, 6, 8, 3, 9, 7, 0, 8, 10, 3, 11, 9, 0, 6, 8, 3, 9, 7, 0, 8, 10, 3, 11, 9,
0, 10, 12, 3, 13, 11, 12, 1, 0, 3, 5, 13, 0, 10, 12, 3, 13, 11, 12, 1, 0, 3, 5, 13,
1, 5, 4, 1, 4, 2, 2, 4, 7, 2, 7, 6, 1, 5, 4, 1, 4, 2, 2, 4, 7, 2, 7, 6,
6, 7, 9, 6, 9, 8, 8, 9, 11, 8, 11, 10, 6, 7, 9, 6, 9, 8, 8, 9, 11, 8, 11, 10,
10, 11, 13, 10, 13, 12, 5, 1, 12, 5, 12, 13, 10, 11, 13, 10, 13, 12, 5, 1, 12, 5, 12, 13,
14, 15, 16, 16, 15, 17, 16, 17, 18, 18, 17, 19, 14, 15, 16, 16, 15, 17, 16, 17, 18, 18, 17, 19,
18, 19, 20, 20, 19, 21, 20, 21, 22, 22, 21, 23, 18, 19, 20, 20, 19, 21, 20, 21, 22, 22, 21, 23,
22, 23, 24, 24, 23, 25, 24, 25, 26, 26, 25, 27, 22, 23, 24, 24, 23, 25, 24, 25, 26, 26, 25, 27,
26, 27, 28, 28, 27, 29, 28, 29, 30, 31, 32, 33, 26, 27, 28, 28, 27, 29, 28, 29, 30, 31, 32, 33,
29, 34, 35, 27, 36, 34, 27, 34, 29, 25, 37, 36, 29, 34, 35, 27, 36, 34, 27, 34, 29, 25, 37, 36,
25, 36, 27, 23, 38, 37, 23, 37, 25, 21, 39, 38, 25, 36, 27, 23, 38, 37, 23, 37, 25, 21, 39, 38,
21, 38, 23, 19, 40, 39, 19, 39, 21, 17, 41, 40, 21, 38, 23, 19, 40, 39, 19, 39, 21, 17, 41, 40,
17, 40, 19, 15, 42, 41, 15, 41, 17, 15, 14, 42, 17, 40, 19, 15, 42, 41, 15, 41, 17, 15, 14, 42,
42, 14, 43, 42, 43, 44, 42, 44, 41, 41, 44, 45, 42, 14, 43, 42, 43, 44, 42, 44, 41, 41, 44, 45,
41, 45, 40, 40, 45, 46, 40, 46, 39, 39, 46, 47, 41, 45, 40, 40, 45, 46, 40, 46, 39, 39, 46, 47,
39, 47, 38, 38, 47, 48, 38, 48, 37, 37, 48, 49, 39, 47, 38, 38, 47, 48, 38, 48, 37, 37, 48, 49,
37, 49, 36, 36, 49, 50, 36, 50, 34, 34, 50, 35, 37, 49, 36, 36, 49, 50, 36, 50, 34, 34, 50, 35,
51, 52, 33, 49, 53, 52, 49, 52, 50, 48, 54, 53, 51, 52, 33, 49, 53, 52, 49, 52, 50, 48, 54, 53,
48, 53, 49, 47, 55, 54, 47, 54, 48, 46, 56, 55, 48, 53, 49, 47, 55, 54, 47, 54, 48, 46, 56, 55,
46, 55, 47, 45, 57, 56, 45, 56, 46, 44, 58, 57, 46, 55, 47, 45, 57, 56, 45, 56, 46, 44, 58, 57,
44, 57, 45, 43, 59, 58, 43, 58, 44, 43, 14, 59, 44, 57, 45, 43, 59, 58, 43, 58, 44, 43, 14, 59,
59, 14, 60, 59, 60, 61, 59, 61, 58, 58, 61, 62, 59, 14, 60, 59, 60, 61, 59, 61, 58, 58, 61, 62,
58, 62, 57, 57, 62, 63, 57, 63, 56, 56, 63, 64, 58, 62, 57, 57, 62, 63, 57, 63, 56, 56, 63, 64,
56, 64, 55, 55, 64, 65, 55, 65, 54, 54, 65, 66, 56, 64, 55, 55, 64, 65, 55, 65, 54, 54, 65, 66,
54, 66, 53, 53, 66, 67, 53, 67, 52, 52, 67, 33, 54, 66, 53, 53, 66, 67, 53, 67, 52, 52, 67, 33,
67, 68, 33, 66, 69, 68, 66, 68, 67, 65, 70, 69, 67, 68, 33, 66, 69, 68, 66, 68, 67, 65, 70, 69,
65, 69, 66, 64, 71, 70, 64, 70, 65, 63, 72, 71, 65, 69, 66, 64, 71, 70, 64, 70, 65, 63, 72, 71,
63, 71, 64, 62, 73, 72, 62, 72, 63, 61, 74, 73, 63, 71, 64, 62, 73, 72, 62, 72, 63, 61, 74, 73,
61, 73, 62, 60, 75, 74, 60, 74, 61, 60, 14, 75, 61, 73, 62, 60, 75, 74, 60, 74, 61, 60, 14, 75,
75, 14, 76, 75, 76, 77, 75, 77, 74, 74, 77, 78, 75, 14, 76, 75, 76, 77, 75, 77, 74, 74, 77, 78,
74, 78, 73, 73, 78, 79, 73, 79, 72, 72, 79, 80, 74, 78, 73, 73, 78, 79, 73, 79, 72, 72, 79, 80,
72, 80, 71, 71, 80, 81, 71, 81, 70, 70, 81, 82, 72, 80, 71, 71, 80, 81, 71, 81, 70, 70, 81, 82,
70, 82, 69, 69, 82, 83, 69, 83, 68, 68, 83, 33, 70, 82, 69, 69, 82, 83, 69, 83, 68, 68, 83, 33,
83, 31, 33, 82, 84, 31, 82, 31, 83, 81, 85, 84, 83, 31, 33, 82, 84, 31, 82, 31, 83, 81, 85, 84,
81, 84, 82, 80, 86, 85, 80, 85, 81, 79, 87, 86, 81, 84, 82, 80, 86, 85, 80, 85, 81, 79, 87, 86,
79, 86, 80, 78, 88, 87, 78, 87, 79, 77, 89, 88, 79, 86, 80, 78, 88, 87, 78, 87, 79, 77, 89, 88,
77, 88, 78, 90, 16, 18, 90, 18, 91, 90, 14, 16 77, 88, 78, 90, 16, 18, 90, 18, 91, 90, 14, 16
] ]
} }
] ]
} }
], ],
"materials": [ "materials": [
{ {
"id": "_tree.png", "id": "_tree.png",
"diffuse": [ 0.900000, 0.900000, 0.900000], "diffuse": [ 0.900000, 0.900000, 0.900000],
"specular": [ 0.100000, 0.100000, 0.100000], "specular": [ 0.100000, 0.100000, 0.100000],
"textures": [ "textures": [
{ {
"id": "_tree.png", "id": "_tree.png",
"filename": "tree.png", "filename": "tree.png",
"type": "DIFFUSE" "type": "DIFFUSE"
} }
] ]
} }
], ],
"nodes": [ "nodes": [
{ {
"id": "treeA_root", "id": "treeA_root",
"parts": [ "parts": [
{ {
"meshpartid": "mpart1", "meshpartid": "mpart1",
"materialid": "_tree.png", "materialid": "_tree.png",
"uvMapping": [[ 0]] "uvMapping": [[ 0]]
} }
] ]
} }
], ],
"animations": [] "animations": []
} }

View File

@@ -1,74 +1,74 @@
/* /*
* Copyright 2013 Hannes Janetzek * Copyright 2013 Hannes Janetzek
* *
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
* *
* This program is free software: you can redistribute it and/or modify it under the * This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software * terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version. * Foundation, either version 3 of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT ANY * This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License along with * You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>. * this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.oscim.web.client; package org.oscim.web.client;
import org.oscim.core.Tile; import org.oscim.core.Tile;
import org.oscim.gdx.client.MapConfig; import org.oscim.gdx.client.MapConfig;
import com.badlogic.gdx.ApplicationListener; import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.backends.gwt.GwtApplication; import com.badlogic.gdx.backends.gwt.GwtApplication;
import com.badlogic.gdx.backends.gwt.GwtApplicationConfiguration; import com.badlogic.gdx.backends.gwt.GwtApplicationConfiguration;
import com.badlogic.gdx.backends.gwt.preloader.Preloader.PreloaderCallback; import com.badlogic.gdx.backends.gwt.preloader.Preloader.PreloaderCallback;
import com.badlogic.gdx.backends.gwt.preloader.Preloader.PreloaderState; import com.badlogic.gdx.backends.gwt.preloader.Preloader.PreloaderState;
public class GwtLauncher extends GwtApplication { public class GwtLauncher extends GwtApplication {
@Override @Override
public GwtApplicationConfiguration getConfig() { public GwtApplicationConfiguration getConfig() {
GwtApplicationConfiguration cfg = GwtApplicationConfiguration cfg =
new GwtApplicationConfiguration(getWindowWidth(), new GwtApplicationConfiguration(getWindowWidth(),
getWindowHeight()); getWindowHeight());
cfg.canvasId = "map-canvas"; cfg.canvasId = "map-canvas";
cfg.stencil = true; cfg.stencil = true;
cfg.fps = 120; cfg.fps = 120;
return cfg; return cfg;
} }
@Override @Override
public ApplicationListener getApplicationListener() { public ApplicationListener getApplicationListener() {
Tile.SIZE = MapConfig.get().getTileSize(); Tile.SIZE = MapConfig.get().getTileSize();
return new GwtMap(); return new GwtMap();
} }
@Override @Override
public PreloaderCallback getPreloaderCallback() { public PreloaderCallback getPreloaderCallback() {
return new PreloaderCallback() { return new PreloaderCallback() {
@Override @Override
public void update(PreloaderState state) { public void update(PreloaderState state) {
} }
@Override @Override
public void error(String file) { public void error(String file) {
//log.debug("error loading " + file); //log.debug("error loading " + file);
} }
}; };
} }
private static native int getWindowWidth() /*-{ private static native int getWindowWidth() /*-{
return $wnd.innerWidth; return $wnd.innerWidth;
}-*/; }-*/;
private static native int getWindowHeight() /*-{ private static native int getWindowHeight() /*-{
return $wnd.innerHeight; return $wnd.innerHeight;
}-*/; }-*/;
} }

View File

@@ -1,75 +1,75 @@
<!doctype html> <!doctype html>
<html> <html>
<head> <head>
<title>vtm-gdx</title> <title>vtm-gdx</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> <meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!-- pixel and dpi are way too simple concepts for web devs, lets have css-pixels! <!-- pixel and dpi are way too simple concepts for web devs, lets have css-pixels!
definition is limited only by your imagination! --> definition is limited only by your imagination! -->
<!-- http://www.html5rocks.com/de/mobile/touch/ --> <!-- http://www.html5rocks.com/de/mobile/touch/ -->
<!-- http://www.quirksmode.org/mobile/viewports.html --> <!-- http://www.quirksmode.org/mobile/viewports.html -->
<!-- http://www.quirksmode.org/blog/archives/2012/07/more_about_devi.html --> <!-- http://www.quirksmode.org/blog/archives/2012/07/more_about_devi.html -->
<!-- devicePixelRatio: http://coding.smashingmagazine.com/2012/08/20/towards-retina-web/ --> <!-- devicePixelRatio: http://coding.smashingmagazine.com/2012/08/20/towards-retina-web/ -->
<meta name="viewport" <meta name="viewport"
content="width=device-width, initial-scale=1, user-scalable=no"> content="width=device-width, initial-scale=1, user-scalable=no">
<link rel="stylesheet" type="text/css" href="default.css"> <link rel="stylesheet" type="text/css" href="default.css">
<script type="text/javascript"> <script type="text/javascript">
var mapconfig = { var mapconfig = {
tilesource : "oscimap4", tilesource : "oscimap4",
tileurl : "http://opensciencemap.org/tiles/vtm", tileurl : "http://opensciencemap.org/tiles/vtm",
zoom : 2, zoom : 2,
latitude : 0.0, latitude : 0.0,
longitude : 0.0, longitude : 0.0,
tileSize : 400 tileSize : 400
} }
//background : "naturalearth" //background : "naturalearth"
</script> </script>
</head> </head>
<body oncontextmenu="return false;"> <body oncontextmenu="return false;">
<div id="credits"> <div id="credits">
<a href="https://github.com/hjanetzek/vtm">Source</a> | map data © <a <a href="https://github.com/hjanetzek/vtm">Source</a> | map data © <a
href="http://www.openstreemap.org">OpenStreetMap</a> contributors | <a href="http://www.openstreemap.org">OpenStreetMap</a> contributors | <a
href="http://www.opensciencemap.org">OpenScienceMap</a> href="http://www.opensciencemap.org">OpenScienceMap</a>
</div> </div>
<div id="canvas-area" <div id="canvas-area"
style="position: fixed; left: 0px; top: 0px; width: 100%; height: 100%;"> style="position: fixed; left: 0px; top: 0px; width: 100%; height: 100%;">
<canvas id="map-canvas"></canvas> <canvas id="map-canvas"></canvas>
</div> </div>
<script type="text/Javascript"> <script type="text/Javascript">
function canvasResize() { function canvasResize() {
div = document.getElementById('canvas-area') div = document.getElementById('canvas-area')
canvas = document.getElementById('map-canvas') canvas = document.getElementById('map-canvas')
var w = div.scrollWidth; var w = div.scrollWidth;
var h = div.scrollHeight; var h = div.scrollHeight;
//console.log(div.clientHeight + " " + div.clientWidth) //console.log(div.clientHeight + " " + div.clientWidth)
canvas.width = w; canvas.width = w;
canvas.height = h; canvas.height = h;
canvas.style.width = w + 'px'; canvas.style.width = w + 'px';
canvas.style.height = h + 'px'; canvas.style.height = h + 'px';
} }
canvasResize(); canvasResize();
window.addEventListener('resize', canvasResize, false); window.addEventListener('resize', canvasResize, false);
</script> </script>
<script type="text/javascript" src="VtmWebApp/js/_tessellate.js"></script> <script type="text/javascript" src="VtmWebApp/js/_tessellate.js"></script>
<script type="text/javascript" src="VtmWebApp/js/tessellate.js"></script> <script type="text/javascript" src="VtmWebApp/js/tessellate.js"></script>
<script type="text/javascript" src="VtmWebApp/VtmWebApp.nocache.js"></script> <script type="text/javascript" src="VtmWebApp/VtmWebApp.nocache.js"></script>
<div id="search"> <div id="search">
<table> <table>
<tr> <tr>
<td id="nameFieldContainer"> <td id="nameFieldContainer">
<td id="sendButtonContainer"> <td id="sendButtonContainer">
</tr> </tr>
<tr> <tr>
<td colspan="2" id="listContainer"> <td colspan="2" id="listContainer">
</tr> </tr>
</table> </table>
</div> </div>
</body> </body>
</html> </html>

View File

@@ -1,84 +1,84 @@
/* /*
* Copyright 2013 Hannes Janetzek * Copyright 2013 Hannes Janetzek
* *
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
* *
* This program is free software: you can redistribute it and/or modify it under the * This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software * terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version. * Foundation, either version 3 of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT ANY * This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License along with * You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>. * this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.oscim.web.client; package org.oscim.web.client;
import org.oscim.core.Tile; import org.oscim.core.Tile;
import org.oscim.gdx.client.MapConfig; import org.oscim.gdx.client.MapConfig;
import org.timepedia.exporter.client.ExporterUtil; import org.timepedia.exporter.client.ExporterUtil;
import com.badlogic.gdx.ApplicationListener; import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.backends.gwt.GwtApplication; import com.badlogic.gdx.backends.gwt.GwtApplication;
import com.badlogic.gdx.backends.gwt.GwtApplicationConfiguration; import com.badlogic.gdx.backends.gwt.GwtApplicationConfiguration;
import com.badlogic.gdx.backends.gwt.preloader.Preloader.PreloaderCallback; import com.badlogic.gdx.backends.gwt.preloader.Preloader.PreloaderCallback;
import com.badlogic.gdx.backends.gwt.preloader.Preloader.PreloaderState; import com.badlogic.gdx.backends.gwt.preloader.Preloader.PreloaderState;
public class GwtLauncher extends GwtApplication { public class GwtLauncher extends GwtApplication {
@Override @Override
public void onModuleLoad() { public void onModuleLoad() {
//GWT.create(GwtGdxMap.class); //GWT.create(GwtGdxMap.class);
//JsOverlays.init(); //JsOverlays.init();
ExporterUtil.exportAll(); ExporterUtil.exportAll();
super.onModuleLoad(); super.onModuleLoad();
} }
@Override @Override
public GwtApplicationConfiguration getConfig() { public GwtApplicationConfiguration getConfig() {
GwtApplicationConfiguration cfg = GwtApplicationConfiguration cfg =
new GwtApplicationConfiguration(getWindowWidth(), new GwtApplicationConfiguration(getWindowWidth(),
getWindowHeight()); getWindowHeight());
cfg.canvasId = "map-canvas"; cfg.canvasId = "map-canvas";
cfg.stencil = true; cfg.stencil = true;
cfg.fps = 120; cfg.fps = 120;
return cfg; return cfg;
} }
@Override @Override
public ApplicationListener getApplicationListener() { public ApplicationListener getApplicationListener() {
Tile.SIZE = MapConfig.get().getTileSize(); Tile.SIZE = MapConfig.get().getTileSize();
return new GwtMap(); return new GwtMap();
} }
@Override @Override
public PreloaderCallback getPreloaderCallback() { public PreloaderCallback getPreloaderCallback() {
return new PreloaderCallback() { return new PreloaderCallback() {
@Override @Override
public void update(PreloaderState state) { public void update(PreloaderState state) {
} }
@Override @Override
public void error(String file) { public void error(String file) {
//log.debug("error loading " + file); //log.debug("error loading " + file);
} }
}; };
} }
private static native int getWindowWidth() /*-{ private static native int getWindowWidth() /*-{
return $wnd.innerWidth; return $wnd.innerWidth;
}-*/; }-*/;
private static native int getWindowHeight() /*-{ private static native int getWindowHeight() /*-{
return $wnd.innerHeight; return $wnd.innerHeight;
}-*/; }-*/;
} }

View File

@@ -1,33 +1,33 @@
<!doctype html> <!doctype html>
<html> <html>
<head> <head>
<title>vtm-web-js</title> <title>vtm-web-js</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> <meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" <meta name="viewport"
content="width=device-width, initial-scale=1, user-scalable=no"> content="width=device-width, initial-scale=1, user-scalable=no">
<link rel="stylesheet" type="text/css" href="default.css"> <link rel="stylesheet" type="text/css" href="default.css">
</head> </head>
<body oncontextmenu="return false;"> <body oncontextmenu="return false;">
<div id="canvas-area" <div id="canvas-area"
style="position: fixed; left: 0px; top: 0px; width: 100%; height: 100%;"> style="position: fixed; left: 0px; top: 0px; width: 100%; height: 100%;">
<canvas id="map-canvas"> <canvas id="map-canvas">
Your browser does not support the HTML5 canvas tag. Your browser does not support the HTML5 canvas tag.
</canvas> </canvas>
</div> </div>
<script type="text/javascript" src="map.js"></script> <script type="text/javascript" src="map.js"></script>
<script type="text/javascript" src="VtmWebApp/js/_tessellate.js"></script> <script type="text/javascript" src="VtmWebApp/js/_tessellate.js"></script>
<script type="text/javascript" src="VtmWebApp/js/tessellate.js"></script> <script type="text/javascript" src="VtmWebApp/js/tessellate.js"></script>
<script type="text/javascript" src="VtmWebApp/VtmWebApp.nocache.js"></script> <script type="text/javascript" src="VtmWebApp/VtmWebApp.nocache.js"></script>
<div id="credits"> <div id="credits">
<a href="https://github.com/hjanetzek/vtm">Source</a> | map data © <a <a href="https://github.com/hjanetzek/vtm">Source</a> | map data © <a
href="http://www.openstreemap.org">OpenStreetMap</a> contributors | <a href="http://www.openstreemap.org">OpenStreetMap</a> contributors | <a
href="http://www.opensciencemap.org">OpenScienceMap</a> href="http://www.opensciencemap.org">OpenScienceMap</a>
</div> </div>
</body> </body>
</html> </html>

View File

@@ -1,33 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.5.1//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.5.1/distro-source/core/src/gwt-module.dtd"> <!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.5.1//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.5.1/distro-source/core/src/gwt-module.dtd">
<module rename-to='com.badlogic.gdx.backends.gwt'> <module rename-to='com.badlogic.gdx.backends.gwt'>
<inherits name='com.google.gwt.user.User' /> <inherits name='com.google.gwt.user.User' />
<!-- Inherit edited chrome theme ("gwt"-prefixed classes only) for a little bit of default styling in the text input dialogs --> <!-- Inherit edited chrome theme ("gwt"-prefixed classes only) for a little bit of default styling in the text input dialogs -->
<inherits name='com.badlogic.gdx.backends.gwt.theme.chrome.Chrome'/> <inherits name='com.badlogic.gdx.backends.gwt.theme.chrome.Chrome'/>
<inherits name="com.google.gwt.http.HTTP"/> <inherits name="com.google.gwt.http.HTTP"/>
<inherits name="com.badlogic.gdx" /> <inherits name="com.badlogic.gdx" />
<inherits name="com.google.gwt.webgl.WebGL" /> <inherits name="com.google.gwt.webgl.WebGL" />
<inherits name="com.badlogic.gwtref.GwtReflect"/> <inherits name="com.badlogic.gwtref.GwtReflect"/>
<!-- <script src="soundmanager2-setup.js"/> <!-- <script src="soundmanager2-setup.js"/>
<script src="soundmanager2-jsmin.js"/> --> <script src="soundmanager2-jsmin.js"/> -->
<!-- <public path="gwt/resources"/> --> <!-- <public path="gwt/resources"/> -->
<super-source path="gwt/emu" /> <super-source path="gwt/emu" />
<source path="gwt"> <source path="gwt">
<exclude name="**/emu/**" /> <exclude name="**/emu/**" />
<exclude name="**/theme/**" /> <exclude name="**/theme/**" />
<exclude name="**/PreloaderBundleGenerator.java"/> <exclude name="**/PreloaderBundleGenerator.java"/>
<exclude name="**/FileWrapper.java"/> <exclude name="**/FileWrapper.java"/>
<exclude name="**/emu/**" /> <exclude name="**/emu/**" />
</source> </source>
<define-configuration-property name="gdx.assetpath" is-multi-valued="false"/> <define-configuration-property name="gdx.assetpath" is-multi-valued="false"/>
<define-configuration-property name="gdx.assetfilterclass" is-multi-valued="false"/> <define-configuration-property name="gdx.assetfilterclass" is-multi-valued="false"/>
<define-configuration-property name="gdx.assetoutputpath" is-multi-valued="false"/> <define-configuration-property name="gdx.assetoutputpath" is-multi-valued="false"/>
<generate-with class="com.badlogic.gdx.backends.gwt.preloader.PreloaderBundleGenerator"> <generate-with class="com.badlogic.gdx.backends.gwt.preloader.PreloaderBundleGenerator">
<when-type-assignable class="com.badlogic.gdx.backends.gwt.preloader.PreloaderBundle"/> <when-type-assignable class="com.badlogic.gdx.backends.gwt.preloader.PreloaderBundle"/>
</generate-with> </generate-with>
</module> </module>

View File

@@ -1,342 +1,342 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2011 See libgdx AUTHORS file. * Copyright 2011 See libgdx AUTHORS file.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
******************************************************************************/ ******************************************************************************/
package com.badlogic.gdx.backends.gwt; package com.badlogic.gdx.backends.gwt;
import org.oscim.gdx.client.GdxGL; import org.oscim.gdx.client.GdxGL;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Graphics; import com.badlogic.gdx.Graphics;
import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.GL30; import com.badlogic.gdx.graphics.GL30;
import com.badlogic.gdx.utils.GdxRuntimeException; import com.badlogic.gdx.utils.GdxRuntimeException;
import com.google.gwt.canvas.client.Canvas; import com.google.gwt.canvas.client.Canvas;
import com.google.gwt.dom.client.CanvasElement; import com.google.gwt.dom.client.CanvasElement;
import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.user.client.ui.Panel; import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.webgl.client.WebGLContextAttributes; import com.google.gwt.webgl.client.WebGLContextAttributes;
import com.google.gwt.webgl.client.WebGLRenderingContext; import com.google.gwt.webgl.client.WebGLRenderingContext;
public class GwtGraphics implements Graphics { public class GwtGraphics implements Graphics {
static final Logger log = LoggerFactory.getLogger(GwtGraphics.class); static final Logger log = LoggerFactory.getLogger(GwtGraphics.class);
CanvasElement canvas; CanvasElement canvas;
WebGLRenderingContext context; WebGLRenderingContext context;
GL20 gl; GL20 gl;
String extensions; String extensions;
float fps = 0; float fps = 0;
long lastTimeStamp = System.currentTimeMillis(); long lastTimeStamp = System.currentTimeMillis();
float deltaTime = 0; float deltaTime = 0;
float time = 0; float time = 0;
int frames; int frames;
GwtApplicationConfiguration config; GwtApplicationConfiguration config;
boolean inFullscreenMode = false; boolean inFullscreenMode = false;
double pixelRatio; double pixelRatio;
public GwtGraphics(Panel root, final GwtApplicationConfiguration config) { public GwtGraphics(Panel root, final GwtApplicationConfiguration config) {
this.pixelRatio = getDevicePixelRatioJSNI(); this.pixelRatio = getDevicePixelRatioJSNI();
if (config.canvasId == null) { if (config.canvasId == null) {
Canvas canvasWidget = Canvas.createIfSupported(); Canvas canvasWidget = Canvas.createIfSupported();
if (canvasWidget == null) if (canvasWidget == null)
throw new GdxRuntimeException("Canvas not supported"); throw new GdxRuntimeException("Canvas not supported");
canvas = canvasWidget.getCanvasElement(); canvas = canvasWidget.getCanvasElement();
root.add(canvasWidget); root.add(canvasWidget);
} else { } else {
canvas = (CanvasElement) Document.get().getElementById(config.canvasId); canvas = (CanvasElement) Document.get().getElementById(config.canvasId);
canvas.setWidth((int) (config.width * pixelRatio)); canvas.setWidth((int) (config.width * pixelRatio));
canvas.setHeight((int) (config.height * pixelRatio)); canvas.setHeight((int) (config.height * pixelRatio));
canvas.getStyle().setWidth(config.width, Unit.PX); canvas.getStyle().setWidth(config.width, Unit.PX);
canvas.getStyle().setHeight(config.height, Unit.PX); canvas.getStyle().setHeight(config.height, Unit.PX);
} }
this.config = config; this.config = config;
WebGLContextAttributes attributes = WebGLContextAttributes.create(); WebGLContextAttributes attributes = WebGLContextAttributes.create();
attributes.setAntialias(config.antialiasing); attributes.setAntialias(config.antialiasing);
attributes.setStencil(config.stencil); attributes.setStencil(config.stencil);
attributes.setAlpha(false); attributes.setAlpha(false);
attributes.setPremultipliedAlpha(false); attributes.setPremultipliedAlpha(false);
context = WebGLRenderingContext.getContext(canvas, attributes); context = WebGLRenderingContext.getContext(canvas, attributes);
if (context == null) if (context == null)
throw new GdxRuntimeException("Could not create Canvas for " + attributes); throw new GdxRuntimeException("Could not create Canvas for " + attributes);
context.viewport(0, 0, config.width, config.height); context.viewport(0, 0, config.width, config.height);
// this actually *enables* the option to use std derivatives in shader.. // this actually *enables* the option to use std derivatives in shader..
if (context.getExtension("OES_standard_derivatives") == null) { if (context.getExtension("OES_standard_derivatives") == null) {
log.error("Missing gl extension for OES_standard_derivatives"); log.error("Missing gl extension for OES_standard_derivatives");
} }
if (context.getExtension("WEBKIT_WEBGL_depth_texture") == null) { if (context.getExtension("WEBKIT_WEBGL_depth_texture") == null) {
log.error("Missing gl extension for WEBKIT_WEBGL_depth_texture"); log.error("Missing gl extension for WEBKIT_WEBGL_depth_texture");
} }
this.gl = config.useDebugGL ? new GwtGL20Debug(context) : new GdxGL(context); this.gl = config.useDebugGL ? new GwtGL20Debug(context) : new GdxGL(context);
} }
public static native double getDevicePixelRatioJSNI() /*-{ public static native double getDevicePixelRatioJSNI() /*-{
return $wnd.devicePixelRatio || 1.0; return $wnd.devicePixelRatio || 1.0;
}-*/; }-*/;
public static native int getWindowWidthJSNI() /*-{ public static native int getWindowWidthJSNI() /*-{
return $wnd.innerWidth; return $wnd.innerWidth;
}-*/; }-*/;
public static native int getWindowHeightJSNI() /*-{ public static native int getWindowHeightJSNI() /*-{
return $wnd.innerHeight; return $wnd.innerHeight;
}-*/; }-*/;
public WebGLRenderingContext getContext() { public WebGLRenderingContext getContext() {
return context; return context;
} }
@Override @Override
public GL20 getGL20() { public GL20 getGL20() {
return gl; return gl;
} }
@Override @Override
public int getWidth() { public int getWidth() {
return canvas.getWidth(); return canvas.getWidth();
} }
@Override @Override
public int getHeight() { public int getHeight() {
return canvas.getHeight(); return canvas.getHeight();
} }
@Override @Override
public float getDeltaTime() { public float getDeltaTime() {
return deltaTime; return deltaTime;
} }
@Override @Override
public int getFramesPerSecond() { public int getFramesPerSecond() {
return (int) fps; return (int) fps;
} }
@Override @Override
public GraphicsType getType() { public GraphicsType getType() {
return GraphicsType.WebGL; return GraphicsType.WebGL;
} }
@Override @Override
public float getPpiX() { public float getPpiX() {
return 96; return 96;
} }
@Override @Override
public float getPpiY() { public float getPpiY() {
return 96; return 96;
} }
@Override @Override
public float getPpcX() { public float getPpcX() {
return 96 / 2.54f; return 96 / 2.54f;
} }
@Override @Override
public float getPpcY() { public float getPpcY() {
return 96 / 2.54f; return 96 / 2.54f;
} }
@Override @Override
public boolean supportsDisplayModeChange() { public boolean supportsDisplayModeChange() {
return true; return true;
} }
@Override @Override
public DisplayMode[] getDisplayModes() { public DisplayMode[] getDisplayModes() {
return new DisplayMode[] { new DisplayMode(getScreenWidthJSNI(), getScreenHeightJSNI(), 60, return new DisplayMode[] { new DisplayMode(getScreenWidthJSNI(), getScreenHeightJSNI(), 60,
8) { 8) {
} }; } };
} }
private native int getScreenWidthJSNI() /*-{ private native int getScreenWidthJSNI() /*-{
return $wnd.screen.width; return $wnd.screen.width;
}-*/; }-*/;
private native int getScreenHeightJSNI() /*-{ private native int getScreenHeightJSNI() /*-{
return $wnd.screen.height; return $wnd.screen.height;
}-*/; }-*/;
private native boolean isFullscreenJSNI() /*-{ private native boolean isFullscreenJSNI() /*-{
if ("webkitIsFullScreen" in $doc) { if ("webkitIsFullScreen" in $doc) {
return $doc.webkitIsFullScreen; return $doc.webkitIsFullScreen;
} }
if ("mozFullScreen" in $doc) { if ("mozFullScreen" in $doc) {
return $doc.mozFullScreen; return $doc.mozFullScreen;
} }
return false return false
}-*/; }-*/;
private void fullscreenChanged() { private void fullscreenChanged() {
if (!isFullscreen()) { if (!isFullscreen()) {
canvas.setWidth(config.width); canvas.setWidth(config.width);
canvas.setHeight(config.height); canvas.setHeight(config.height);
} }
} }
private native boolean setFullscreenJSNI(GwtGraphics graphics, CanvasElement element) /*-{ private native boolean setFullscreenJSNI(GwtGraphics graphics, CanvasElement element) /*-{
if (element.webkitRequestFullScreen) { if (element.webkitRequestFullScreen) {
element.width = $wnd.screen.width; element.width = $wnd.screen.width;
element.height = $wnd.screen.height; element.height = $wnd.screen.height;
element.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT); element.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
$doc $doc
.addEventListener( .addEventListener(
"webkitfullscreenchange", "webkitfullscreenchange",
function() { function() {
graphics.@com.badlogic.gdx.backends.gwt.GwtGraphics::fullscreenChanged()(); graphics.@com.badlogic.gdx.backends.gwt.GwtGraphics::fullscreenChanged()();
}, false); }, false);
return true; return true;
} }
if (element.mozRequestFullScreen) { if (element.mozRequestFullScreen) {
element.width = $wnd.screen.width; element.width = $wnd.screen.width;
element.height = $wnd.screen.height; element.height = $wnd.screen.height;
element.mozRequestFullScreen(); element.mozRequestFullScreen();
$doc $doc
.addEventListener( .addEventListener(
"mozfullscreenchange", "mozfullscreenchange",
function() { function() {
graphics.@com.badlogic.gdx.backends.gwt.GwtGraphics::fullscreenChanged()(); graphics.@com.badlogic.gdx.backends.gwt.GwtGraphics::fullscreenChanged()();
}, false); }, false);
return true; return true;
} }
return false; return false;
}-*/; }-*/;
private native void exitFullscreen() /*-{ private native void exitFullscreen() /*-{
if ($doc.webkitExitFullscreen) if ($doc.webkitExitFullscreen)
$doc.webkitExitFullscreen(); $doc.webkitExitFullscreen();
if ($doc.mozExitFullscreen) if ($doc.mozExitFullscreen)
$doc.mozExitFullscreen(); $doc.mozExitFullscreen();
}-*/; }-*/;
@Override @Override
public DisplayMode getDesktopDisplayMode() { public DisplayMode getDesktopDisplayMode() {
return new DisplayMode(getScreenWidthJSNI(), getScreenHeightJSNI(), 60, 8) { return new DisplayMode(getScreenWidthJSNI(), getScreenHeightJSNI(), 60, 8) {
}; };
} }
@Override @Override
public boolean setDisplayMode(DisplayMode displayMode) { public boolean setDisplayMode(DisplayMode displayMode) {
if (displayMode.width != getScreenWidthJSNI() if (displayMode.width != getScreenWidthJSNI()
&& displayMode.height != getScreenHeightJSNI()) && displayMode.height != getScreenHeightJSNI())
return false; return false;
return setFullscreenJSNI(this, canvas); return setFullscreenJSNI(this, canvas);
} }
@Override @Override
public boolean setDisplayMode(int width, int height, boolean fullscreen) { public boolean setDisplayMode(int width, int height, boolean fullscreen) {
if (fullscreen) { if (fullscreen) {
if (width != getScreenWidthJSNI() && height != getScreenHeightJSNI()) if (width != getScreenWidthJSNI() && height != getScreenHeightJSNI())
return false; return false;
return setFullscreenJSNI(this, canvas); return setFullscreenJSNI(this, canvas);
} else { } else {
if (isFullscreenJSNI()) if (isFullscreenJSNI())
exitFullscreen(); exitFullscreen();
canvas.setWidth(width); canvas.setWidth(width);
canvas.setHeight(height); canvas.setHeight(height);
canvas.getStyle().setWidth(width, Unit.PX); canvas.getStyle().setWidth(width, Unit.PX);
canvas.getStyle().setHeight(height, Unit.PX); canvas.getStyle().setHeight(height, Unit.PX);
return true; return true;
} }
} }
@Override @Override
public BufferFormat getBufferFormat() { public BufferFormat getBufferFormat() {
return new BufferFormat(8, 8, 8, 0, 16, config.stencil ? 8 : 0, 0, false); return new BufferFormat(8, 8, 8, 0, 16, config.stencil ? 8 : 0, 0, false);
} }
@Override @Override
public boolean supportsExtension(String extension) { public boolean supportsExtension(String extension) {
if (extensions == null) if (extensions == null)
extensions = Gdx.gl.glGetString(GL20.GL_EXTENSIONS); extensions = Gdx.gl.glGetString(GL20.GL_EXTENSIONS);
return extensions.contains(extension); return extensions.contains(extension);
} }
public void update() { public void update() {
long currTimeStamp = System.currentTimeMillis(); long currTimeStamp = System.currentTimeMillis();
deltaTime = (currTimeStamp - lastTimeStamp) / 1000.0f; deltaTime = (currTimeStamp - lastTimeStamp) / 1000.0f;
lastTimeStamp = currTimeStamp; lastTimeStamp = currTimeStamp;
time += deltaTime; time += deltaTime;
frames++; frames++;
if (time > 1) { if (time > 1) {
this.fps = frames; this.fps = frames;
time = 0; time = 0;
frames = 0; frames = 0;
} }
} }
@Override @Override
public void setTitle(String title) { public void setTitle(String title) {
} }
@Override @Override
public void setVSync(boolean vsync) { public void setVSync(boolean vsync) {
} }
@Override @Override
public float getDensity() { public float getDensity() {
return 96.0f / 160; return 96.0f / 160;
} }
@Override @Override
public void setContinuousRendering(boolean isContinuous) { public void setContinuousRendering(boolean isContinuous) {
} }
@Override @Override
public boolean isContinuousRendering() { public boolean isContinuousRendering() {
return false; return false;
} }
@Override @Override
public void requestRendering() { public void requestRendering() {
} }
@Override @Override
public float getRawDeltaTime() { public float getRawDeltaTime() {
return getDeltaTime(); return getDeltaTime();
} }
@Override @Override
public boolean isFullscreen() { public boolean isFullscreen() {
return isFullscreenJSNI(); return isFullscreenJSNI();
} }
@Override @Override
public boolean isGL30Available() { public boolean isGL30Available() {
return false; return false;
} }
@Override @Override
public GL30 getGL30() { public GL30 getGL30() {
return null; return null;
} }
@Override @Override
public long getFrameId() { public long getFrameId() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return 0; return 0;
} }
} }

View File

@@ -1,377 +1,377 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2011 See libgdx AUTHORS file. * Copyright 2011 See libgdx AUTHORS file.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
******************************************************************************/ ******************************************************************************/
package com.badlogic.gdx.graphics; package com.badlogic.gdx.graphics;
import java.nio.Buffer; import java.nio.Buffer;
import java.nio.IntBuffer; import java.nio.IntBuffer;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import com.badlogic.gdx.backends.gwt.GwtFileHandle; import com.badlogic.gdx.backends.gwt.GwtFileHandle;
import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.utils.BufferUtils; import com.badlogic.gdx.utils.BufferUtils;
import com.badlogic.gdx.utils.Disposable; import com.badlogic.gdx.utils.Disposable;
import com.badlogic.gdx.utils.GdxRuntimeException; import com.badlogic.gdx.utils.GdxRuntimeException;
import com.google.gwt.canvas.client.Canvas; import com.google.gwt.canvas.client.Canvas;
import com.google.gwt.canvas.dom.client.CanvasPixelArray; import com.google.gwt.canvas.dom.client.CanvasPixelArray;
import com.google.gwt.canvas.dom.client.Context2d; import com.google.gwt.canvas.dom.client.Context2d;
import com.google.gwt.canvas.dom.client.Context2d.Composite; import com.google.gwt.canvas.dom.client.Context2d.Composite;
import com.google.gwt.dom.client.CanvasElement; import com.google.gwt.dom.client.CanvasElement;
import com.google.gwt.dom.client.ImageElement; import com.google.gwt.dom.client.ImageElement;
public class Pixmap implements Disposable { public class Pixmap implements Disposable {
public static Map<Integer, Pixmap> pixmaps = new HashMap<Integer, Pixmap>(); public static Map<Integer, Pixmap> pixmaps = new HashMap<Integer, Pixmap>();
static int nextId = 0; static int nextId = 0;
/** Different pixel formats. /** Different pixel formats.
* *
* @author mzechner */ * @author mzechner */
public enum Format { public enum Format {
Alpha, Intensity, LuminanceAlpha, RGB565, RGBA4444, RGB888, RGBA8888; Alpha, Intensity, LuminanceAlpha, RGB565, RGBA4444, RGB888, RGBA8888;
} }
/** Blending functions to be set with {@link Pixmap#setBlending}. /** Blending functions to be set with {@link Pixmap#setBlending}.
* @author mzechner */ * @author mzechner */
public enum Blending { public enum Blending {
None, SourceOver None, SourceOver
} }
/** Filters to be used with {@link Pixmap#drawPixmap(Pixmap, int, int, int, int, int, int, int, int)}. /** Filters to be used with {@link Pixmap#drawPixmap(Pixmap, int, int, int, int, int, int, int, int)}.
* *
* @author mzechner */ * @author mzechner */
public enum Filter { public enum Filter {
NearestNeighbour, BiLinear NearestNeighbour, BiLinear
} }
int width; int width;
int height; int height;
Format format; Format format;
Canvas canvas; Canvas canvas;
Context2d context; Context2d context;
int id; int id;
IntBuffer buffer; IntBuffer buffer;
int r = 255, g = 255, b = 255; int r = 255, g = 255, b = 255;
float a; float a;
String color = make(r, g, b, a); String color = make(r, g, b, a);
static Blending blending; static Blending blending;
CanvasPixelArray pixels; CanvasPixelArray pixels;
public Context2d getContext(){ public Context2d getContext(){
return context; return context;
} }
public Pixmap (FileHandle file) { public Pixmap (FileHandle file) {
GwtFileHandle gwtFile = (GwtFileHandle)file; GwtFileHandle gwtFile = (GwtFileHandle)file;
ImageElement img = gwtFile.preloader.images.get(file.path()); ImageElement img = gwtFile.preloader.images.get(file.path());
if (img == null) throw new GdxRuntimeException("Couldn't load image '" + file.path() + "', file does not exist"); if (img == null) throw new GdxRuntimeException("Couldn't load image '" + file.path() + "', file does not exist");
create(img.getWidth(), img.getHeight(), Format.RGBA8888); create(img.getWidth(), img.getHeight(), Format.RGBA8888);
context.setGlobalCompositeOperation(Composite.COPY); context.setGlobalCompositeOperation(Composite.COPY);
context.drawImage(img, 0, 0); context.drawImage(img, 0, 0);
context.setGlobalCompositeOperation(getComposite()); context.setGlobalCompositeOperation(getComposite());
} }
private static Composite getComposite () { private static Composite getComposite () {
return blending == Blending.None ? Composite.COPY : Composite.SOURCE_OVER; return blending == Blending.None ? Composite.COPY : Composite.SOURCE_OVER;
} }
public Pixmap (ImageElement img) { public Pixmap (ImageElement img) {
create(img.getWidth(), img.getHeight(), Format.RGBA8888); create(img.getWidth(), img.getHeight(), Format.RGBA8888);
context.drawImage(img, 0, 0); context.drawImage(img, 0, 0);
} }
public Pixmap (int width, int height, Format format) { public Pixmap (int width, int height, Format format) {
create(width, height, format); create(width, height, format);
} }
private void create (int width, int height, Format format2) { private void create (int width, int height, Format format2) {
this.width = width; this.width = width;
this.height = height; this.height = height;
this.format = Format.RGBA8888; this.format = Format.RGBA8888;
canvas = Canvas.createIfSupported(); canvas = Canvas.createIfSupported();
canvas.getCanvasElement().setWidth(width); canvas.getCanvasElement().setWidth(width);
canvas.getCanvasElement().setHeight(height); canvas.getCanvasElement().setHeight(height);
context = canvas.getContext2d(); context = canvas.getContext2d();
context.setGlobalCompositeOperation(getComposite()); context.setGlobalCompositeOperation(getComposite());
buffer = BufferUtils.newIntBuffer(1); buffer = BufferUtils.newIntBuffer(1);
id = nextId++; id = nextId++;
buffer.put(0, id); buffer.put(0, id);
pixmaps.put(id, this); pixmaps.put(id, this);
} }
public static String make (int r2, int g2, int b2, float a2) { public static String make (int r2, int g2, int b2, float a2) {
return "rgba(" + r2 + "," + g2 + "," + b2 + "," + a2 + ")"; return "rgba(" + r2 + "," + g2 + "," + b2 + "," + a2 + ")";
} }
/** Sets the type of {@link Blending} to be used for all operations. Default is {@link Blending#SourceOver}. /** Sets the type of {@link Blending} to be used for all operations. Default is {@link Blending#SourceOver}.
* @param blending the blending type */ * @param blending the blending type */
public static void setBlending (Blending blending) { public static void setBlending (Blending blending) {
Pixmap.blending = blending; Pixmap.blending = blending;
Composite composite = getComposite(); Composite composite = getComposite();
for (Pixmap pixmap : pixmaps.values()) { for (Pixmap pixmap : pixmaps.values()) {
pixmap.context.setGlobalCompositeOperation(composite); pixmap.context.setGlobalCompositeOperation(composite);
} }
} }
/** @return the currently set {@link Blending} */ /** @return the currently set {@link Blending} */
public static Blending getBlending () { public static Blending getBlending () {
return blending; return blending;
} }
/** Sets the type of interpolation {@link Filter} to be used in conjunction with /** Sets the type of interpolation {@link Filter} to be used in conjunction with
* {@link Pixmap#drawPixmap(Pixmap, int, int, int, int, int, int, int, int)}. * {@link Pixmap#drawPixmap(Pixmap, int, int, int, int, int, int, int, int)}.
* @param filter the filter. */ * @param filter the filter. */
public static void setFilter (Filter filter) { public static void setFilter (Filter filter) {
} }
public Format getFormat () { public Format getFormat () {
return format; return format;
} }
public int getGLInternalFormat () { public int getGLInternalFormat () {
return GL20.GL_RGBA; return GL20.GL_RGBA;
} }
public int getGLFormat () { public int getGLFormat () {
return GL20.GL_RGBA; return GL20.GL_RGBA;
} }
public int getGLType () { public int getGLType () {
return GL20.GL_UNSIGNED_BYTE; return GL20.GL_UNSIGNED_BYTE;
} }
public int getWidth () { public int getWidth () {
return width; return width;
} }
public int getHeight () { public int getHeight () {
return height; return height;
} }
public Buffer getPixels () { public Buffer getPixels () {
return buffer; return buffer;
} }
@Override @Override
public void dispose () { public void dispose () {
pixmaps.remove(id); pixmaps.remove(id);
} }
public CanvasElement getCanvasElement () { public CanvasElement getCanvasElement () {
return canvas.getCanvasElement(); return canvas.getCanvasElement();
} }
/** Sets the color for the following drawing operations /** Sets the color for the following drawing operations
* @param color the color, encoded as RGBA8888 */ * @param color the color, encoded as RGBA8888 */
public void setColor (int color) { public void setColor (int color) {
r = (color >>> 24) & 0xff; r = (color >>> 24) & 0xff;
g = (color >>> 16) & 0xff; g = (color >>> 16) & 0xff;
b = (color >>> 8) & 0xff; b = (color >>> 8) & 0xff;
a = (color & 0xff) / 255f; a = (color & 0xff) / 255f;
this.color = make(r, g, b, a); this.color = make(r, g, b, a);
context.setFillStyle(this.color); context.setFillStyle(this.color);
context.setStrokeStyle(this.color); context.setStrokeStyle(this.color);
} }
/** Sets the color for the following drawing operations. /** Sets the color for the following drawing operations.
* *
* @param r The red component. * @param r The red component.
* @param g The green component. * @param g The green component.
* @param b The blue component. * @param b The blue component.
* @param a The alpha component. */ * @param a The alpha component. */
public void setColor (float r, float g, float b, float a) { public void setColor (float r, float g, float b, float a) {
this.r = (int)(r * 255); this.r = (int)(r * 255);
this.g = (int)(g * 255); this.g = (int)(g * 255);
this.b = (int)(b * 255); this.b = (int)(b * 255);
this.a = a; this.a = a;
color = make(this.r, this.g, this.b, this.a); color = make(this.r, this.g, this.b, this.a);
context.setFillStyle(color); context.setFillStyle(color);
context.setStrokeStyle(this.color); context.setStrokeStyle(this.color);
} }
/** Sets the color for the following drawing operations. /** Sets the color for the following drawing operations.
* @param color The color. */ * @param color The color. */
public void setColor (Color color) { public void setColor (Color color) {
setColor(color.r, color.g, color.b, color.a); setColor(color.r, color.g, color.b, color.a);
} }
/** Fills the complete bitmap with the currently set color. */ /** Fills the complete bitmap with the currently set color. */
public void fill () { public void fill () {
context.fillRect(0, 0, getWidth(), getHeight()); context.fillRect(0, 0, getWidth(), getHeight());
} }
// /** // /**
// * Sets the width in pixels of strokes. // * Sets the width in pixels of strokes.
// * // *
// * @param width The stroke width in pixels. // * @param width The stroke width in pixels.
// */ // */
// public void setStrokeWidth (int width); // public void setStrokeWidth (int width);
/** Draws a line between the given coordinates using the currently set color. /** Draws a line between the given coordinates using the currently set color.
* *
* @param x The x-coodinate of the first point * @param x The x-coodinate of the first point
* @param y The y-coordinate of the first point * @param y The y-coordinate of the first point
* @param x2 The x-coordinate of the first point * @param x2 The x-coordinate of the first point
* @param y2 The y-coordinate of the first point */ * @param y2 The y-coordinate of the first point */
public void drawLine (int x, int y, int x2, int y2) { public void drawLine (int x, int y, int x2, int y2) {
context.beginPath(); context.beginPath();
context.moveTo(x, y); context.moveTo(x, y);
context.lineTo(x2, y2); context.lineTo(x2, y2);
context.stroke(); context.stroke();
context.closePath(); context.closePath();
} }
/** Draws a rectangle outline starting at x, y extending by width to the right and by height downwards (y-axis points downwards) /** Draws a rectangle outline starting at x, y extending by width to the right and by height downwards (y-axis points downwards)
* using the current color. * using the current color.
* *
* @param x The x coordinate * @param x The x coordinate
* @param y The y coordinate * @param y The y coordinate
* @param width The width in pixels * @param width The width in pixels
* @param height The height in pixels */ * @param height The height in pixels */
public void drawRectangle (int x, int y, int width, int height) { public void drawRectangle (int x, int y, int width, int height) {
context.beginPath(); context.beginPath();
context.rect(x, y, width, height); context.rect(x, y, width, height);
context.stroke(); context.stroke();
context.closePath(); context.closePath();
} }
/** Draws an area form another Pixmap to this Pixmap. /** Draws an area form another Pixmap to this Pixmap.
* *
* @param pixmap The other Pixmap * @param pixmap The other Pixmap
* @param x The target x-coordinate (top left corner) * @param x The target x-coordinate (top left corner)
* @param y The target y-coordinate (top left corner) */ * @param y The target y-coordinate (top left corner) */
public void drawPixmap (Pixmap pixmap, int x, int y) { public void drawPixmap (Pixmap pixmap, int x, int y) {
context.drawImage(pixmap.getCanvasElement(), x, y); context.drawImage(pixmap.getCanvasElement(), x, y);
} }
/** Draws an area form another Pixmap to this Pixmap. /** Draws an area form another Pixmap to this Pixmap.
* *
* @param pixmap The other Pixmap * @param pixmap The other Pixmap
* @param x The target x-coordinate (top left corner) * @param x The target x-coordinate (top left corner)
* @param y The target y-coordinate (top left corner) * @param y The target y-coordinate (top left corner)
* @param srcx The source x-coordinate (top left corner) * @param srcx The source x-coordinate (top left corner)
* @param srcy The source y-coordinate (top left corner); * @param srcy The source y-coordinate (top left corner);
* @param srcWidth The width of the area form the other Pixmap in pixels * @param srcWidth The width of the area form the other Pixmap in pixels
* @param srcHeight The height of the area form the other Pixmap in pixles */ * @param srcHeight The height of the area form the other Pixmap in pixles */
public void drawPixmap (Pixmap pixmap, int x, int y, int srcx, int srcy, int srcWidth, int srcHeight) { public void drawPixmap (Pixmap pixmap, int x, int y, int srcx, int srcy, int srcWidth, int srcHeight) {
context.drawImage(pixmap.getCanvasElement(), srcx, srcy, srcWidth, srcHeight, x, y, srcWidth, srcHeight); context.drawImage(pixmap.getCanvasElement(), srcx, srcy, srcWidth, srcHeight, x, y, srcWidth, srcHeight);
} }
/** Draws an area form another Pixmap to this Pixmap. This will automatically scale and stretch the source image to the /** Draws an area form another Pixmap to this Pixmap. This will automatically scale and stretch the source image to the
* specified target rectangle. Use {@link Pixmap#setFilter(Filter)} to specify the type of filtering to be used (nearest * specified target rectangle. Use {@link Pixmap#setFilter(Filter)} to specify the type of filtering to be used (nearest
* neighbour or bilinear). * neighbour or bilinear).
* *
* @param pixmap The other Pixmap * @param pixmap The other Pixmap
* @param srcx The source x-coordinate (top left corner) * @param srcx The source x-coordinate (top left corner)
* @param srcy The source y-coordinate (top left corner); * @param srcy The source y-coordinate (top left corner);
* @param srcWidth The width of the area form the other Pixmap in pixels * @param srcWidth The width of the area form the other Pixmap in pixels
* @param srcHeight The height of the area form the other Pixmap in pixles * @param srcHeight The height of the area form the other Pixmap in pixles
* @param dstx The target x-coordinate (top left corner) * @param dstx The target x-coordinate (top left corner)
* @param dsty The target y-coordinate (top left corner) * @param dsty The target y-coordinate (top left corner)
* @param dstWidth The target width * @param dstWidth The target width
* @param dstHeight the target height */ * @param dstHeight the target height */
public void drawPixmap (Pixmap pixmap, int srcx, int srcy, int srcWidth, int srcHeight, int dstx, int dsty, int dstWidth, public void drawPixmap (Pixmap pixmap, int srcx, int srcy, int srcWidth, int srcHeight, int dstx, int dsty, int dstWidth,
int dstHeight) { int dstHeight) {
context.drawImage(pixmap.getCanvasElement(), srcx, srcy, srcWidth, srcHeight, dstx, dsty, dstWidth, dstHeight); context.drawImage(pixmap.getCanvasElement(), srcx, srcy, srcWidth, srcHeight, dstx, dsty, dstWidth, dstHeight);
} }
/** Fills a rectangle starting at x, y extending by width to the right and by height downwards (y-axis points downwards) using /** Fills a rectangle starting at x, y extending by width to the right and by height downwards (y-axis points downwards) using
* the current color. * the current color.
* *
* @param x The x coordinate * @param x The x coordinate
* @param y The y coordinate * @param y The y coordinate
* @param width The width in pixels * @param width The width in pixels
* @param height The height in pixels */ * @param height The height in pixels */
public void fillRectangle (int x, int y, int width, int height) { public void fillRectangle (int x, int y, int width, int height) {
context.fillRect(x, y, width, height); context.fillRect(x, y, width, height);
} }
/** Draws a circle outline with the center at x,y and a radius using the current color and stroke width. /** Draws a circle outline with the center at x,y and a radius using the current color and stroke width.
* *
* @param x The x-coordinate of the center * @param x The x-coordinate of the center
* @param y The y-coordinate of the center * @param y The y-coordinate of the center
* @param radius The radius in pixels */ * @param radius The radius in pixels */
public void drawCircle (int x, int y, int radius) { public void drawCircle (int x, int y, int radius) {
context.beginPath(); context.beginPath();
context.arc(x, y, radius, 0, 2 * Math.PI, false); context.arc(x, y, radius, 0, 2 * Math.PI, false);
context.stroke(); context.stroke();
context.closePath(); context.closePath();
} }
/** Fills a circle with the center at x,y and a radius using the current color. /** Fills a circle with the center at x,y and a radius using the current color.
* *
* @param x The x-coordinate of the center * @param x The x-coordinate of the center
* @param y The y-coordinate of the center * @param y The y-coordinate of the center
* @param radius The radius in pixels */ * @param radius The radius in pixels */
public void fillCircle (int x, int y, int radius) { public void fillCircle (int x, int y, int radius) {
context.beginPath(); context.beginPath();
context.arc(x, y, radius, 0, 2 * Math.PI, false); context.arc(x, y, radius, 0, 2 * Math.PI, false);
context.fill(); context.fill();
context.closePath(); context.closePath();
} }
/** Fills a triangle with vertices at x1,y1 and x2,y2 and x3,y3 using the current color. /** Fills a triangle with vertices at x1,y1 and x2,y2 and x3,y3 using the current color.
* *
* @param x1 The x-coordinate of vertex 1 * @param x1 The x-coordinate of vertex 1
* @param y1 The y-coordinate of vertex 1 * @param y1 The y-coordinate of vertex 1
* @param x2 The x-coordinate of vertex 2 * @param x2 The x-coordinate of vertex 2
* @param y2 The y-coordinate of vertex 2 * @param y2 The y-coordinate of vertex 2
* @param x3 The x-coordinate of vertex 3 * @param x3 The x-coordinate of vertex 3
* @param y3 The y-coordinate of vertex 3 */ * @param y3 The y-coordinate of vertex 3 */
public void fillTriangle (int x1, int y1, int x2, int y2, int x3, int y3) { public void fillTriangle (int x1, int y1, int x2, int y2, int x3, int y3) {
context.beginPath(); context.beginPath();
context.moveTo(x1,y1); context.moveTo(x1,y1);
context.lineTo(x2,y2); context.lineTo(x2,y2);
context.lineTo(x3,y3); context.lineTo(x3,y3);
context.lineTo(x1,y1); context.lineTo(x1,y1);
context.fill(); context.fill();
context.closePath(); context.closePath();
} }
/** Returns the 32-bit RGBA8888 value of the pixel at x, y. For Alpha formats the RGB components will be one. /** Returns the 32-bit RGBA8888 value of the pixel at x, y. For Alpha formats the RGB components will be one.
* *
* @param x The x-coordinate * @param x The x-coordinate
* @param y The y-coordinate * @param y The y-coordinate
* @return The pixel color in RGBA8888 format. */ * @return The pixel color in RGBA8888 format. */
public int getPixel (int x, int y) { public int getPixel (int x, int y) {
if (pixels == null) pixels = context.getImageData(0, 0, width, height).getData(); if (pixels == null) pixels = context.getImageData(0, 0, width, height).getData();
int i = x * 4 + y * width * 4; int i = x * 4 + y * width * 4;
int r = pixels.get(i + 0) & 0xff; int r = pixels.get(i + 0) & 0xff;
int g = pixels.get(i + 1) & 0xff; int g = pixels.get(i + 1) & 0xff;
int b = pixels.get(i + 2) & 0xff; int b = pixels.get(i + 2) & 0xff;
int a = pixels.get(i + 3) & 0xff; int a = pixels.get(i + 3) & 0xff;
return (r << 24) | (g << 16) | (b << 8) | (a); return (r << 24) | (g << 16) | (b << 8) | (a);
} }
/** Draws a pixel at the given location with the current color. /** Draws a pixel at the given location with the current color.
* *
* @param x the x-coordinate * @param x the x-coordinate
* @param y the y-coordinate */ * @param y the y-coordinate */
public void drawPixel (int x, int y) { public void drawPixel (int x, int y) {
context.fillRect(x, y, 1, 1); context.fillRect(x, y, 1, 1);
} }
/** Draws a pixel at the given location with the given color. /** Draws a pixel at the given location with the given color.
* *
* @param x the x-coordinate * @param x the x-coordinate
* @param y the y-coordinate * @param y the y-coordinate
* @param color the color in RGBA8888 format. */ * @param color the color in RGBA8888 format. */
public void drawPixel (int x, int y, int color) { public void drawPixel (int x, int y, int color) {
setColor(color); setColor(color);
drawPixel(x, y); drawPixel(x, y);
} }
} }

View File

@@ -1,62 +1,62 @@
/* /*
* Copyright 2014 Hannes Janetzek * Copyright 2014 Hannes Janetzek
* *
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
* *
* This program is free software: you can redistribute it and/or modify it under the * This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software * terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version. * Foundation, either version 3 of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT ANY * This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License along with * You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>. * this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.oscim.tiling.source.geojson; package org.oscim.tiling.source.geojson;
import java.util.Map; import java.util.Map;
import org.oscim.core.MapElement; import org.oscim.core.MapElement;
import org.oscim.core.Tag; import org.oscim.core.Tag;
import org.oscim.tiling.ITileDataSource; import org.oscim.tiling.ITileDataSource;
import org.oscim.tiling.source.JsonTileDataSource; import org.oscim.tiling.source.JsonTileDataSource;
import org.oscim.tiling.source.UrlTileSource; import org.oscim.tiling.source.UrlTileSource;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public abstract class GeoJsonTileSource extends UrlTileSource { public abstract class GeoJsonTileSource extends UrlTileSource {
static final Logger log = LoggerFactory.getLogger(GeoJsonTileSource.class); static final Logger log = LoggerFactory.getLogger(GeoJsonTileSource.class);
public GeoJsonTileSource(String url) { public GeoJsonTileSource(String url) {
super(url, "/{Z}/{X}/{Y}.json"); super(url, "/{Z}/{X}/{Y}.json");
} }
@Override @Override
public ITileDataSource getDataSource() { public ITileDataSource getDataSource() {
return new JsonTileDataSource(this); return new JsonTileDataSource(this);
} }
public Tag getFeatureTag() { public Tag getFeatureTag() {
return null; return null;
} }
/** allow overriding tag handling */ /** allow overriding tag handling */
public abstract void decodeTags(MapElement mapElement, Map<String, Object> properties); public abstract void decodeTags(MapElement mapElement, Map<String, Object> properties);
public Tag rewriteTag(String key, Object value) { public Tag rewriteTag(String key, Object value) {
if (value == null) if (value == null)
return null; return null;
String val = (value instanceof String) ? (String) value : String.valueOf(value); String val = (value instanceof String) ? (String) value : String.valueOf(value);
return new Tag(key, val); return new Tag(key, val);
} }
/** modify mapElement before process() */ /** modify mapElement before process() */
public void postGeomHook(MapElement mapElement) { public void postGeomHook(MapElement mapElement) {
} }
} }

File diff suppressed because it is too large Load Diff

View File

@@ -1,259 +1,259 @@
/* /*
* Copyright 2012 osmdroid authors: Nicolas Gramlich, Theodore Hong, Fred Eisele * Copyright 2012 osmdroid authors: Nicolas Gramlich, Theodore Hong, Fred Eisele
* *
* Copyright 2013 Hannes Janetzek * Copyright 2013 Hannes Janetzek
* Copyright 2016 devemux86 * Copyright 2016 devemux86
* *
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
* *
* This program is free software: you can redistribute it and/or modify it under the * This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software * terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version. * Foundation, either version 3 of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT ANY * This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License along with * You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>. * this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.oscim.layers.marker; package org.oscim.layers.marker;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.oscim.core.Box; import org.oscim.core.Box;
import org.oscim.core.Point; import org.oscim.core.Point;
import org.oscim.event.Gesture; import org.oscim.event.Gesture;
import org.oscim.event.GestureListener; import org.oscim.event.GestureListener;
import org.oscim.event.MotionEvent; import org.oscim.event.MotionEvent;
import org.oscim.map.Map; import org.oscim.map.Map;
import org.oscim.map.Viewport; import org.oscim.map.Viewport;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class ItemizedLayer<Item extends MarkerItem> extends MarkerLayer<Item> public class ItemizedLayer<Item extends MarkerItem> extends MarkerLayer<Item>
implements GestureListener { implements GestureListener {
static final Logger log = LoggerFactory.getLogger(ItemizedLayer.class); static final Logger log = LoggerFactory.getLogger(ItemizedLayer.class);
protected final List<Item> mItemList; protected final List<Item> mItemList;
protected final Point mTmpPoint = new Point(); protected final Point mTmpPoint = new Point();
protected OnItemGestureListener<Item> mOnItemGestureListener; protected OnItemGestureListener<Item> mOnItemGestureListener;
protected int mDrawnItemsLimit = Integer.MAX_VALUE; protected int mDrawnItemsLimit = Integer.MAX_VALUE;
public ItemizedLayer(Map map, MarkerSymbol defaulMarker) { public ItemizedLayer(Map map, MarkerSymbol defaulMarker) {
this(map, new ArrayList<Item>(), defaulMarker, null); this(map, new ArrayList<Item>(), defaulMarker, null);
} }
public ItemizedLayer(Map map, List<Item> list, public ItemizedLayer(Map map, List<Item> list,
MarkerSymbol defaultMarker, MarkerSymbol defaultMarker,
OnItemGestureListener<Item> listener) { OnItemGestureListener<Item> listener) {
super(map, defaultMarker); super(map, defaultMarker);
mItemList = list; mItemList = list;
mOnItemGestureListener = listener; mOnItemGestureListener = listener;
populate(); populate();
} }
public void setOnItemGestureListener(OnItemGestureListener<Item> listener) { public void setOnItemGestureListener(OnItemGestureListener<Item> listener) {
mOnItemGestureListener = listener; mOnItemGestureListener = listener;
} }
@Override @Override
protected Item createItem(int index) { protected Item createItem(int index) {
return mItemList.get(index); return mItemList.get(index);
} }
@Override @Override
public int size() { public int size() {
return Math.min(mItemList.size(), mDrawnItemsLimit); return Math.min(mItemList.size(), mDrawnItemsLimit);
} }
public boolean addItem(Item item) { public boolean addItem(Item item) {
final boolean result = mItemList.add(item); final boolean result = mItemList.add(item);
populate(); populate();
return result; return result;
} }
public void addItem(int location, Item item) { public void addItem(int location, Item item) {
mItemList.add(location, item); mItemList.add(location, item);
} }
public boolean addItems(List<Item> items) { public boolean addItems(List<Item> items) {
final boolean result = mItemList.addAll(items); final boolean result = mItemList.addAll(items);
populate(); populate();
return result; return result;
} }
public void removeAllItems() { public void removeAllItems() {
removeAllItems(true); removeAllItems(true);
} }
public void removeAllItems(boolean withPopulate) { public void removeAllItems(boolean withPopulate) {
mItemList.clear(); mItemList.clear();
if (withPopulate) { if (withPopulate) {
populate(); populate();
} }
} }
public boolean removeItem(Item item) { public boolean removeItem(Item item) {
final boolean result = mItemList.remove(item); final boolean result = mItemList.remove(item);
populate(); populate();
return result; return result;
} }
public Item removeItem(int position) { public Item removeItem(int position) {
final Item result = mItemList.remove(position); final Item result = mItemList.remove(position);
populate(); populate();
return result; return result;
} }
/** /**
* Each of these methods performs a item sensitive check. If the item is * Each of these methods performs a item sensitive check. If the item is
* located its corresponding method is called. The result of the call is * located its corresponding method is called. The result of the call is
* returned. Helper methods are provided so that child classes may more * returned. Helper methods are provided so that child classes may more
* easily override behavior without resorting to overriding the * easily override behavior without resorting to overriding the
* ItemGestureListener methods. * ItemGestureListener methods.
*/ */
// @Override // @Override
// public boolean onTap(MotionEvent event, MapPosition pos) { // public boolean onTap(MotionEvent event, MapPosition pos) {
// return activateSelectedItems(event, mActiveItemSingleTap); // return activateSelectedItems(event, mActiveItemSingleTap);
// } // }
protected boolean onSingleTapUpHelper(int index, Item item) { protected boolean onSingleTapUpHelper(int index, Item item) {
return mOnItemGestureListener.onItemSingleTapUp(index, item); return mOnItemGestureListener.onItemSingleTapUp(index, item);
} }
private final ActiveItem mActiveItemSingleTap = new ActiveItem() { private final ActiveItem mActiveItemSingleTap = new ActiveItem() {
@Override @Override
public boolean run(int index) { public boolean run(int index) {
final ItemizedLayer<Item> that = ItemizedLayer.this; final ItemizedLayer<Item> that = ItemizedLayer.this;
if (mOnItemGestureListener == null) { if (mOnItemGestureListener == null) {
return false; return false;
} }
return onSingleTapUpHelper(index, that.mItemList.get(index)); return onSingleTapUpHelper(index, that.mItemList.get(index));
} }
}; };
protected boolean onLongPressHelper(int index, Item item) { protected boolean onLongPressHelper(int index, Item item) {
return this.mOnItemGestureListener.onItemLongPress(index, item); return this.mOnItemGestureListener.onItemLongPress(index, item);
} }
private final ActiveItem mActiveItemLongPress = new ActiveItem() { private final ActiveItem mActiveItemLongPress = new ActiveItem() {
@Override @Override
public boolean run(final int index) { public boolean run(final int index) {
final ItemizedLayer<Item> that = ItemizedLayer.this; final ItemizedLayer<Item> that = ItemizedLayer.this;
if (that.mOnItemGestureListener == null) { if (that.mOnItemGestureListener == null) {
return false; return false;
} }
return onLongPressHelper(index, that.mItemList.get(index)); return onLongPressHelper(index, that.mItemList.get(index));
} }
}; };
/** /**
* When a content sensitive action is performed the content item needs to be * When a content sensitive action is performed the content item needs to be
* identified. This method does that and then performs the assigned task on * identified. This method does that and then performs the assigned task on
* that item. * that item.
* *
* @return true if event is handled false otherwise * @return true if event is handled false otherwise
*/ */
protected boolean activateSelectedItems(MotionEvent event, ActiveItem task) { protected boolean activateSelectedItems(MotionEvent event, ActiveItem task) {
int size = mItemList.size(); int size = mItemList.size();
if (size == 0) if (size == 0)
return false; return false;
int eventX = (int) event.getX() - mMap.getWidth() / 2; int eventX = (int) event.getX() - mMap.getWidth() / 2;
int eventY = (int) event.getY() - mMap.getHeight() / 2; int eventY = (int) event.getY() - mMap.getHeight() / 2;
Viewport mapPosition = mMap.viewport(); Viewport mapPosition = mMap.viewport();
Box box = mapPosition.getBBox(null, 128); Box box = mapPosition.getBBox(null, 128);
box.map2mercator(); box.map2mercator();
box.scale(1E6); box.scale(1E6);
int nearest = -1; int nearest = -1;
int inside = -1; int inside = -1;
double insideY = -Double.MAX_VALUE; double insideY = -Double.MAX_VALUE;
/* squared dist: 50*50 pixel ~ 2mm on 400dpi */ /* squared dist: 50*50 pixel ~ 2mm on 400dpi */
double dist = 2500; double dist = 2500;
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
Item item = mItemList.get(i); Item item = mItemList.get(i);
if (!box.contains(item.getPoint().longitudeE6, if (!box.contains(item.getPoint().longitudeE6,
item.getPoint().latitudeE6)) item.getPoint().latitudeE6))
continue; continue;
mapPosition.toScreenPoint(item.getPoint(), mTmpPoint); mapPosition.toScreenPoint(item.getPoint(), mTmpPoint);
float dx = (float) (mTmpPoint.x - eventX); float dx = (float) (mTmpPoint.x - eventX);
float dy = (float) (mTmpPoint.y - eventY); float dy = (float) (mTmpPoint.y - eventY);
MarkerSymbol it = item.getMarker(); MarkerSymbol it = item.getMarker();
if (it == null) if (it == null)
it = mMarkerRenderer.mDefaultMarker; it = mMarkerRenderer.mDefaultMarker;
if (it.isInside(dx, dy)) { if (it.isInside(dx, dy)) {
if (mTmpPoint.y > insideY) { if (mTmpPoint.y > insideY) {
insideY = mTmpPoint.y; insideY = mTmpPoint.y;
inside = i; inside = i;
} }
} }
if (inside >= 0) if (inside >= 0)
continue; continue;
double d = dx * dx + dy * dy; double d = dx * dx + dy * dy;
if (d > dist) if (d > dist)
continue; continue;
dist = d; dist = d;
nearest = i; nearest = i;
} }
if (inside >= 0) if (inside >= 0)
nearest = inside; nearest = inside;
if (nearest >= 0 && task.run(nearest)) { if (nearest >= 0 && task.run(nearest)) {
mMarkerRenderer.update(); mMarkerRenderer.update();
mMap.render(); mMap.render();
return true; return true;
} }
return false; return false;
} }
/** /**
* When the item is touched one of these methods may be invoked depending on * When the item is touched one of these methods may be invoked depending on
* the type of touch. Each of them returns true if the event was completely * the type of touch. Each of them returns true if the event was completely
* handled. * handled.
*/ */
public static interface OnItemGestureListener<T> { public static interface OnItemGestureListener<T> {
public boolean onItemSingleTapUp(int index, T item); public boolean onItemSingleTapUp(int index, T item);
public boolean onItemLongPress(int index, T item); public boolean onItemLongPress(int index, T item);
} }
public static interface ActiveItem { public static interface ActiveItem {
public boolean run(int aIndex); public boolean run(int aIndex);
} }
@Override @Override
public boolean onGesture(Gesture g, MotionEvent e) { public boolean onGesture(Gesture g, MotionEvent e) {
if (g instanceof Gesture.Tap) if (g instanceof Gesture.Tap)
return activateSelectedItems(e, mActiveItemSingleTap); return activateSelectedItems(e, mActiveItemSingleTap);
if (g instanceof Gesture.LongPress) if (g instanceof Gesture.LongPress)
return activateSelectedItems(e, mActiveItemLongPress); return activateSelectedItems(e, mActiveItemLongPress);
return false; return false;
} }
public Item getByUid(Object uid) { public Item getByUid(Object uid) {
for (Item it : mItemList) for (Item it : mItemList)
if (it.getUid() == uid) if (it.getUid() == uid)
return it; return it;
return null; return null;
} }
} }

View File

@@ -1,94 +1,94 @@
/* /*
* Copyright 2012 osmdroid authors: * Copyright 2012 osmdroid authors:
* Copyright 2012 Nicolas Gramlich * Copyright 2012 Nicolas Gramlich
* Copyright 2012 Theodore Hong * Copyright 2012 Theodore Hong
* Copyright 2012 Fred Eisele * Copyright 2012 Fred Eisele
* *
* Copyright 2014 Hannes Janetzek * Copyright 2014 Hannes Janetzek
* *
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
* *
* This program is free software: you can redistribute it and/or modify it under the * This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software * terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version. * Foundation, either version 3 of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT ANY * This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License along with * You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>. * this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.oscim.layers.marker; package org.oscim.layers.marker;
import org.oscim.core.GeoPoint; import org.oscim.core.GeoPoint;
/** /**
* Immutable class describing a GeoPoint with a Title and a Description. * Immutable class describing a GeoPoint with a Title and a Description.
*/ */
public class MarkerItem { public class MarkerItem {
public static final int ITEM_STATE_FOCUSED_MASK = 4; public static final int ITEM_STATE_FOCUSED_MASK = 4;
public static final int ITEM_STATE_PRESSED_MASK = 1; public static final int ITEM_STATE_PRESSED_MASK = 1;
public static final int ITEM_STATE_SELECTED_MASK = 2; public static final int ITEM_STATE_SELECTED_MASK = 2;
/** /**
* Indicates a hotspot for an area. This is where the origin (0,0) of a * Indicates a hotspot for an area. This is where the origin (0,0) of a
* point will be located relative to the area. In otherwords this acts as an * point will be located relative to the area. In otherwords this acts as an
* offset. NONE indicates that no adjustment should be made. * offset. NONE indicates that no adjustment should be made.
*/ */
public enum HotspotPlace { public enum HotspotPlace {
NONE, CENTER, BOTTOM_CENTER, NONE, CENTER, BOTTOM_CENTER,
TOP_CENTER, RIGHT_CENTER, LEFT_CENTER, TOP_CENTER, RIGHT_CENTER, LEFT_CENTER,
UPPER_RIGHT_CORNER, LOWER_RIGHT_CORNER, UPPER_RIGHT_CORNER, LOWER_RIGHT_CORNER,
UPPER_LEFT_CORNER, LOWER_LEFT_CORNER UPPER_LEFT_CORNER, LOWER_LEFT_CORNER
} }
public final Object uid; public final Object uid;
public final String title; public final String title;
public final String description; public final String description;
public final GeoPoint geoPoint; public final GeoPoint geoPoint;
protected MarkerSymbol mMarker; protected MarkerSymbol mMarker;
/** /**
* @param title * @param title
* this should be <b>singleLine</b> (no <code>'\n'</code> ) * this should be <b>singleLine</b> (no <code>'\n'</code> )
* @param description * @param description
* a <b>multiLine</b> description ( <code>'\n'</code> possible) * a <b>multiLine</b> description ( <code>'\n'</code> possible)
*/ */
public MarkerItem(String title, String description, GeoPoint geoPoint) { public MarkerItem(String title, String description, GeoPoint geoPoint) {
this(null, title, description, geoPoint); this(null, title, description, geoPoint);
} }
public MarkerItem(Object uid, String title, String description, GeoPoint geoPoint) { public MarkerItem(Object uid, String title, String description, GeoPoint geoPoint) {
this.title = title; this.title = title;
this.description = description; this.description = description;
this.geoPoint = geoPoint; this.geoPoint = geoPoint;
this.uid = uid; this.uid = uid;
} }
public Object getUid() { public Object getUid() {
return uid; return uid;
} }
public String getTitle() { public String getTitle() {
return title; return title;
} }
public String getSnippet() { public String getSnippet() {
return description; return description;
} }
public GeoPoint getPoint() { public GeoPoint getPoint() {
return geoPoint; return geoPoint;
} }
public MarkerSymbol getMarker() { public MarkerSymbol getMarker() {
return mMarker; return mMarker;
} }
public void setMarker(MarkerSymbol marker) { public void setMarker(MarkerSymbol marker) {
mMarker = marker; mMarker = marker;
} }
} }

View File

@@ -1,115 +1,115 @@
/* /*
* Copyright 2012 osmdroid authors: * Copyright 2012 osmdroid authors:
* Copyright 2012 Nicolas Gramlich * Copyright 2012 Nicolas Gramlich
* Copyright 2012 Theodore Hong * Copyright 2012 Theodore Hong
* Copyright 2012 Fred Eisele * Copyright 2012 Fred Eisele
* *
* Copyright 2013 Hannes Janetzek * Copyright 2013 Hannes Janetzek
* *
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
* *
* This program is free software: you can redistribute it and/or modify it under the * This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software * terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version. * Foundation, either version 3 of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT ANY * This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License along with * You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>. * this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.oscim.layers.marker; package org.oscim.layers.marker;
import org.oscim.core.Point; import org.oscim.core.Point;
import org.oscim.layers.Layer; import org.oscim.layers.Layer;
import org.oscim.map.Map; import org.oscim.map.Map;
/** /**
* Draws a list of {@link MarkerItem} as markers to a map. The item with the * Draws a list of {@link MarkerItem} as markers to a map. The item with the
* lowest index is drawn as last and therefore the 'topmost' marker. It also * lowest index is drawn as last and therefore the 'topmost' marker. It also
* gets checked for onTap first. This class is generic, because you then you get * gets checked for onTap first. This class is generic, because you then you get
* your custom item-class passed back in onTap(). << TODO * your custom item-class passed back in onTap(). << TODO
*/ */
public abstract class MarkerLayer<Item extends MarkerItem> extends Layer { public abstract class MarkerLayer<Item extends MarkerItem> extends Layer {
protected final MarkerRenderer mMarkerRenderer; protected final MarkerRenderer mMarkerRenderer;
protected Item mFocusedItem; protected Item mFocusedItem;
/** /**
* Method by which subclasses create the actual Items. This will only be * Method by which subclasses create the actual Items. This will only be
* called from populate() we'll cache them for later use. * called from populate() we'll cache them for later use.
*/ */
protected abstract Item createItem(int i); protected abstract Item createItem(int i);
/** /**
* The number of items in this overlay. * The number of items in this overlay.
*/ */
public abstract int size(); public abstract int size();
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public MarkerLayer(Map map, MarkerSymbol defaultSymbol) { public MarkerLayer(Map map, MarkerSymbol defaultSymbol) {
super(map); super(map);
mMarkerRenderer = new MarkerRenderer((MarkerLayer<MarkerItem>) this, defaultSymbol); mMarkerRenderer = new MarkerRenderer((MarkerLayer<MarkerItem>) this, defaultSymbol);
mRenderer = mMarkerRenderer; mRenderer = mMarkerRenderer;
} }
/** /**
* Utility method to perform all processing on a new ItemizedOverlay. * Utility method to perform all processing on a new ItemizedOverlay.
* Subclasses provide Items through the createItem(int) method. The subclass * Subclasses provide Items through the createItem(int) method. The subclass
* should call this as soon as it has data, before anything else gets * should call this as soon as it has data, before anything else gets
* called. * called.
*/ */
protected final void populate() { protected final void populate() {
mMarkerRenderer.populate(size()); mMarkerRenderer.populate(size());
} }
/** /**
* TODO * TODO
* If the given Item is found in the overlay, force it to be the current * If the given Item is found in the overlay, force it to be the current
* focus-bearer. Any registered {link ItemizedLayer#OnFocusChangeListener} * focus-bearer. Any registered {link ItemizedLayer#OnFocusChangeListener}
* will be notified. This does not move the map, so if the Item isn't * will be notified. This does not move the map, so if the Item isn't
* already centered, the user may get confused. If the Item is not found, * already centered, the user may get confused. If the Item is not found,
* this is a no-op. You can also pass null to remove focus. * this is a no-op. You can also pass null to remove focus.
* *
* @param item * @param item
*/ */
public void setFocus(Item item) { public void setFocus(Item item) {
mFocusedItem = item; mFocusedItem = item;
} }
/** /**
* @return the currently-focused item, or null if no item is currently * @return the currently-focused item, or null if no item is currently
* focused. * focused.
*/ */
public Item getFocus() { public Item getFocus() {
return mFocusedItem; return mFocusedItem;
} }
/** /**
* TODO * TODO
* Interface definition for overlays that contain items that can be snapped * Interface definition for overlays that contain items that can be snapped
* to (for example, when the user invokes a zoom, this could be called * to (for example, when the user invokes a zoom, this could be called
* allowing the user to snap the zoom to an interesting point.) * allowing the user to snap the zoom to an interesting point.)
*/ */
public interface Snappable { public interface Snappable {
/** /**
* Checks to see if the given x and y are close enough to an item * Checks to see if the given x and y are close enough to an item
* resulting in snapping the current action (e.g. zoom) to the item. * resulting in snapping the current action (e.g. zoom) to the item.
* *
* @param x * @param x
* The x in screen coordinates. * The x in screen coordinates.
* @param y * @param y
* The y in screen coordinates. * The y in screen coordinates.
* @param snapPoint * @param snapPoint
* To be filled with the the interesting point (in screen * To be filled with the the interesting point (in screen
* coordinates) that is closest to the given x and y. Can be * coordinates) that is closest to the given x and y. Can be
* untouched if not snapping. * untouched if not snapping.
* @return Whether or not to snap to the interesting point. * @return Whether or not to snap to the interesting point.
*/ */
boolean onSnapToItem(int x, int y, Point snapPoint); boolean onSnapToItem(int x, int y, Point snapPoint);
} }
} }

File diff suppressed because it is too large Load Diff

View File

@@ -1,420 +1,420 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2011 Mario Zechner <badlogicgames@gmail.com> * Copyright 2011 Mario Zechner <badlogicgames@gmail.com>
* Copyright 2011 Nathan Sweet <nathan.sweet@gmail.com> * Copyright 2011 Nathan Sweet <nathan.sweet@gmail.com>
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
******************************************************************************/ ******************************************************************************/
package org.oscim.utils.math; package org.oscim.utils.math;
/** /**
* Takes a linear value in the range of 0-1 and outputs a (usually) non-linear, * Takes a linear value in the range of 0-1 and outputs a (usually) non-linear,
* interpolated value. * interpolated value.
*/ */
public abstract class Interpolation { public abstract class Interpolation {
/** @param a Alpha value between 0 and 1. */ /** @param a Alpha value between 0 and 1. */
abstract public float apply(float a); abstract public float apply(float a);
/** @param a Alpha value between 0 and 1. */ /** @param a Alpha value between 0 and 1. */
public float apply(float start, float end, float a) { public float apply(float start, float end, float a) {
return start + (end - start) * apply(a); return start + (end - start) * apply(a);
} }
static public final Interpolation linear = new Interpolation() { static public final Interpolation linear = new Interpolation() {
@Override @Override
public float apply(float a) { public float apply(float a) {
return a; return a;
} }
}; };
static public final Interpolation fade = new Interpolation() { static public final Interpolation fade = new Interpolation() {
@Override @Override
public float apply(float a) { public float apply(float a) {
return MathUtils.clamp(a * a * a * (a * (a * 6 - 15) + 10), 0, 1); return MathUtils.clamp(a * a * a * (a * (a * 6 - 15) + 10), 0, 1);
} }
}; };
static public final Pow pow2 = new Pow(2); static public final Pow pow2 = new Pow(2);
static public final PowIn pow2In = new PowIn(2); static public final PowIn pow2In = new PowIn(2);
static public final PowOut pow2Out = new PowOut(2); static public final PowOut pow2Out = new PowOut(2);
static public final Pow pow3 = new Pow(3); static public final Pow pow3 = new Pow(3);
static public final PowIn pow3In = new PowIn(3); static public final PowIn pow3In = new PowIn(3);
static public final PowOut pow3Out = new PowOut(3); static public final PowOut pow3Out = new PowOut(3);
static public final Pow pow4 = new Pow(4); static public final Pow pow4 = new Pow(4);
static public final PowIn pow4In = new PowIn(4); static public final PowIn pow4In = new PowIn(4);
static public final PowOut pow4Out = new PowOut(4); static public final PowOut pow4Out = new PowOut(4);
static public final Pow pow5 = new Pow(5); static public final Pow pow5 = new Pow(5);
static public final PowIn pow5In = new PowIn(5); static public final PowIn pow5In = new PowIn(5);
static public final PowOut pow5Out = new PowOut(5); static public final PowOut pow5Out = new PowOut(5);
static public final Interpolation sine = new Interpolation() { static public final Interpolation sine = new Interpolation() {
@Override @Override
public float apply(float a) { public float apply(float a) {
return (1 - MathUtils.cos(a * MathUtils.PI)) / 2; return (1 - MathUtils.cos(a * MathUtils.PI)) / 2;
} }
}; };
static public final Interpolation sineIn = new Interpolation() { static public final Interpolation sineIn = new Interpolation() {
@Override @Override
public float apply(float a) { public float apply(float a) {
return 1 - MathUtils.cos(a * MathUtils.PI / 2); return 1 - MathUtils.cos(a * MathUtils.PI / 2);
} }
}; };
static public final Interpolation sineOut = new Interpolation() { static public final Interpolation sineOut = new Interpolation() {
@Override @Override
public float apply(float a) { public float apply(float a) {
return MathUtils.sin(a * MathUtils.PI / 2); return MathUtils.sin(a * MathUtils.PI / 2);
} }
}; };
static public final Interpolation exp10 = new Exp(2, 10); static public final Interpolation exp10 = new Exp(2, 10);
static public final Interpolation exp10In = new ExpIn(2, 10); static public final Interpolation exp10In = new ExpIn(2, 10);
static public final Interpolation exp10Out = new ExpOut(2, 10); static public final Interpolation exp10Out = new ExpOut(2, 10);
static public final Interpolation exp5 = new Exp(2, 5); static public final Interpolation exp5 = new Exp(2, 5);
static public final Interpolation exp5In = new ExpIn(2, 5); static public final Interpolation exp5In = new ExpIn(2, 5);
static public final Interpolation exp5Out = new ExpOut(2, 5); static public final Interpolation exp5Out = new ExpOut(2, 5);
static public final Interpolation circle = new Interpolation() { static public final Interpolation circle = new Interpolation() {
@Override @Override
public float apply(float a) { public float apply(float a) {
if (a <= 0.5f) { if (a <= 0.5f) {
a *= 2; a *= 2;
return (1 - (float) Math.sqrt(1 - a * a)) / 2; return (1 - (float) Math.sqrt(1 - a * a)) / 2;
} }
a--; a--;
a *= 2; a *= 2;
return ((float) Math.sqrt(1 - a * a) + 1) / 2; return ((float) Math.sqrt(1 - a * a) + 1) / 2;
} }
}; };
static public final Interpolation circleIn = new Interpolation() { static public final Interpolation circleIn = new Interpolation() {
@Override @Override
public float apply(float a) { public float apply(float a) {
return 1 - (float) Math.sqrt(1 - a * a); return 1 - (float) Math.sqrt(1 - a * a);
} }
}; };
static public final Interpolation circleOut = new Interpolation() { static public final Interpolation circleOut = new Interpolation() {
@Override @Override
public float apply(float a) { public float apply(float a) {
a--; a--;
return (float) Math.sqrt(1 - a * a); return (float) Math.sqrt(1 - a * a);
} }
}; };
static public final Elastic elastic = new Elastic(2, 10); static public final Elastic elastic = new Elastic(2, 10);
static public final Elastic elasticIn = new ElasticIn(2, 10); static public final Elastic elasticIn = new ElasticIn(2, 10);
static public final Elastic elasticOut = new ElasticOut(2, 10); static public final Elastic elasticOut = new ElasticOut(2, 10);
static public final Interpolation swing = new Swing(1.5f); static public final Interpolation swing = new Swing(1.5f);
static public final Interpolation swingIn = new SwingIn(2f); static public final Interpolation swingIn = new SwingIn(2f);
static public final Interpolation swingOut = new SwingOut(2f); static public final Interpolation swingOut = new SwingOut(2f);
static public final Interpolation bounce = new Bounce(4); static public final Interpolation bounce = new Bounce(4);
static public final Interpolation bounceIn = new BounceIn(4); static public final Interpolation bounceIn = new BounceIn(4);
static public final Interpolation bounceOut = new BounceOut(4); static public final Interpolation bounceOut = new BounceOut(4);
// //
static public class Pow extends Interpolation { static public class Pow extends Interpolation {
final int power; final int power;
public Pow(int power) { public Pow(int power) {
this.power = power; this.power = power;
} }
@Override @Override
public float apply(float a) { public float apply(float a) {
if (a <= 0.5f) if (a <= 0.5f)
return (float) Math.pow(a * 2, power) / 2; return (float) Math.pow(a * 2, power) / 2;
return (float) Math.pow((a - 1) * 2, power) / (power % 2 == 0 ? -2 : 2) + 1; return (float) Math.pow((a - 1) * 2, power) / (power % 2 == 0 ? -2 : 2) + 1;
} }
} }
static public class PowIn extends Pow { static public class PowIn extends Pow {
public PowIn(int power) { public PowIn(int power) {
super(power); super(power);
} }
@Override @Override
public float apply(float a) { public float apply(float a) {
return (float) Math.pow(a, power); return (float) Math.pow(a, power);
} }
} }
static public class PowOut extends Pow { static public class PowOut extends Pow {
public PowOut(int power) { public PowOut(int power) {
super(power); super(power);
} }
@Override @Override
public float apply(float a) { public float apply(float a) {
return (float) Math.pow(a - 1, power) * (power % 2 == 0 ? -1 : 1) + 1; return (float) Math.pow(a - 1, power) * (power % 2 == 0 ? -1 : 1) + 1;
} }
} }
// //
static public class Exp extends Interpolation { static public class Exp extends Interpolation {
final float value, power, min, scale; final float value, power, min, scale;
public Exp(float value, float power) { public Exp(float value, float power) {
this.value = value; this.value = value;
this.power = power; this.power = power;
min = (float) Math.pow(value, -power); min = (float) Math.pow(value, -power);
scale = 1 / (1 - min); scale = 1 / (1 - min);
} }
@Override @Override
public float apply(float a) { public float apply(float a) {
if (a <= 0.5f) if (a <= 0.5f)
return ((float) Math.pow(value, power * (a * 2 - 1)) - min) * scale / 2; return ((float) Math.pow(value, power * (a * 2 - 1)) - min) * scale / 2;
return (2 - ((float) Math.pow(value, -power * (a * 2 - 1)) - min) * scale) / 2; return (2 - ((float) Math.pow(value, -power * (a * 2 - 1)) - min) * scale) / 2;
} }
} }
static public class ExpIn extends Exp { static public class ExpIn extends Exp {
public ExpIn(float value, float power) { public ExpIn(float value, float power) {
super(value, power); super(value, power);
} }
@Override @Override
public float apply(float a) { public float apply(float a) {
return ((float) Math.pow(value, power * (a - 1)) - min) * scale; return ((float) Math.pow(value, power * (a - 1)) - min) * scale;
} }
} }
static public class ExpOut extends Exp { static public class ExpOut extends Exp {
public ExpOut(float value, float power) { public ExpOut(float value, float power) {
super(value, power); super(value, power);
} }
@Override @Override
public float apply(float a) { public float apply(float a) {
return 1 - ((float) Math.pow(value, -power * a) - min) * scale; return 1 - ((float) Math.pow(value, -power * a) - min) * scale;
} }
} }
// //
static public class Elastic extends Interpolation { static public class Elastic extends Interpolation {
final float value, power; final float value, power;
public Elastic(float value, float power) { public Elastic(float value, float power) {
this.value = value; this.value = value;
this.power = power; this.power = power;
} }
@Override @Override
public float apply(float a) { public float apply(float a) {
if (a <= 0.5f) { if (a <= 0.5f) {
a *= 2; a *= 2;
return (float) Math.pow(value, power * (a - 1)) * MathUtils.sin(a * 20) * 1.0955f return (float) Math.pow(value, power * (a - 1)) * MathUtils.sin(a * 20) * 1.0955f
/ 2; / 2;
} }
a = 1 - a; a = 1 - a;
a *= 2; a *= 2;
return 1 - (float) Math.pow(value, power * (a - 1)) * MathUtils.sin((a) * 20) * 1.0955f return 1 - (float) Math.pow(value, power * (a - 1)) * MathUtils.sin((a) * 20) * 1.0955f
/ 2; / 2;
} }
} }
static public class ElasticIn extends Elastic { static public class ElasticIn extends Elastic {
public ElasticIn(float value, float power) { public ElasticIn(float value, float power) {
super(value, power); super(value, power);
} }
@Override @Override
public float apply(float a) { public float apply(float a) {
return (float) Math.pow(value, power * (a - 1)) * MathUtils.sin(a * 20) * 1.0955f; return (float) Math.pow(value, power * (a - 1)) * MathUtils.sin(a * 20) * 1.0955f;
} }
} }
static public class ElasticOut extends Elastic { static public class ElasticOut extends Elastic {
public ElasticOut(float value, float power) { public ElasticOut(float value, float power) {
super(value, power); super(value, power);
} }
@Override @Override
public float apply(float a) { public float apply(float a) {
a = 1 - a; a = 1 - a;
return (1 - (float) Math.pow(value, power * (a - 1)) * MathUtils.sin(a * 20) * 1.0955f); return (1 - (float) Math.pow(value, power * (a - 1)) * MathUtils.sin(a * 20) * 1.0955f);
} }
} }
// //
static public class Bounce extends BounceOut { static public class Bounce extends BounceOut {
public Bounce(float[] widths, float[] heights) { public Bounce(float[] widths, float[] heights) {
super(widths, heights); super(widths, heights);
} }
public Bounce(int bounces) { public Bounce(int bounces) {
super(bounces); super(bounces);
} }
private float out(float a) { private float out(float a) {
float test = a + widths[0] / 2; float test = a + widths[0] / 2;
if (test < widths[0]) if (test < widths[0])
return test / (widths[0] / 2) - 1; return test / (widths[0] / 2) - 1;
return super.apply(a); return super.apply(a);
} }
@Override @Override
public float apply(float a) { public float apply(float a) {
if (a <= 0.5f) if (a <= 0.5f)
return (1 - out(1 - a * 2)) / 2; return (1 - out(1 - a * 2)) / 2;
return out(a * 2 - 1) / 2 + 0.5f; return out(a * 2 - 1) / 2 + 0.5f;
} }
} }
static public class BounceOut extends Interpolation { static public class BounceOut extends Interpolation {
final float[] widths, heights; final float[] widths, heights;
public BounceOut(float[] widths, float[] heights) { public BounceOut(float[] widths, float[] heights) {
if (widths.length != heights.length) if (widths.length != heights.length)
throw new IllegalArgumentException("Must be the same number of widths and heights."); throw new IllegalArgumentException("Must be the same number of widths and heights.");
this.widths = widths; this.widths = widths;
this.heights = heights; this.heights = heights;
} }
public BounceOut(int bounces) { public BounceOut(int bounces) {
if (bounces < 2 || bounces > 5) if (bounces < 2 || bounces > 5)
throw new IllegalArgumentException("bounces cannot be < 2 or > 5: " + bounces); throw new IllegalArgumentException("bounces cannot be < 2 or > 5: " + bounces);
widths = new float[bounces]; widths = new float[bounces];
heights = new float[bounces]; heights = new float[bounces];
heights[0] = 1; heights[0] = 1;
switch (bounces) { switch (bounces) {
case 2: case 2:
widths[0] = 0.6f; widths[0] = 0.6f;
widths[1] = 0.4f; widths[1] = 0.4f;
heights[1] = 0.33f; heights[1] = 0.33f;
break; break;
case 3: case 3:
widths[0] = 0.4f; widths[0] = 0.4f;
widths[1] = 0.4f; widths[1] = 0.4f;
widths[2] = 0.2f; widths[2] = 0.2f;
heights[1] = 0.33f; heights[1] = 0.33f;
heights[2] = 0.1f; heights[2] = 0.1f;
break; break;
case 4: case 4:
widths[0] = 0.34f; widths[0] = 0.34f;
widths[1] = 0.34f; widths[1] = 0.34f;
widths[2] = 0.2f; widths[2] = 0.2f;
widths[3] = 0.15f; widths[3] = 0.15f;
heights[1] = 0.26f; heights[1] = 0.26f;
heights[2] = 0.11f; heights[2] = 0.11f;
heights[3] = 0.03f; heights[3] = 0.03f;
break; break;
case 5: case 5:
widths[0] = 0.3f; widths[0] = 0.3f;
widths[1] = 0.3f; widths[1] = 0.3f;
widths[2] = 0.2f; widths[2] = 0.2f;
widths[3] = 0.1f; widths[3] = 0.1f;
widths[4] = 0.1f; widths[4] = 0.1f;
heights[1] = 0.45f; heights[1] = 0.45f;
heights[2] = 0.3f; heights[2] = 0.3f;
heights[3] = 0.15f; heights[3] = 0.15f;
heights[4] = 0.06f; heights[4] = 0.06f;
break; break;
} }
widths[0] *= 2; widths[0] *= 2;
} }
@Override @Override
public float apply(float a) { public float apply(float a) {
a += widths[0] / 2; a += widths[0] / 2;
float width = 0, height = 0; float width = 0, height = 0;
for (int i = 0, n = widths.length; i < n; i++) { for (int i = 0, n = widths.length; i < n; i++) {
width = widths[i]; width = widths[i];
if (a <= width) { if (a <= width) {
height = heights[i]; height = heights[i];
break; break;
} }
a -= width; a -= width;
} }
a /= width; a /= width;
float z = 4 / width * height * a; float z = 4 / width * height * a;
return 1 - (z - z * a) * width; return 1 - (z - z * a) * width;
} }
} }
static public class BounceIn extends BounceOut { static public class BounceIn extends BounceOut {
public BounceIn(float[] widths, float[] heights) { public BounceIn(float[] widths, float[] heights) {
super(widths, heights); super(widths, heights);
} }
public BounceIn(int bounces) { public BounceIn(int bounces) {
super(bounces); super(bounces);
} }
@Override @Override
public float apply(float a) { public float apply(float a) {
return 1 - super.apply(1 - a); return 1 - super.apply(1 - a);
} }
} }
// //
static public class Swing extends Interpolation { static public class Swing extends Interpolation {
private final float scale; private final float scale;
public Swing(float scale) { public Swing(float scale) {
this.scale = scale * 2; this.scale = scale * 2;
} }
@Override @Override
public float apply(float a) { public float apply(float a) {
if (a <= 0.5f) { if (a <= 0.5f) {
a *= 2; a *= 2;
return a * a * ((scale + 1) * a - scale) / 2; return a * a * ((scale + 1) * a - scale) / 2;
} }
a--; a--;
a *= 2; a *= 2;
return a * a * ((scale + 1) * a + scale) / 2 + 1; return a * a * ((scale + 1) * a + scale) / 2 + 1;
} }
} }
static public class SwingOut extends Interpolation { static public class SwingOut extends Interpolation {
private final float scale; private final float scale;
public SwingOut(float scale) { public SwingOut(float scale) {
this.scale = scale; this.scale = scale;
} }
@Override @Override
public float apply(float a) { public float apply(float a) {
a--; a--;
return a * a * ((scale + 1) * a + scale) + 1; return a * a * ((scale + 1) * a + scale) + 1;
} }
} }
static public class SwingIn extends Interpolation { static public class SwingIn extends Interpolation {
private final float scale; private final float scale;
public SwingIn(float scale) { public SwingIn(float scale) {
this.scale = scale; this.scale = scale;
} }
@Override @Override
public float apply(float a) { public float apply(float a) {
return a * a * ((scale + 1) * a - scale); return a * a * ((scale + 1) * a - scale);
} }
} }
} }

View File

@@ -1,284 +1,284 @@
/******************************************************************************* /*******************************************************************************
* Copyright 2011 Mario Zechner <badlogicgames@gmail.com> * Copyright 2011 Mario Zechner <badlogicgames@gmail.com>
* Copyright 2011 Nathan Sweet <nathan.sweet@gmail.com> * Copyright 2011 Nathan Sweet <nathan.sweet@gmail.com>
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
******************************************************************************/ ******************************************************************************/
package org.oscim.utils.math; package org.oscim.utils.math;
import java.util.Random; import java.util.Random;
/** /**
* Utility and fast math functions. * Utility and fast math functions.
* <p> * <p>
* Thanks to Riven on JavaGaming.org for the basis of sin/cos/atan2/floor/ceil. * Thanks to Riven on JavaGaming.org for the basis of sin/cos/atan2/floor/ceil.
* *
* @author Nathan Sweet * @author Nathan Sweet
*/ */
public class MathUtils { public class MathUtils {
static public final float nanoToSec = 1 / 1000000000f; static public final float nanoToSec = 1 / 1000000000f;
static public final float PI = 3.1415927f; static public final float PI = 3.1415927f;
public static final float PI2 = PI * 2; public static final float PI2 = PI * 2;
static private final int SIN_BITS = 13; // Adjust for accuracy. static private final int SIN_BITS = 13; // Adjust for accuracy.
static private final int SIN_MASK = ~(-1 << SIN_BITS); static private final int SIN_MASK = ~(-1 << SIN_BITS);
static private final int SIN_COUNT = SIN_MASK + 1; static private final int SIN_COUNT = SIN_MASK + 1;
static private final float radFull = PI * 2; static private final float radFull = PI * 2;
static private final float degFull = 360; static private final float degFull = 360;
static private final float radToIndex = SIN_COUNT / radFull; static private final float radToIndex = SIN_COUNT / radFull;
static private final float degToIndex = SIN_COUNT / degFull; static private final float degToIndex = SIN_COUNT / degFull;
static public final float radiansToDegrees = 180f / PI; static public final float radiansToDegrees = 180f / PI;
static public final float radDeg = radiansToDegrees; static public final float radDeg = radiansToDegrees;
static public final float degreesToRadians = PI / 180; static public final float degreesToRadians = PI / 180;
static public final float degRad = degreesToRadians; static public final float degRad = degreesToRadians;
static private class Sin { static private class Sin {
static final float[] table = new float[SIN_COUNT]; static final float[] table = new float[SIN_COUNT];
static { static {
for (int i = 0; i < SIN_COUNT; i++) for (int i = 0; i < SIN_COUNT; i++)
table[i] = (float) Math.sin((i + 0.5f) / SIN_COUNT * radFull); table[i] = (float) Math.sin((i + 0.5f) / SIN_COUNT * radFull);
for (int i = 0; i < 360; i += 90) for (int i = 0; i < 360; i += 90)
table[(int) (i * degToIndex) & SIN_MASK] = (float) Math.sin(i * degreesToRadians); table[(int) (i * degToIndex) & SIN_MASK] = (float) Math.sin(i * degreesToRadians);
} }
} }
static private class Cos { static private class Cos {
static final float[] table = new float[SIN_COUNT]; static final float[] table = new float[SIN_COUNT];
static { static {
for (int i = 0; i < SIN_COUNT; i++) for (int i = 0; i < SIN_COUNT; i++)
table[i] = (float) Math.cos((i + 0.5f) / SIN_COUNT * radFull); table[i] = (float) Math.cos((i + 0.5f) / SIN_COUNT * radFull);
for (int i = 0; i < 360; i += 90) for (int i = 0; i < 360; i += 90)
table[(int) (i * degToIndex) & SIN_MASK] = (float) Math.cos(i * degreesToRadians); table[(int) (i * degToIndex) & SIN_MASK] = (float) Math.cos(i * degreesToRadians);
} }
} }
/** Returns the sine in radians. */ /** Returns the sine in radians. */
static public final float sin(float radians) { static public final float sin(float radians) {
return Sin.table[(int) (radians * radToIndex) & SIN_MASK]; return Sin.table[(int) (radians * radToIndex) & SIN_MASK];
} }
/** Returns the cosine in radians. */ /** Returns the cosine in radians. */
static public final float cos(float radians) { static public final float cos(float radians) {
return Cos.table[(int) (radians * radToIndex) & SIN_MASK]; return Cos.table[(int) (radians * radToIndex) & SIN_MASK];
} }
/** Returns the sine in radians. */ /** Returns the sine in radians. */
static public final float sinDeg(float degrees) { static public final float sinDeg(float degrees) {
return Sin.table[(int) (degrees * degToIndex) & SIN_MASK]; return Sin.table[(int) (degrees * degToIndex) & SIN_MASK];
} }
/** Returns the cosine in radians. */ /** Returns the cosine in radians. */
static public final float cosDeg(float degrees) { static public final float cosDeg(float degrees) {
return Cos.table[(int) (degrees * degToIndex) & SIN_MASK]; return Cos.table[(int) (degrees * degToIndex) & SIN_MASK];
} }
// --- // ---
static private final int ATAN2_BITS = 7; // Adjust for accuracy. static private final int ATAN2_BITS = 7; // Adjust for accuracy.
static private final int ATAN2_BITS2 = ATAN2_BITS << 1; static private final int ATAN2_BITS2 = ATAN2_BITS << 1;
static private final int ATAN2_MASK = ~(-1 << ATAN2_BITS2); static private final int ATAN2_MASK = ~(-1 << ATAN2_BITS2);
static private final int ATAN2_COUNT = ATAN2_MASK + 1; static private final int ATAN2_COUNT = ATAN2_MASK + 1;
static final int ATAN2_DIM = (int) Math.sqrt(ATAN2_COUNT); static final int ATAN2_DIM = (int) Math.sqrt(ATAN2_COUNT);
static private final float INV_ATAN2_DIM_MINUS_1 = 1.0f / (ATAN2_DIM - 1); static private final float INV_ATAN2_DIM_MINUS_1 = 1.0f / (ATAN2_DIM - 1);
static private class Atan2 { static private class Atan2 {
static final float[] table = new float[ATAN2_COUNT]; static final float[] table = new float[ATAN2_COUNT];
static { static {
for (int i = 0; i < ATAN2_DIM; i++) { for (int i = 0; i < ATAN2_DIM; i++) {
for (int j = 0; j < ATAN2_DIM; j++) { for (int j = 0; j < ATAN2_DIM; j++) {
float x0 = (float) i / ATAN2_DIM; float x0 = (float) i / ATAN2_DIM;
float y0 = (float) j / ATAN2_DIM; float y0 = (float) j / ATAN2_DIM;
table[j * ATAN2_DIM + i] = (float) Math.atan2(y0, x0); table[j * ATAN2_DIM + i] = (float) Math.atan2(y0, x0);
} }
} }
} }
} }
/** Returns atan2 in radians from a lookup table. */ /** Returns atan2 in radians from a lookup table. */
static public final float atan2(float y, float x) { static public final float atan2(float y, float x) {
float add, mul; float add, mul;
if (x < 0) { if (x < 0) {
if (y < 0) { if (y < 0) {
y = -y; y = -y;
mul = 1; mul = 1;
} else } else
mul = -1; mul = -1;
x = -x; x = -x;
add = -PI; add = -PI;
} else { } else {
if (y < 0) { if (y < 0) {
y = -y; y = -y;
mul = -1; mul = -1;
} else } else
mul = 1; mul = 1;
add = 0; add = 0;
} }
float invDiv = 1 / ((x < y ? y : x) * INV_ATAN2_DIM_MINUS_1); float invDiv = 1 / ((x < y ? y : x) * INV_ATAN2_DIM_MINUS_1);
int xi = (int) (x * invDiv); int xi = (int) (x * invDiv);
int yi = (int) (y * invDiv); int yi = (int) (y * invDiv);
return (Atan2.table[yi * ATAN2_DIM + xi] + add) * mul; return (Atan2.table[yi * ATAN2_DIM + xi] + add) * mul;
} }
// --- // ---
static public Random random = new Random(); static public Random random = new Random();
/** /**
* Returns a random number between 0 (inclusive) and the specified value * Returns a random number between 0 (inclusive) and the specified value
* (inclusive). * (inclusive).
*/ */
static public final int random(int range) { static public final int random(int range) {
return random.nextInt(range + 1); return random.nextInt(range + 1);
} }
/** Returns a random number between start (inclusive) and end (inclusive). */ /** Returns a random number between start (inclusive) and end (inclusive). */
static public final int random(int start, int end) { static public final int random(int start, int end) {
return start + random.nextInt(end - start + 1); return start + random.nextInt(end - start + 1);
} }
/** Returns a random boolean value. */ /** Returns a random boolean value. */
static public final boolean randomBoolean() { static public final boolean randomBoolean() {
return random.nextBoolean(); return random.nextBoolean();
} }
/** Returns random number between 0.0 (inclusive) and 1.0 (exclusive). */ /** Returns random number between 0.0 (inclusive) and 1.0 (exclusive). */
static public final float random() { static public final float random() {
return random.nextFloat(); return random.nextFloat();
} }
/** /**
* Returns a random number between 0 (inclusive) and the specified value * Returns a random number between 0 (inclusive) and the specified value
* (exclusive). * (exclusive).
*/ */
static public final float random(float range) { static public final float random(float range) {
return random.nextFloat() * range; return random.nextFloat() * range;
} }
/** Returns a random number between start (inclusive) and end (exclusive). */ /** Returns a random number between start (inclusive) and end (exclusive). */
static public final float random(float start, float end) { static public final float random(float start, float end) {
return start + random.nextFloat() * (end - start); return start + random.nextFloat() * (end - start);
} }
// --- // ---
/** /**
* Returns the next power of two. Returns the specified value if the value * Returns the next power of two. Returns the specified value if the value
* is already a power of two. * is already a power of two.
*/ */
static public int nextPowerOfTwo(int value) { static public int nextPowerOfTwo(int value) {
if (value == 0) if (value == 0)
return 1; return 1;
value--; value--;
value |= value >> 1; value |= value >> 1;
value |= value >> 2; value |= value >> 2;
value |= value >> 4; value |= value >> 4;
value |= value >> 8; value |= value >> 8;
value |= value >> 16; value |= value >> 16;
return value + 1; return value + 1;
} }
static public boolean isPowerOfTwo(int value) { static public boolean isPowerOfTwo(int value) {
return value != 0 && (value & value - 1) == 0; return value != 0 && (value & value - 1) == 0;
} }
// --- // ---
static public int clamp(int value, int min, int max) { static public int clamp(int value, int min, int max) {
if (value < min) if (value < min)
return min; return min;
if (value > max) if (value > max)
return max; return max;
return value; return value;
} }
static public short clamp(short value, short min, short max) { static public short clamp(short value, short min, short max) {
if (value < min) if (value < min)
return min; return min;
if (value > max) if (value > max)
return max; return max;
return value; return value;
} }
static public float clamp(float value, float min, float max) { static public float clamp(float value, float min, float max) {
if (value < min) if (value < min)
return min; return min;
if (value > max) if (value > max)
return max; return max;
return value; return value;
} }
// --- // ---
static private final int BIG_ENOUGH_INT = 16 * 1024; static private final int BIG_ENOUGH_INT = 16 * 1024;
static private final double BIG_ENOUGH_FLOOR = BIG_ENOUGH_INT; static private final double BIG_ENOUGH_FLOOR = BIG_ENOUGH_INT;
static private final double CEIL = 0.9999999; static private final double CEIL = 0.9999999;
static private final double BIG_ENOUGH_CEIL = Double.longBitsToDouble(Double.doubleToLongBits(BIG_ENOUGH_INT + 1) - 1); static private final double BIG_ENOUGH_CEIL = Double.longBitsToDouble(Double.doubleToLongBits(BIG_ENOUGH_INT + 1) - 1);
static private final double BIG_ENOUGH_ROUND = BIG_ENOUGH_INT + 0.5f; static private final double BIG_ENOUGH_ROUND = BIG_ENOUGH_INT + 0.5f;
/** /**
* Returns the largest integer less than or equal to the specified float. * Returns the largest integer less than or equal to the specified float.
* This method will only properly floor floats from * This method will only properly floor floats from
* -(2^14) to (Float.MAX_VALUE - 2^14). * -(2^14) to (Float.MAX_VALUE - 2^14).
*/ */
static public int floor(float x) { static public int floor(float x) {
return (int) (x + BIG_ENOUGH_FLOOR) - BIG_ENOUGH_INT; return (int) (x + BIG_ENOUGH_FLOOR) - BIG_ENOUGH_INT;
} }
/** /**
* Returns the largest integer less than or equal to the specified float. * Returns the largest integer less than or equal to the specified float.
* This method will only properly floor floats that are * This method will only properly floor floats that are
* positive. Note this method simply casts the float to int. * positive. Note this method simply casts the float to int.
*/ */
static public int floorPositive(float x) { static public int floorPositive(float x) {
return (int) x; return (int) x;
} }
/** /**
* Returns the smallest integer greater than or equal to the specified * Returns the smallest integer greater than or equal to the specified
* float. This method will only properly ceil floats from * float. This method will only properly ceil floats from
* -(2^14) to (Float.MAX_VALUE - 2^14). * -(2^14) to (Float.MAX_VALUE - 2^14).
*/ */
static public int ceil(float x) { static public int ceil(float x) {
return (int) (x + BIG_ENOUGH_CEIL) - BIG_ENOUGH_INT; return (int) (x + BIG_ENOUGH_CEIL) - BIG_ENOUGH_INT;
} }
/** /**
* Returns the smallest integer greater than or equal to the specified * Returns the smallest integer greater than or equal to the specified
* float. This method will only properly ceil floats that * float. This method will only properly ceil floats that
* are positive. * are positive.
*/ */
static public int ceilPositive(float x) { static public int ceilPositive(float x) {
return (int) (x + CEIL); return (int) (x + CEIL);
} }
/** /**
* Returns the closest integer to the specified float. This method will only * Returns the closest integer to the specified float. This method will only
* properly round floats from -(2^14) to * properly round floats from -(2^14) to
* (Float.MAX_VALUE - 2^14). * (Float.MAX_VALUE - 2^14).
*/ */
static public int round(float x) { static public int round(float x) {
return (int) (x + BIG_ENOUGH_ROUND) - BIG_ENOUGH_INT; return (int) (x + BIG_ENOUGH_ROUND) - BIG_ENOUGH_INT;
} }
/** /**
* Returns the closest integer to the specified float. This method will only * Returns the closest integer to the specified float. This method will only
* properly round floats that are positive. * properly round floats that are positive.
*/ */
static public int roundPositive(float x) { static public int roundPositive(float x) {
return (int) (x + 0.5f); return (int) (x + 0.5f);
} }
} }