From d117dacf08f214b935b790c08bd9ff399157abe5 Mon Sep 17 00:00:00 2001 From: "Stephen M. McQuay" Date: Mon, 7 May 2012 23:17:29 -0600 Subject: [PATCH] Added sample json files. - removed the older util.py module --- blender/samples/cube.json | 1 + blender/samples/spaceship.json | 1 + surf/util.py | 178 --------------------------------- 3 files changed, 2 insertions(+), 178 deletions(-) create mode 100644 blender/samples/cube.json create mode 100644 blender/samples/spaceship.json delete mode 100644 surf/util.py diff --git a/blender/samples/cube.json b/blender/samples/cube.json new file mode 100644 index 0000000..add4de5 --- /dev/null +++ b/blender/samples/cube.json @@ -0,0 +1 @@ +{"vertices": [[-1.0, -1.0, -1.0], [-1.0, 1.0, -1.0], [1.0, 1.0, -1.0], [1.0, -1.0, -1.0], [-1.0, -1.0, 1.0], [-1.0, 1.0, 1.0], [1.0, 1.0, 1.0], [1.0, -1.0, 1.0]], "edges": [[4, 5], [5, 1], [1, 0], [0, 4], [5, 6], [6, 2], [2, 1], [6, 7], [7, 3], [3, 2], [7, 4], [0, 3]], "faces for edge": [[5, 0], [1, 0], [4, 0], [3, 0], [5, 1], [2, 1], [4, 1], [5, 2], [3, 2], [4, 2], [5, 3], [4, 3]], "faces": [[4, 5, 1, 0], [5, 6, 2, 1], [6, 7, 3, 2], [7, 4, 0, 3], [0, 1, 2, 3], [7, 6, 5, 4]], "edges for face": [[0, 1, 2, 3], [4, 5, 6, 1], [7, 8, 9, 5], [10, 3, 11, 8], [2, 6, 9, 11], [7, 4, 0, 10]], "edges for vert": [[2, 3, 11], [1, 2, 6], [5, 6, 9], [8, 9, 11], [0, 3, 10], [0, 1, 4], [4, 5, 7], [7, 8, 10]], "faces for vert": [[4, 0, 3], [1, 0, 4], [2, 1, 4], [3, 2, 4], [0, 3, 5], [5, 0, 1], [5, 1, 2], [5, 2, 3]]} \ No newline at end of file diff --git a/blender/samples/spaceship.json b/blender/samples/spaceship.json new file mode 100644 index 0000000..1c8961e --- /dev/null +++ b/blender/samples/spaceship.json @@ -0,0 +1 @@ +{"vertices": [[0.4239938259124756, 0.4239937663078308, -1.0], [0.4239938259124756, -0.42399370670318604, -1.0], [-0.4239938259124756, -0.42399364709854126, -1.0], [-0.4239935874938965, 0.42399394512176514, -1.0], [1.0000004768371582, 0.999999463558197, 1.0], [0.9999993443489075, -1.0000005960464478, 1.0], [-1.0000003576278687, -0.9999996423721313, 1.0], [-0.9999999403953552, 1.0, 1.0], [1.7187751531600952, 1.718773365020752, 3.6781961917877197], [0.8474826216697693, -1.7187747955322266, 2.689941883087158], [-0.8474841713905334, -1.7187738418579102, 2.689941883087158], [-1.7187739610671997, 1.7187743186950684, 3.6781961917877197], [0.21214807033538818, 5.308051586151123, 0.28254061937332153], [4.481936454772949, -6.694088935852051, 0.1084127426147461], [-4.481936454772949, -6.694085121154785, 0.1084127426147461], [-0.21214735507965088, 5.308051586151123, 0.28254061937332153], [1.0978095531463623, 5.668883323669434, 1.627023696899414], [0.9093747138977051, -26.25899887084961, 12.111918449401855], [-0.9093770980834961, -26.25899887084961, 12.111918449401855], [-1.097808599472046, 5.668883800506592, 1.627023696899414], [-0.4887238144874573, 1.1223108768463135, 1.455737829208374], [-0.4241607189178467, -1.1223105192184448, 1.455737829208374], [0.4241601228713989, -1.1223114728927612, 1.455737829208374], [0.4887240529060364, 1.1223104000091553, 1.455737829208374], [-0.15801039338111877, 5.369452953338623, 0.5113258957862854], [-1.6869838237762451, -10.023368835449219, 2.151001214981079], [1.686983346939087, -10.023370742797852, 2.151001214981079], [0.15801063179969788, 5.369452953338623, 0.5113259553909302], [-2.384185791015625e-07, -10.023369789123535, 2.139824390411377], [1.1920928955078125e-07, 5.369452953338623, 0.6323570013046265], [-1.1920928955078125e-06, -26.25899887084961, 11.297588348388672], [4.7683712978141557e-07, 5.668883323669434, 1.6580955982208252], [0.0, -6.694087028503418, 0.2619309425354004], [3.5762786865234375e-07, 5.308051586151123, 0.42201876640319824], [-7.748603820800781e-07, -1.7187743186950684, 2.555626630783081], [5.960464477539062e-07, 1.7187738418579102, 3.5438809394836426], [-5.364418029785156e-07, -1.0000001192092896, 1.0816290378570557], [2.384185791015625e-07, 0.9999997615814209, 1.0816290378570557], [7.238045185431474e-08, -0.19043827056884766, -0.7571098804473877], [1.0643348247185713e-07, 0.1904383897781372, -0.7571098804473877]], "edges": [[0, 1], [39, 3], [0, 4], [38, 2], [1, 5], [2, 3], [2, 6], [3, 7], [4, 5], [37, 7], [36, 6], [6, 7], [8, 9], [35, 11], [34, 10], [10, 11], [20, 7], [21, 10], [22, 5], [23, 8], [33, 15], [32, 14], [31, 19], [30, 18], [24, 15], [25, 18], [26, 13], [27, 16], [18, 10], [6, 14], [5, 13], [19, 11], [8, 16], [15, 7], [12, 4], [9, 17], [20, 11], [21, 6], [22, 9], [23, 4], [24, 19], [25, 14], [26, 17], [27, 12], [20, 21], [22, 23], [25, 21], [29, 27], [28, 26], [24, 20], [27, 23], [26, 22], [28, 25], [30, 17], [31, 16], [29, 24], [31, 35], [29, 31], [32, 36], [28, 32], [32, 13], [34, 9], [35, 8], [33, 12], [35, 34], [36, 38], [38, 39], [39, 37], [36, 5], [38, 1], [39, 0], [37, 4], [30, 28], [34, 30], [37, 33], [33, 29]], "faces for edge": [[34, 2], [5, 0], [26, 2], [3, 0], [31, 2], [4, 0], [4, 3], [5, 4], [7, 2], [14, 5], [8, 3], [4, 1], [32, 19], [12, 6], [17, 6], [18, 6], [13, 1], [18, 9], [16, 7], [19, 15], [21, 14], [11, 8], [12, 10], [22, 17], [21, 13], [22, 9], [29, 16], [37, 15], [17, 9], [20, 8], [27, 16], [23, 12], [30, 15], [14, 13], [36, 24], [35, 25], [23, 18], [20, 1], [25, 19], [24, 7], [23, 10], [20, 11], [28, 25], [33, 24], [18, 1], [19, 7], [20, 9], [37, 33], [29, 28], [23, 13], [24, 15], [25, 16], [22, 11], [35, 28], [37, 30], [21, 10], [30, 12], [37, 10], [27, 8], [29, 11], [29, 27], [35, 32], [32, 30], [36, 33], [32, 6], [31, 3], [34, 0], [26, 5], [31, 27], [34, 31], [34, 26], [36, 26], [28, 22], [35, 17], [36, 14], [33, 21]], "faces": [[39, 38, 2, 3], [21, 20, 7, 6], [0, 4, 5, 1], [38, 36, 6, 2], [2, 6, 7, 3], [37, 39, 3, 7], [35, 11, 10, 34], [23, 22, 5, 4], [32, 14, 6, 36], [25, 18, 10, 21], [29, 24, 19, 31], [28, 25, 14, 32], [31, 19, 11, 35], [24, 15, 7, 20], [37, 7, 15, 33], [27, 16, 8, 23], [26, 13, 5, 22], [34, 10, 18, 30], [10, 11, 20, 21], [8, 9, 22, 23], [14, 25, 21, 6], [33, 15, 24, 29], [30, 18, 25, 28], [19, 24, 20, 11], [12, 27, 23, 4], [17, 26, 22, 9], [4, 0, 39, 37], [13, 32, 36, 5], [17, 30, 28, 26], [26, 28, 32, 13], [16, 31, 35, 8], [1, 5, 36, 38], [8, 35, 34, 9], [12, 33, 29, 27], [0, 1, 38, 39], [9, 34, 30, 17], [4, 37, 33, 12], [27, 29, 31, 16]], "edges for face": [[66, 3, 5, 1], [44, 16, 11, 37], [2, 8, 4, 0], [65, 10, 6, 3], [6, 11, 7, 5], [67, 1, 7, 9], [13, 15, 14, 64], [45, 18, 8, 39], [21, 29, 10, 58], [25, 28, 17, 46], [55, 40, 22, 57], [52, 41, 21, 59], [22, 31, 13, 56], [24, 33, 16, 49], [9, 33, 20, 74], [27, 32, 19, 50], [26, 30, 18, 51], [14, 28, 23, 73], [15, 36, 44, 17], [12, 38, 45, 19], [41, 46, 37, 29], [20, 24, 55, 75], [23, 25, 52, 72], [40, 49, 36, 31], [43, 50, 39, 34], [42, 51, 38, 35], [2, 70, 67, 71], [60, 58, 68, 30], [53, 72, 48, 42], [48, 59, 60, 26], [54, 56, 62, 32], [4, 68, 65, 69], [62, 64, 61, 12], [63, 75, 47, 43], [0, 69, 66, 70], [61, 73, 53, 35], [71, 74, 63, 34], [47, 57, 54, 27]], "edges for vert": [[0, 2, 70], [0, 4, 69], [3, 5, 6], [1, 5, 7], [2, 8, 34, 39, 71], [4, 8, 18, 30, 68], [6, 10, 11, 29, 37], [7, 9, 11, 16, 33], [12, 19, 32, 62], [12, 35, 38, 61], [14, 15, 17, 28], [13, 15, 31, 36], [34, 43, 63], [26, 30, 60], [21, 29, 41], [20, 24, 33], [27, 32, 54], [35, 42, 53], [23, 25, 28], [22, 31, 40], [16, 36, 44, 49], [17, 37, 44, 46], [18, 38, 45, 51], [19, 39, 45, 50], [24, 40, 49, 55], [25, 41, 46, 52], [26, 42, 48, 51], [27, 43, 47, 50], [48, 52, 59, 72], [47, 55, 57, 75], [23, 53, 72, 73], [22, 54, 56, 57], [21, 58, 59, 60], [20, 63, 74, 75], [14, 61, 64, 73], [13, 56, 62, 64], [10, 58, 65, 68], [9, 67, 71, 74], [3, 65, 66, 69], [1, 66, 67, 70]], "faces for vert": [[34, 2, 26], [2, 31, 34], [3, 0, 4], [0, 4, 5], [26, 2, 24, 7, 36], [2, 7, 16, 27, 31], [3, 8, 4, 20, 1], [4, 5, 1, 13, 14], [19, 15, 30, 32], [32, 25, 19, 35], [6, 18, 9, 17], [12, 6, 23, 18], [36, 24, 33], [29, 16, 27], [11, 8, 20], [14, 21, 13], [37, 15, 30], [35, 25, 28], [17, 22, 9], [10, 12, 23], [1, 23, 18, 13], [18, 20, 1, 9], [7, 25, 19, 16], [19, 24, 7, 15], [13, 10, 23, 21], [9, 11, 20, 22], [16, 28, 29, 25], [15, 33, 37, 24], [28, 11, 29, 22], [33, 10, 37, 21], [22, 35, 28, 17], [12, 37, 30, 10], [8, 27, 11, 29], [21, 36, 14, 33], [17, 32, 6, 35], [6, 12, 30, 32], [3, 8, 31, 27], [14, 5, 26, 36], [0, 3, 34, 31], [5, 0, 26, 34]]} diff --git a/surf/util.py b/surf/util.py deleted file mode 100644 index daf2386..0000000 --- a/surf/util.py +++ /dev/null @@ -1,178 +0,0 @@ -from geometry import Vertex, Edge, Face, Polygon - - -def cube(): - ''' - This function returns a populated Polygon object. The object is a cube with - a vertex at the origin, and another at (1, 1, 1). - - v4 v5 - *-----e8-----* - | | - | | - e|4 f4 e|5 - | | - v4 v|0 v|1 v5 - *-----e4-----*-----e0-----*-----e5-----* - | | | | - | | | | - e11| f3 e|3 f0 e|1 f1 e|9 - | | | | - | | | | - *-----e7-----*-----e2-----*-----e6-----* - v7 v|3 v|2 v6 - | | - e|7 f2 e|6 - | | - v|7 v|6 - *-----e10----* - | | - | | - e|11 f5 e|9 - | | - | | - *-----e8-----* - v4 v5 - v0 - <0,1,0> - v1 - <1,1,0> - v2 - <1,0,0> - v3 - <0,0,0> - v4 - <0,1,1> - v5 - <1,1,1> - v6 - <1,0,1> - v7 - <0,0,1> - - face list - f0 - e0, e1, e2, e3 - f1 - e1, e5, e9, e6 - f2 - e2, e6, e10, e7 - f3 - e4, e3, e7, e11 - f4 - e8, e5, e0, e4 - f5 - e10, e9, e8, e11 - - winged edges ordered by face, then by vertex reference - edge list - e0 - v0, v1; f0, f4; e3, e1, e4, e5 - e1 - v1, v2; f0, f1; e0, e2, e5, e6 - e2 - v3, v2; f0, f2; e3, e7, e1, e6 - e3 - v0, v3; f3, f0; e4, e7, e0, e2 - e4 - v4, v0; f3, f4; e11, e3, e0 e8 - e5 - v5, v1; f4, f1; e8, e0, e9, e1 - e6 - v2, v6; f1, f2; e1, e9, e2, e10 - e7 - v7, v3; f3, f2; e11, e3, e10, e2 - e8 - v4, v5, f4, f5; e4, e5, e11, e9 - e9 - v5, v6; f1, f5; e5, e6, e8, e10 - e10 - v7, v6; f2, f5; e7, e6, e11, e9 - e11 - v4, v7; f3, f5; e4, e7, e8, 10 - - vertex list - v0 - e0, e3, e4 - v1 - e0, e5, e1 - v2 - e1, e6, e2 - v3 - e2, e7, e3 - v4 - e4, e11, e8 - v5 - e5, e9, e8 - v6 - e2, e9, e10 - v7 - e7, e10, e11 - ''' - - p = Polygon() - - # setup vertices - p.vertices = [ - Vertex(p, 0, 1.0, 1.0, 0.0), - Vertex(p, 1, 1.0, 0.0, 0.0), - Vertex(p, 2, 0.0, 1.0, 0.0), - Vertex(p, 3, 0.0, 0.0, 0.0), - Vertex(p, 4, 0.0, 1.0, 1.0), - Vertex(p, 5, 1.0, 1.0, 1.0), - Vertex(p, 6, 1.0, 0.0, 1.0), - Vertex(p, 7, 0.0, 0.0, 1.0)] - - p.vertices[0].edge_ids = [0, 3, 4] - p.vertices[1].edge_ids = [0, 5, 1] - p.vertices[2].edge_ids = [1, 6, 2] - p.vertices[3].edge_ids = [2, 7, 3] - p.vertices[4].edge_ids = [4, 11, 8] - p.vertices[5].edge_ids = [5, 9, 8] - p.vertices[6].edge_ids = [6, 9, 10] - p.vertices[7].edge_ids = [7, 10, 11] - - # setup edges - p.edges = [Edge(p, i) for i in range(12)] - - # winged edges ordered by face, then by vertex reference - # setup edge end vertex ids - p.edges[0].vertex_ids = [0, 1] - p.edges[1].vertex_ids = [1, 2] - p.edges[2].vertex_ids = [2, 3] - p.edges[3].vertex_ids = [3, 0] - p.edges[4].vertex_ids = [0, 4] - p.edges[5].vertex_ids = [5, 1] - p.edges[6].vertex_ids = [2, 6] - p.edges[7].vertex_ids = [7, 3] - p.edges[8].vertex_ids = [4, 5] - p.edges[9].vertex_ids = [5, 6] - p.edges[10].vertex_ids = [7, 6] - p.edges[11].vertex_ids = [4, 7] - - # setup edges winged edge ids - p.edges[0].edge_ids = [3, 1, 4, 5] - p.edges[1].edge_ids = [0, 2, 5, 6] - p.edges[2].edge_ids = [1, 3, 6, 7] - p.edges[3].edge_ids = [4, 7, 0, 2] - p.edges[4].edge_ids = [11, 3, 0, 8] - p.edges[5].edge_ids = [8, 0, 9, 1] - p.edges[6].edge_ids = [1, 9, 2, 10] - p.edges[7].edge_ids = [11, 3, 10, 2] - p.edges[8].edge_ids = [4, 5, 11, 9] - p.edges[9].edge_ids = [5, 6, 8, 10] - p.edges[10].edge_ids = [7, 6, 11, 9] - p.edges[11].edge_ids = [4, 7, 8, 10] - - # setup edge adjacent face ids - p.edges[0].face_ids = [0, 4] - p.edges[1].face_ids = [0, 1] - p.edges[2].face_ids = [0, 2] - p.edges[3].face_ids = [3, 0] - p.edges[4].face_ids = [3, 4] - p.edges[5].face_ids = [4, 1] - p.edges[6].face_ids = [1, 2] - p.edges[7].face_ids = [3, 2] - p.edges[8].face_ids = [4, 5] - p.edges[9].face_ids = [1, 5] - p.edges[10].face_ids = [2, 5] - p.edges[11].face_ids = [3, 5] - - # setup faces - p.faces = [Face(p, i) for i in range(6)] - - # setup face edge ids - p.faces[0].edge_ids = [0, 1, 2, 3] - p.faces[1].edge_ids = [1, 5, 9, 6] - p.faces[2].edge_ids = [2, 6, 10, 7] - p.faces[3].edge_ids = [4, 3, 7, 11] - p.faces[4].edge_ids = [8, 5, 0, 4] - p.faces[5].edge_ids = [10, 9, 8, 11] - - # Polygon stores all the actual data. - # Every other class only stores indices to - # the original data. This could be slightly - # dangerous if any items get appended to the - # list of objects or the indices get changed. - - - # These are all the same vertex, just testing to make - # sure I did it right. - - # print p.vertices[1].x - # edge_v_id = p.edges[1].vertex_ids[0] - # print p.vertices[edge_v_id].x - - # face_edge_id = p.faces[0].edge_ids[1] - # edge_v_id = p.edges[face_edge_id].vertex_ids[0] - # print p.vertices[edge_v_id].x - - return p - -# print cube()