diff --git a/Cargo.toml b/Cargo.toml index a351ac0..840023c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -56,6 +56,9 @@ name = "sprite" [[example]] name = "group" +[[example]] +name = "anim" + [[example]] name = "aviator" path = "examples/aviator/main.rs" diff --git a/examples/anim.rs b/examples/anim.rs new file mode 100644 index 0000000..f978922 --- /dev/null +++ b/examples/anim.rs @@ -0,0 +1,137 @@ +extern crate gfx; +extern crate mint; +extern crate three; + +const SCALE: f32 = 1.0 / 10.0; +const VERTICES: &[i16] = &[0,101,79,0,55,189,0,-80,-186,0,88,-85,-110,-66,-79,1,-50,328,-25,-14,426,-95,-81,54,5,2,914,-64,-117,28,2,27,542,0,-102,-122,-70,-70,-148,-110,72,62,-27,-45,290,0,-133,29,-23,93,828,2,-24,551,5,104,825,6,10,1004,3,53,713,-82,27,-197,-82,-116,-132,6,-13,953,6,97,899,0,30,231,-129,-16,-100,-20,15,719,-55,-18,196,-18,-16,974,0,57,-181,5,-90,979,-18,13,423,0,107,-17,4,18,819,-93,60,133,-66,-53,-156,1,19,417,0,-26,-266,-24,43,911,-32,6,285,-31,-38,-259,-26,40,832,-57,17,195,-24,-10,553,-64,-116,-150,1,-36,425,-20,77,909,-40,57,-160,-36,-7,303,-25,39,715,-137,-33,-51,6,48,974,4,70,765,-115,18,85,-30,-20,354,-34,-73,-187,1,-38,362,-24,12,550,-63,82,-99,-30,-68,-252,-119,59,92,5,-4,882,-69,-84,-152,-40,-69,-290,0,-67,-283,-85,97,-25,-16,13,986,0,20,272,-65,-85,-345,0,-72,247,0,-56,-364,-56,-102,-159,-89,-97,-138,-80,-169,-348,-69,-168,-348,-63,-158,-351,-74,-152,-353,-85,-158,-351,-91,-277,-688,-63,-278,-688,-95,-241,-698,-58,-243,-700,-57,-175,-407,-74,-155,-413,-65,-188,-464,-75,-182,-465,-100,-174,-407,-86,-196,-461,-92,-197,-401,-81,-203,-460,-66,-196,-401,-70,-202,-460,-67,-253,-676,-75,-248,-677,-83,-254,-676,-81,-262,-673,-71,-261,-673,-28,38,191,-38,-66,-292,-130,-398,200,-212,-350,-59,-169,-48,-22,-255,-355,-108,-102,-393,204,-101,-5,100,-189,-394,68,-203,-239,35,-158,-169,160,-130,-166,170,-120,-171,143,-216,-221,-147,-250,-357,-78,-231,-206,-151,-212,-198,-182,-105,-396,217,-219,-469,-64,-215,-472,-78,-64,-641,224,-193,-541,-19,-36,-636,228,-40,-638,241,-158,-387,60,-161,-534,-29,-48,-635,196,-73,-640,205,-100,-603,161,-75,-597,151,-119,-628,105,-92,-622,92,-146,-584,67,-119,-577,51,-162,-587,26,-132,-581,14,-60,-765,131,-101,-721,56,-135,-669,5,-163,-615,-33,-24,-726,238,-25,-784,203,-136,4,27,-162,-191,22,124,-59,-80,28,-14,426,95,-56,76,64,-117,28,70,-70,-148,113,74,62,28,-45,290,34,93,828,85,28,-198,79,-116,-132,129,-16,-100,28,15,719,55,-18,196,30,-16,973,22,13,423,93,60,133,66,-53,-156,36,43,911,34,6,284,31,-38,-259,37,40,831,57,17,195,29,-10,552,62,-116,-150,33,76,908,40,57,-160,37,-7,303,33,39,715,137,-33,-51,115,18,85,33,-20,354,36,-72,-188,29,11,549,63,82,-99,30,-68,-252,122,61,92,67,-84,-152,40,-69,-290,85,97,-25,28,12,986,65,-85,-345,53,-102,-159,87,-97,-137,78,-169,-348,67,-168,-348,61,-158,-351,72,-152,-353,83,-159,-351,84,-275,-688,60,-275,-688,88,-243,-697,56,-245,-700,55,-175,-407,71,-155,-413,61,-188,-464,71,-182,-465,97,-174,-407,82,-196,-461,89,-197,-401,77,-203,-460,63,-196,-401,66,-202,-460,64,-253,-676,73,-248,-677,80,-254,-676,78,-262,-673,68,-261,-673,28,38,191,38,-66,-292,143,-392,194,224,-342,-65,178,-64,-4,267,-347,-114,115,-387,198,109,-2,99,201,-387,62,217,-233,34,172,-162,159,144,-160,169,133,-165,143,230,-213,-148,263,-350,-84,245,-199,-153,226,-190,-183,118,-389,211,231,-462,-71,227,-464,-84,77,-635,217,205,-534,-26,49,-630,221,53,-632,234,170,-381,54,173,-527,-36,61,-629,189,86,-634,198,113,-596,154,87,-591,144,131,-622,98,105,-616,85,158,-577,60,131,-570,44,175,-580,19,145,-574,7,73,-759,123,114,-714,49,147,-662,-2,176,-608,-40,37,-720,231,38,-778,195,139,5,27,176,-184,21,72,-272,-762,-77,-272,-758,40,58,900,46,65,844,44,72,875,45,39,864,43,54,869,41,61,882,38,67,860,47,83,856,33,64,871,-33,40,864,-27,59,901,-34,65,845,-36,84,856,-21,64,871,-29,61,883,-31,55,870,-27,68,860,-32,73,875]; +const INDICES: &[u16] = &[10,0,35,1,0,2,0,3,10,1,35,98,0,3,0,1,10,60,36,41,0,4,5,6,10,41,36,21,0,6,5,7,10,38,41,30,0,8,9,10,10,30,41,48,0,10,9,11,10,43,54,28,0,12,13,14,10,28,54,7,0,14,13,15,10,59,3,48,0,16,17,11,10,48,3,30,0,11,17,10,10,21,36,26,0,7,5,19,10,26,36,12,0,19,5,18,10,59,66,3,0,16,20,17,10,3,66,33,0,17,20,21,10,15,70,9,0,22,23,24,10,59,48,21,0,16,11,25,10,21,48,41,0,25,11,9,10,54,43,35,0,13,12,26,10,35,43,98,0,26,12,27,10,49,28,14,0,28,14,29,10,49,40,43,0,28,30,12,10,68,25,40,0,31,32,30,10,40,25,43,0,30,32,12,10,32,37,40,0,33,34,30,10,40,37,68,0,30,34,31,10,57,55,5,0,35,36,37,10,5,55,49,0,37,36,28,10,34,27,17,0,38,39,40,10,17,27,44,0,40,39,41,10,63,56,11,0,42,43,44,10,2,11,56,0,45,44,43,10,73,22,51,0,46,47,48,10,51,22,7,0,48,47,15,10,22,9,7,0,47,24,15,10,7,9,28,0,15,24,14,10,9,45,15,0,24,49,22,10,58,50,10,0,50,51,52,10,10,50,20,0,52,51,53,10,12,36,63,0,18,5,42,10,63,36,56,0,42,5,43,10,9,70,28,0,24,23,14,10,28,70,14,0,14,23,29,10,49,14,5,0,28,29,37,10,5,14,70,0,37,29,23,10,72,63,11,0,54,42,44,10,16,18,53,0,55,56,57,10,46,6,57,0,58,59,35,10,57,6,55,0,35,59,36,10,47,24,18,0,60,61,56,10,47,52,24,0,60,62,61,10,42,266,16,0,63,64,55,10,16,266,267,0,55,64,65,10,270,264,269,0,66,67,68,10,269,264,265,0,68,67,69,10,47,265,67,0,60,69,70,10,67,39,29,0,70,71,72,10,1,98,25,0,73,27,32,10,25,98,43,0,32,27,12,10,51,140,26,0,48,74,19,10,26,140,4,0,19,74,75,10,42,53,50,0,63,57,51,10,50,53,20,0,51,57,53,10,50,27,42,0,51,39,63,10,29,31,67,0,72,76,70,10,8,23,39,0,77,78,71,10,23,31,29,0,78,76,72,10,58,10,32,0,50,52,33,10,32,10,37,0,33,52,34,10,40,49,32,0,30,28,33,10,49,55,32,0,28,36,33,10,55,6,32,0,36,59,33,10,0,13,35,0,2,79,0,10,35,13,61,0,0,79,80,10,44,58,6,0,41,50,59,10,6,58,32,0,59,50,33,10,46,44,6,0,58,41,59,10,23,29,39,0,78,72,71,10,16,53,42,0,55,57,63,10,50,58,27,0,51,50,39,10,27,58,44,0,39,50,41,10,22,45,9,0,47,49,24,10,17,44,46,0,40,41,58,10,54,140,7,0,13,74,15,10,7,140,51,0,15,74,48,10,19,52,67,0,81,62,70,10,67,52,47,0,70,62,60,10,67,31,19,0,70,76,81,10,64,60,41,0,82,83,9,10,56,60,2,0,43,4,45,10,2,60,65,0,45,4,84,10,62,42,34,0,85,63,38,10,34,42,27,0,38,63,39,10,71,41,38,0,86,9,8,10,65,60,64,0,87,83,82,10,22,74,45,0,88,89,90,10,45,74,75,0,90,89,91,10,76,72,75,0,92,93,91,10,75,72,45,0,91,93,90,10,76,77,72,0,92,94,93,10,72,77,63,0,93,94,95,10,77,78,63,0,94,96,95,10,63,78,73,0,95,96,97,10,78,74,73,0,96,89,97,10,73,74,22,0,97,89,88,10,85,86,83,0,98,99,100,10,83,86,84,0,100,99,101,10,88,87,86,0,102,103,99,10,86,87,84,0,99,103,101,10,90,89,88,0,104,105,102,10,88,89,87,0,102,105,103,10,92,91,90,0,106,107,104,10,90,91,89,0,104,107,105,10,85,83,92,0,98,100,106,10,92,83,91,0,106,100,107,10,78,87,74,0,96,103,89,10,74,87,89,0,89,103,105,10,89,91,74,0,105,107,89,10,74,91,75,0,89,107,91,10,91,83,75,0,107,100,91,10,75,83,76,0,91,100,92,10,84,77,83,0,101,94,100,10,83,77,76,0,100,94,92,10,87,78,84,0,103,96,101,10,84,78,77,0,101,96,94,10,93,94,85,0,108,109,98,10,85,94,86,0,98,109,99,10,95,88,94,0,110,102,109,10,94,88,86,0,109,102,99,10,95,96,88,0,110,111,102,10,88,96,90,0,102,111,104,10,96,97,90,0,111,112,104,10,90,97,92,0,104,112,106,10,97,93,92,0,112,108,106,10,92,93,85,0,106,108,98,10,81,79,95,0,113,114,110,10,95,79,96,0,110,114,111,10,80,97,79,0,115,112,114,10,79,97,96,0,114,112,111,10,82,93,80,0,116,108,115,10,80,93,97,0,115,108,112,10,82,81,94,0,116,113,109,10,81,95,94,0,113,110,109,10,42,62,264,0,63,85,67,10,264,62,39,0,67,85,71,10,39,62,8,0,71,85,77,10,51,26,73,0,48,19,46,10,63,73,12,0,42,46,18,10,26,12,73,0,19,18,46,10,21,26,4,0,7,19,75,10,33,66,0,0,21,20,2,10,0,66,13,0,2,20,79,10,82,94,93,0,116,109,108,10,72,11,45,0,54,44,49,10,15,45,11,0,22,49,44,10,99,71,69,0,117,86,118,10,41,99,64,0,9,117,82,10,71,99,41,0,86,117,9,10,64,99,69,0,82,117,118,10,69,71,64,0,118,86,82,10,64,71,65,0,82,86,87,10,54,35,105,0,13,26,119,10,105,35,61,0,119,26,120,10,107,106,100,0,121,122,123,10,110,104,141,0,124,125,126,10,141,104,122,0,126,125,127,10,108,13,102,0,128,79,129,10,102,13,66,0,129,79,20,10,13,108,61,0,79,128,80,10,61,108,109,0,80,128,130,10,110,105,109,0,124,131,130,10,109,105,61,0,130,131,80,10,105,110,140,0,131,124,132,10,140,110,141,0,132,124,126,10,21,113,102,0,25,133,129,10,102,113,107,0,129,133,121,10,113,112,107,0,133,134,121,10,107,112,106,0,121,134,122,10,112,113,103,0,134,133,135,10,103,113,114,0,135,133,136,10,66,59,102,0,20,16,129,10,102,59,21,0,129,16,25,10,115,109,100,0,137,130,123,10,100,109,108,0,123,130,128,10,115,104,109,0,137,125,130,10,109,104,110,0,130,125,124,10,21,4,114,0,25,138,136,10,114,4,111,0,136,138,139,10,102,107,108,0,129,121,128,10,108,107,100,0,128,121,123,10,101,103,111,0,140,135,139,10,111,103,114,0,139,135,136,10,103,117,112,0,135,141,134,10,112,117,116,0,134,141,142,10,118,100,125,0,143,123,144,10,126,125,100,0,145,144,123,10,112,116,106,0,134,142,122,10,106,116,119,0,122,142,146,10,121,120,115,0,147,148,137,10,115,120,104,0,137,148,125,10,100,118,115,0,123,143,137,10,115,118,121,0,137,143,147,10,131,133,122,0,149,150,127,10,133,123,122,0,150,151,127,10,101,122,123,0,140,127,151,10,117,123,116,0,141,151,142,10,116,123,119,0,142,151,146,10,129,134,128,0,152,153,154,10,128,134,126,0,154,153,145,10,126,134,127,0,145,153,155,10,127,134,129,0,155,153,152,10,131,135,130,0,149,156,157,10,130,135,128,0,157,156,154,10,128,135,129,0,154,156,152,10,129,135,131,0,152,156,149,10,133,136,132,0,150,158,159,10,132,136,130,0,159,158,157,10,130,136,131,0,157,158,149,10,131,136,133,0,149,158,150,10,123,137,119,0,151,160,146,10,119,137,132,0,146,160,159,10,132,137,133,0,159,160,150,10,133,137,123,0,150,160,151,10,124,138,125,0,161,162,144,10,125,138,118,0,144,162,143,10,118,138,121,0,143,162,147,10,121,138,120,0,147,162,148,10,120,138,124,0,148,162,161,10,127,139,126,0,155,163,145,10,126,139,125,0,145,163,144,10,125,139,124,0,144,163,161,10,124,139,127,0,161,163,155,10,103,101,117,0,135,140,141,10,117,101,123,0,141,140,151,10,126,100,128,0,145,123,154,10,130,128,100,0,157,154,123,10,100,106,130,0,123,122,157,10,130,106,132,0,157,122,159,10,106,119,132,0,122,146,159,10,21,114,113,0,25,136,133,10,104,127,122,0,125,155,127,10,127,129,122,0,155,152,127,10,129,131,122,0,152,149,127,10,120,124,104,0,148,161,125,10,104,124,127,0,125,161,155,10,140,54,105,0,74,13,119,10,111,4,141,0,139,138,126,10,141,4,140,0,126,138,132,10,111,141,101,0,139,126,140,10,101,141,122,0,140,126,127,10,47,18,16,0,60,56,55,10,0,1,157,0,2,3,165,10,157,1,209,0,165,3,164,10,150,158,161,0,166,167,168,10,161,158,176,0,168,167,169,10,38,30,161,0,8,10,170,10,161,30,167,0,170,10,171,10,163,154,171,0,172,173,174,10,171,154,144,0,174,173,175,10,175,167,3,0,176,171,17,10,3,167,30,0,17,171,10,10,146,158,152,0,177,167,178,10,152,158,150,0,178,167,166,10,33,180,3,0,21,179,17,10,3,180,175,0,17,179,176,10,173,176,158,0,180,169,167,10,15,145,70,0,22,181,23,10,161,167,150,0,170,171,182,10,150,167,175,0,182,171,176,10,209,163,157,0,183,172,184,10,157,163,171,0,184,172,174,10,148,154,168,0,185,173,186,10,163,160,168,0,172,187,186,10,163,25,160,0,172,32,187,10,160,25,68,0,187,32,31,10,68,37,160,0,31,34,187,10,160,37,156,0,187,34,188,10,168,172,5,0,186,189,37,10,5,172,57,0,37,189,35,10,164,153,17,0,190,191,40,10,17,153,34,0,40,191,38,10,178,11,173,0,192,44,180,10,2,173,11,0,45,180,44,10,184,170,151,0,193,194,195,10,151,170,144,0,195,194,175,10,154,145,144,0,173,181,175,10,144,145,151,0,175,181,195,10,145,15,165,0,181,22,196,10,174,10,169,0,197,52,198,10,169,10,20,0,198,52,53,10,146,178,158,0,177,192,167,10,158,178,173,0,167,192,180,10,148,70,154,0,185,23,173,10,154,70,145,0,173,23,181,10,70,148,5,0,23,185,37,10,5,148,168,0,37,185,186,10,183,11,178,0,199,44,192,10,149,53,18,0,200,57,56,10,46,57,143,0,58,35,201,10,143,57,172,0,201,35,189,10,166,18,24,0,202,56,61,10,166,24,52,0,202,61,62,10,255,260,257,0,203,204,205,10,166,262,149,0,202,206,200,10,255,181,159,0,203,207,208,10,159,181,155,0,208,207,209,10,1,25,209,0,73,32,183,10,209,25,163,0,183,32,172,10,170,152,251,0,194,178,210,10,251,152,142,0,210,178,211,10,162,169,53,0,212,198,57,10,53,169,20,0,57,198,53,10,169,162,153,0,198,212,191,10,155,181,31,0,209,207,76,10,8,159,23,0,77,208,78,10,23,155,31,0,78,209,76,10,174,156,10,0,197,188,52,10,10,156,37,0,52,188,34,10,160,156,168,0,187,188,186,10,168,156,172,0,186,188,189,10,156,143,172,0,188,201,189,10,0,157,147,0,2,165,213,10,147,157,177,0,213,165,214,10,164,143,174,0,190,201,197,10,143,156,174,0,201,188,197,10,46,143,164,0,58,201,190,10,23,159,155,0,78,208,209,10,71,38,161,0,86,8,170,10,149,162,53,0,200,212,57,10,164,174,153,0,190,197,191,10,153,174,169,0,191,197,198,10,151,145,165,0,195,181,196,10,17,46,164,0,40,58,190,10,170,251,144,0,194,210,175,10,144,251,171,0,175,210,174,10,166,52,181,0,202,62,207,10,181,52,19,0,207,62,81,10,181,19,31,0,207,81,76,10,173,2,176,0,180,45,169,10,176,2,65,0,169,45,84,10,179,161,176,0,215,170,216,10,153,162,34,0,191,212,38,10,34,162,62,0,38,212,85,10,65,179,176,0,87,215,216,10,151,165,185,0,217,218,219,10,185,165,186,0,219,218,220,10,165,183,186,0,218,221,220,10,186,183,187,0,220,221,222,10,187,183,188,0,222,221,223,10,188,183,178,0,223,221,224,10,188,178,189,0,223,224,225,10,189,178,184,0,225,224,226,10,189,184,185,0,225,226,219,10,185,184,151,0,219,226,217,10,195,197,194,0,227,228,229,10,194,197,196,0,229,228,230,10,195,198,197,0,227,231,228,10,197,198,199,0,228,231,232,10,198,200,199,0,231,233,232,10,199,200,201,0,232,233,234,10,200,202,201,0,233,235,234,10,201,202,203,0,234,235,236,10,202,194,203,0,235,229,236,10,203,194,196,0,236,229,230,10,189,185,198,0,225,219,231,10,198,185,200,0,231,219,233,10,200,185,202,0,233,219,235,10,202,185,186,0,235,219,220,10,202,186,194,0,235,220,229,10,194,186,187,0,229,220,222,10,187,188,194,0,222,223,229,10,194,188,195,0,229,223,227,10,188,189,195,0,223,225,227,10,195,189,198,0,227,225,231,10,197,205,196,0,228,237,230,10,196,205,204,0,230,237,238,10,197,199,205,0,228,232,237,10,205,199,206,0,237,232,239,10,206,199,207,0,239,232,240,10,207,199,201,0,240,232,234,10,207,201,208,0,240,234,241,10,208,201,203,0,241,234,236,10,208,203,204,0,241,236,238,10,204,203,196,0,238,236,230,10,207,190,206,0,240,242,239,10,206,190,192,0,239,242,243,10,207,208,190,0,240,241,242,10,190,208,191,0,242,241,244,10,193,191,204,0,245,244,238,10,204,191,208,0,238,244,241,10,193,205,192,0,245,237,243,10,192,205,206,0,243,237,239,10,162,258,62,0,212,246,85,10,62,258,159,0,85,246,208,10,62,159,8,0,85,208,77,10,170,184,152,0,194,193,178,10,178,146,184,0,192,177,193,10,184,146,152,0,193,177,178,10,150,142,152,0,166,211,178,10,33,0,180,0,21,2,179,10,180,0,147,0,179,2,213,10,193,204,205,0,245,238,237,10,183,165,11,0,199,196,44,10,15,11,165,0,22,44,196,10,210,182,71,0,247,248,86,10,161,179,210,0,170,215,247,10,71,161,210,0,86,170,247,10,179,182,210,0,215,248,247,10,65,71,179,0,87,86,215,10,179,71,182,0,215,86,248,10,171,216,157,0,174,249,184,10,157,216,177,0,184,249,250,10,218,211,217,0,251,252,253,10,233,215,252,0,254,255,256,10,252,215,221,0,256,255,257,10,219,213,147,0,258,259,213,10,147,213,180,0,213,259,179,10,220,219,177,0,260,258,214,10,177,219,147,0,214,258,213,10,177,216,220,0,214,261,260,10,220,216,221,0,260,261,257,10,216,251,221,0,261,262,257,10,221,251,252,0,257,262,256,10,218,224,213,0,251,263,259,10,213,224,150,0,259,263,182,10,224,218,223,0,263,251,264,10,223,218,217,0,264,251,253,10,225,224,214,0,265,263,266,10,214,224,223,0,266,263,264,10,180,213,175,0,179,259,176,10,175,213,150,0,176,259,182,10,219,220,211,0,258,260,252,10,211,220,226,0,252,260,267,10,221,215,220,0,257,255,260,10,220,215,226,0,260,255,267,10,222,142,225,0,268,269,265,10,225,142,150,0,265,269,182,10,211,218,219,0,252,251,258,10,219,218,213,0,258,251,259,10,212,222,214,0,270,268,266,10,214,222,225,0,266,268,265,10,214,223,228,0,266,264,271,10,228,223,227,0,271,264,272,10,229,236,211,0,273,274,252,10,237,211,236,0,275,252,274,10,230,227,217,0,276,272,253,10,223,217,227,0,264,253,272,10,215,231,226,0,255,277,267,10,226,231,232,0,267,277,278,10,211,226,229,0,252,267,273,10,229,226,232,0,273,267,278,10,242,233,244,0,279,254,280,10,233,234,244,0,254,281,280,10,212,234,233,0,270,281,254,10,227,230,228,0,272,276,271,10,228,230,234,0,271,276,281,10,240,239,245,0,282,283,284,10,239,237,245,0,283,275,284,10,237,238,245,0,275,285,284,10,238,240,245,0,285,282,284,10,242,241,246,0,279,286,287,10,241,239,246,0,286,283,287,10,239,240,246,0,283,282,287,10,240,242,246,0,282,279,287,10,244,243,247,0,280,288,289,10,243,241,247,0,288,286,289,10,241,242,247,0,286,279,289,10,242,244,247,0,279,280,289,10,234,230,248,0,281,276,290,10,230,243,248,0,276,288,290,10,243,244,248,0,288,280,290,10,244,234,248,0,280,281,290,10,235,236,249,0,291,274,292,10,236,229,249,0,274,273,292,10,229,232,249,0,273,278,292,10,232,231,249,0,278,277,292,10,231,235,249,0,277,291,292,10,238,237,250,0,285,275,293,10,237,236,250,0,275,274,293,10,236,235,250,0,274,291,293,10,235,238,250,0,291,285,293,10,234,212,228,0,281,270,271,10,228,212,214,0,271,270,266,10,241,217,211,0,286,253,252,10,211,237,239,0,252,275,283,10,241,211,239,0,286,252,283,10,241,243,217,0,286,288,253,10,217,243,230,0,253,288,276,10,150,224,225,0,182,263,265,10,215,233,238,0,255,254,285,10,238,233,240,0,285,254,282,10,233,242,240,0,254,279,282,10,231,215,235,0,277,255,291,10,215,238,235,0,255,285,291,10,251,216,171,0,210,249,174,10,251,142,252,0,262,269,256,10,252,142,222,0,256,269,268,10,233,252,212,0,254,256,270,10,212,252,222,0,270,256,268,10,166,149,18,0,202,200,56,10,190,253,192,0,242,294,243,10,191,193,253,0,244,245,294,10,253,193,192,0,294,245,243,10,191,253,190,0,244,294,242,10,82,254,81,0,116,295,113,10,80,79,254,0,115,114,295,10,254,79,81,0,295,114,113,10,80,254,82,0,115,295,116,2,60,56,36,0,10,168,154,163,0,186,173,172,10,43,28,49,0,12,14,28,10,257,262,166,0,205,206,202,10,159,258,255,0,208,246,203,10,258,162,256,0,246,212,296,10,259,256,261,0,297,296,298,10,260,263,257,0,204,299,205,10,259,260,258,0,297,204,246,10,258,260,255,0,246,204,203,10,263,261,257,0,299,298,205,10,262,256,149,0,206,296,200,10,149,256,162,0,200,296,212,10,260,259,263,0,204,297,299,10,259,261,263,0,297,298,299,10,257,261,262,0,205,298,206,10,262,261,256,0,206,298,296,10,258,256,259,0,246,296,297,10,255,257,166,0,203,205,202,10,265,272,269,0,69,300,68,10,16,267,47,0,55,65,60,10,272,267,271,0,300,65,301,10,271,267,266,0,301,65,64,10,266,264,270,0,64,67,66,10,268,270,269,0,302,66,68,10,271,270,268,0,301,66,302,10,272,271,268,0,300,301,302,10,269,272,268,0,68,300,302,10,266,270,271,0,64,66,301,10,266,42,264,0,64,63,67,10,265,264,39,0,69,67,71,10,47,272,265,0,60,300,69,10,47,267,272,0,60,65,300,10,67,265,39,0,70,69,71,2,166,181,255,0]; + +const V_FLY: [&[i16]; 14] = [ + &[0,101,79,0,55,189,0,-80,-186,0,88,-85,-110,-66,-79,1,-50,328,-25,-14,426,-95,-81,54,5,2,914,-64,-117,28,2,27,542,0,-102,-122,-70,-70,-148,-110,72,62,-27,-45,290,0,-133,29,-23,93,828,2,-24,551,5,104,825,6,10,1004,3,53,713,-82,27,-197,-82,-116,-132,6,-13,953,6,97,899,0,30,231,-129,-16,-100,-20,15,719,-55,-18,196,-18,-16,974,0,57,-181,5,-90,979,-18,13,423,0,107,-17,4,18,819,-93,60,133,-66,-53,-156,1,19,417,0,-26,-266,-24,43,911,-32,6,285,-31,-38,-259,-26,40,832,-57,17,195,-24,-10,553,-64,-116,-150,1,-36,425,-20,77,909,-40,57,-160,-36,-7,303,-25,39,715,-137,-33,-51,6,48,974,4,70,765,-115,18,85,-30,-20,354,-34,-73,-187,1,-38,362,-24,12,550,-63,82,-99,-30,-68,-252,-119,59,92,5,-4,882,-69,-84,-152,-40,-69,-290,0,-67,-283,-85,97,-25,-16,13,986,0,20,272,-65,-85,-345,0,-72,247,0,-56,-364,-56,-102,-159,-89,-97,-138,-80,-169,-348,-69,-168,-348,-63,-158,-351,-74,-152,-353,-85,-158,-351,-91,-277,-688,-63,-278,-688,-95,-241,-698,-58,-243,-700,-57,-175,-407,-74,-155,-413,-65,-188,-464,-75,-182,-465,-100,-174,-407,-86,-196,-461,-92,-197,-401,-81,-203,-460,-66,-196,-401,-70,-202,-460,-67,-253,-676,-75,-248,-677,-83,-254,-676,-81,-262,-673,-71,-261,-673,-28,38,191,-38,-66,-292,-130,-398,200,-212,-350,-59,-169,-48,-22,-255,-355,-108,-102,-393,204,-101,-5,100,-189,-394,68,-203,-239,35,-158,-169,160,-130,-166,170,-120,-171,143,-216,-221,-147,-250,-357,-78,-231,-206,-151,-212,-198,-182,-105,-396,217,-219,-469,-64,-215,-472,-78,-64,-641,224,-193,-541,-19,-36,-636,228,-40,-638,241,-158,-387,60,-161,-534,-29,-48,-635,196,-73,-640,205,-100,-603,161,-75,-597,151,-119,-628,105,-92,-622,92,-146,-584,67,-119,-577,51,-162,-587,26,-132,-581,14,-60,-765,131,-101,-721,56,-135,-669,5,-163,-615,-33,-24,-726,238,-25,-784,203,-136,4,27,-162,-191,22,124,-59,-80,28,-14,426,95,-56,76,64,-117,28,70,-70,-148,113,74,62,28,-45,290,34,93,828,85,28,-198,79,-116,-132,129,-16,-100,28,15,719,55,-18,196,30,-16,973,22,13,423,93,60,133,66,-53,-156,36,43,911,34,6,284,31,-38,-259,37,40,831,57,17,195,29,-10,552,62,-116,-150,33,76,908,40,57,-160,37,-7,303,33,39,715,137,-33,-51,115,18,85,33,-20,354,36,-72,-188,29,11,549,63,82,-99,30,-68,-252,122,61,92,67,-84,-152,40,-69,-290,85,97,-25,28,12,986,65,-85,-345,53,-102,-159,87,-97,-137,78,-169,-348,67,-168,-348,61,-158,-351,72,-152,-353,83,-159,-351,84,-275,-688,60,-275,-688,88,-243,-697,56,-245,-700,55,-175,-407,71,-155,-413,61,-188,-464,71,-182,-465,97,-174,-407,82,-196,-461,89,-197,-401,77,-203,-460,63,-196,-401,66,-202,-460,64,-253,-676,73,-248,-677,80,-254,-676,78,-262,-673,68,-261,-673,28,38,191,38,-66,-292,143,-392,194,224,-342,-65,178,-64,-4,267,-347,-114,115,-387,198,109,-2,99,201,-387,62,217,-233,34,172,-162,159,144,-160,169,133,-165,143,230,-213,-148,263,-350,-84,245,-199,-153,226,-190,-183,118,-389,211,231,-462,-71,227,-464,-84,77,-635,217,205,-534,-26,49,-630,221,53,-632,234,170,-381,54,173,-527,-36,61,-629,189,86,-634,198,113,-596,154,87,-591,144,131,-622,98,105,-616,85,158,-577,60,131,-570,44,175,-580,19,145,-574,7,73,-759,123,114,-714,49,147,-662,-2,176,-608,-40,37,-720,231,38,-778,195,139,5,27,176,-184,21,72,-272,-762,-77,-272,-758,40,58,900,46,65,844,44,72,875,45,39,864,43,54,869,41,61,882,38,67,860,47,83,856,33,64,871,-33,40,864,-27,59,901,-34,65,845,-36,84,856,-21,64,871,-29,61,883,-31,55,870,-27,68,860,-32,73,875], + &[0,112,79,0,65,189,0,-69,-186,0,99,-84,-107,-52,-76,1,-40,328,-25,-5,426,-95,-70,54,5,13,914,-64,-106,27,2,35,543,0,-91,-122,-70,-59,-148,-111,84,63,-27,-34,290,0,-122,29,-23,104,827,2,-16,552,5,115,825,6,21,1004,3,63,713,-80,39,-197,-82,-105,-133,6,-2,953,6,108,899,0,40,231,-129,-5,-100,-20,25,719,-55,-7,196,-18,-5,974,0,68,-181,5,-79,979,-18,22,423,0,117,-17,4,29,819,-93,70,133,-66,-42,-156,1,28,417,0,-15,-266,-24,54,911,-32,17,285,-31,-26,-259,-26,51,831,-57,27,195,-24,-2,553,-64,-104,-150,1,-27,425,-20,88,908,-40,68,-160,-36,2,303,-25,49,715,-137,-22,-51,6,59,974,4,81,764,-115,28,85,-30,-10,354,-31,-62,-186,1,-28,361,-24,19,550,-63,93,-98,-30,-56,-252,-121,71,93,5,6,882,-69,-73,-152,-40,-58,-290,0,-56,-283,-85,108,-25,-16,24,986,0,30,272,-65,-73,-346,0,-62,247,0,-44,-364,-56,-91,-159,-89,-86,-138,-80,-156,-348,-69,-156,-349,-63,-146,-352,-74,-139,-354,-85,-146,-352,-91,-265,-689,-63,-265,-689,-95,-228,-698,-58,-230,-700,-57,-162,-408,-74,-142,-414,-65,-175,-464,-75,-169,-466,-100,-161,-408,-86,-183,-462,-92,-184,-401,-81,-190,-460,-66,-183,-402,-70,-189,-460,-67,-241,-676,-75,-236,-678,-83,-242,-676,-81,-250,-674,-71,-249,-674,-28,48,192,-38,-54,-292,-164,-392,203,-223,-317,-55,-169,-34,-15,-261,-318,-109,-136,-386,211,-107,6,103,-210,-375,68,-219,-219,31,-182,-152,160,-155,-151,173,-142,-156,148,-216,-199,-151,-260,-324,-79,-230,-185,-156,-209,-178,-186,-141,-390,223,-222,-435,-75,-217,-435,-88,-84,-631,205,-195,-510,-36,-56,-626,213,-61,-630,225,-179,-366,64,-163,-500,-42,-66,-621,180,-90,-629,186,-116,-588,144,-90,-580,137,-127,-608,84,-100,-599,75,-153,-560,49,-126,-550,36,-166,-560,6,-136,-550,-1,-62,-743,99,-99,-692,27,-131,-636,-21,-159,-580,-55,-39,-715,213,-33,-768,171,-137,15,28,-176,-172,23,121,-44,-77,28,-6,426,95,-45,76,64,-106,27,70,-59,-148,114,85,63,28,-35,290,34,104,827,82,40,-197,79,-105,-133,129,-5,-100,28,25,719,55,-7,196,30,-5,973,22,22,423,93,70,133,66,-42,-156,36,53,910,34,16,285,31,-26,-259,37,51,831,57,27,195,29,-2,553,62,-104,-150,33,87,908,40,68,-160,37,2,303,33,49,714,137,-22,-51,115,28,85,33,-10,354,33,-61,-186,29,19,550,63,93,-98,30,-56,-252,124,72,93,67,-73,-152,40,-58,-290,85,108,-25,28,23,985,65,-73,-346,53,-91,-159,87,-86,-138,78,-156,-348,67,-156,-349,61,-146,-352,72,-139,-354,83,-146,-352,84,-263,-690,60,-263,-690,88,-231,-697,56,-232,-700,55,-162,-408,71,-142,-414,61,-175,-464,71,-169,-466,97,-161,-408,82,-183,-462,89,-184,-401,77,-190,-460,63,-183,-402,66,-189,-460,64,-241,-676,73,-236,-678,80,-242,-676,78,-250,-674,68,-249,-674,28,48,192,38,-54,-292,163,-382,197,228,-310,-61,181,-45,-5,267,-313,-114,136,-375,204,114,10,102,211,-367,62,230,-213,30,194,-144,159,168,-143,171,155,-147,146,230,-192,-152,265,-319,-84,244,-177,-158,222,-171,-187,140,-379,217,222,-428,-81,217,-428,-94,73,-618,198,192,-502,-42,45,-611,206,50,-615,218,180,-357,58,160,-491,-48,55,-607,173,80,-616,179,108,-576,138,82,-567,130,119,-596,77,92,-586,68,147,-550,42,120,-539,30,160,-550,0,130,-539,-8,48,-729,92,87,-679,20,122,-625,-27,153,-570,-62,24,-700,206,17,-753,164,140,17,28,188,-164,21,72,-257,-763,-77,-256,-759,40,69,900,46,76,844,44,83,875,45,50,864,43,65,869,41,71,882,38,78,860,47,94,855,33,75,870,-33,51,864,-27,70,900,-34,76,845,-36,95,856,-21,75,871,-29,72,883,-31,66,869,-27,79,860,-32,84,875], + &[0,121,80,0,73,189,0,-58,-186,0,109,-84,-109,-28,-66,1,-33,327,-25,-2,426,-95,-61,53,5,22,914,-64,-97,27,2,35,543,0,-80,-123,-70,-48,-148,-112,96,65,-27,-27,290,0,-113,28,-23,113,826,2,-16,552,5,124,823,6,30,1003,3,69,711,-76,52,-195,-82,-94,-134,6,6,952,6,117,898,0,48,232,-129,4,-100,-20,32,719,-55,0,196,-18,3,973,0,79,-180,5,-69,979,-18,25,424,0,127,-16,4,38,818,-93,79,133,-66,-31,-157,1,32,418,0,-3,-266,-24,63,910,-32,24,285,-31,-15,-259,-26,60,830,-57,35,195,-24,-1,553,-64,-94,-151,1,-23,425,-20,97,907,-40,79,-160,-36,9,303,-25,55,713,-137,-12,-51,6,68,973,4,89,762,-115,37,86,-30,-4,354,-28,-54,-182,1,-23,361,-24,20,550,-63,103,-98,-30,-45,-253,-123,83,95,5,15,881,-69,-62,-152,-40,-45,-291,0,-44,-284,-85,118,-24,-16,33,985,0,38,273,-65,-59,-347,0,-54,246,0,-29,-364,-56,-80,-160,-89,-75,-138,-80,-142,-350,-69,-141,-351,-63,-131,-353,-74,-125,-355,-85,-131,-353,-91,-249,-692,-63,-249,-692,-95,-212,-699,-58,-213,-702,-57,-147,-410,-74,-126,-415,-65,-160,-466,-75,-153,-468,-100,-146,-410,-86,-168,-464,-92,-169,-404,-81,-174,-462,-66,-168,-404,-70,-174,-462,-67,-225,-678,-75,-220,-680,-83,-226,-678,-81,-234,-676,-71,-234,-676,-28,56,192,-38,-41,-293,-261,-351,219,-276,-250,-37,-178,-34,-4,-305,-243,-95,-235,-349,231,-117,19,109,-285,-319,80,-265,-166,23,-234,-108,158,-210,-112,174,-196,-118,150,-238,-147,-156,-309,-252,-66,-248,-130,-163,-223,-129,-190,-241,-353,242,-278,-365,-68,-271,-365,-80,-196,-596,208,-263,-445,-33,-170,-593,221,-177,-597,232,-253,-312,82,-229,-437,-34,-174,-584,187,-200,-591,188,-217,-545,148,-189,-538,146,-220,-558,85,-191,-550,81,-237,-506,51,-207,-497,44,-243,-500,8,-211,-492,5,-166,-699,96,-188,-638,24,-209,-576,-21,-228,-515,-54,-159,-683,214,-149,-732,169,-141,27,31,-215,-126,22,119,-21,-68,28,-2,426,95,-36,76,64,-97,27,70,-48,-148,114,98,65,28,-27,290,34,113,826,78,53,-195,79,-94,-134,129,4,-100,28,32,718,55,0,196,30,3,973,22,25,424,93,79,133,66,-31,-157,36,63,909,34,24,285,31,-15,-259,37,60,830,57,35,195,29,-1,553,62,-94,-151,33,97,907,40,79,-160,37,9,303,33,55,713,137,-12,-51,115,37,86,33,-4,353,30,-52,-182,29,20,550,63,103,-98,30,-45,-253,125,84,95,67,-62,-152,40,-45,-291,85,118,-24,28,33,985,65,-59,-347,53,-80,-160,87,-75,-138,78,-142,-350,67,-141,-351,61,-131,-353,72,-125,-355,83,-131,-353,84,-247,-692,60,-247,-692,88,-214,-699,56,-215,-701,55,-147,-410,71,-126,-415,61,-159,-466,71,-153,-468,97,-146,-410,82,-168,-464,89,-169,-404,77,-174,-462,63,-168,-404,66,-174,-462,64,-225,-678,73,-220,-680,80,-226,-678,78,-234,-676,68,-233,-676,28,56,192,38,-41,-293,255,-343,214,276,-244,-42,188,-27,-5,307,-239,-100,228,-339,226,122,23,109,281,-313,76,273,-161,22,243,-101,157,219,-104,172,204,-110,149,248,-140,-158,310,-248,-71,258,-123,-164,233,-122,-191,235,-344,237,275,-360,-72,268,-359,-85,181,-585,205,256,-439,-37,154,-581,217,161,-586,228,250,-305,77,222,-430,-38,159,-573,183,184,-580,185,203,-535,144,177,-527,142,207,-549,81,179,-540,77,227,-498,47,197,-488,40,234,-493,4,202,-484,1,147,-687,93,173,-629,21,196,-568,-25,219,-508,-58,139,-671,211,129,-720,166,143,28,30,224,-120,20,72,-238,-765,-77,-237,-762,40,78,899,46,85,843,44,92,874,45,59,863,43,74,868,41,80,881,38,87,859,47,103,854,33,84,869,-33,60,863,-27,79,899,-34,85,843,-35,104,855,-21,84,870,-29,81,882,-31,75,868,-27,88,859,-32,93,874], + &[0,121,82,0,72,190,0,-55,-187,0,111,-82,-114,-4,-54,1,-37,326,-25,-9,426,-95,-61,53,5,21,912,-64,-97,25,2,24,543,0,-78,-124,-70,-45,-149,-112,101,69,-27,-30,289,0,-112,26,-23,112,824,2,-27,552,6,123,821,6,30,1002,3,65,709,-72,57,-192,-82,-92,-135,6,6,951,6,116,895,0,47,232,-129,6,-100,-20,28,717,-55,-1,196,-18,3,971,0,82,-179,5,-69,978,-18,18,425,0,128,-15,5,38,816,-93,78,134,-66,-29,-157,1,25,419,0,0,-266,-24,62,908,-32,22,285,-31,-11,-259,-26,60,828,-57,34,195,-25,-13,553,-64,-91,-152,1,-31,423,-20,96,905,-40,81,-159,-36,6,303,-25,51,711,-137,-10,-52,6,68,971,4,87,759,-115,37,86,-30,-9,353,-28,-54,-178,1,-28,360,-24,8,550,-63,105,-97,-30,-41,-254,-126,87,99,5,15,880,-69,-59,-153,-40,-40,-292,0,-39,-285,-85,119,-23,-16,33,983,0,36,274,-65,-51,-348,0,-56,245,0,-22,-365,-56,-77,-161,-89,-73,-139,-80,-135,-353,-69,-134,-353,-63,-124,-356,-74,-117,-357,-85,-124,-355,-91,-234,-697,-63,-235,-696,-95,-197,-703,-58,-199,-705,-57,-138,-412,-74,-118,-417,-65,-150,-469,-75,-144,-471,-100,-137,-412,-86,-158,-467,-92,-160,-407,-81,-165,-465,-66,-160,-407,-70,-164,-465,-67,-211,-682,-75,-206,-684,-83,-212,-682,-81,-220,-680,-71,-219,-680,-28,55,193,-38,-36,-294,-404,-258,225,-349,-148,-22,-189,14,-1,-365,-131,-83,-380,-263,241,-130,29,116,-395,-215,87,-318,-80,9,-290,-35,150,-272,-46,168,-257,-57,147,-263,-70,-164,-376,-139,-56,-266,-52,-171,-239,-60,-194,-390,-266,250,-375,-257,-62,-366,-258,-73,-403,-510,205,-387,-339,-31,-380,-515,222,-389,-518,231,-363,-217,94,-353,-340,-26,-376,-504,189,-402,-504,186,-399,-453,147,-371,-454,149,-395,-463,83,-365,-463,84,-393,-407,51,-361,-406,49,-390,-399,8,-357,-400,11,-382,-613,91,-375,-547,22,-371,-480,-21,-369,-415,-52,-391,-604,210,-387,-653,163,-146,32,33,-259,-58,17,119,0,-54,28,-9,425,95,-36,75,64,-97,25,70,-45,-149,113,102,69,28,-30,289,34,112,824,72,58,-192,79,-92,-135,129,6,-100,28,28,717,55,-1,196,30,3,971,22,18,424,93,78,134,66,-29,-157,36,62,908,34,22,285,31,-11,-259,37,60,828,57,34,195,29,-13,553,62,-91,-152,33,96,905,40,81,-159,37,6,303,33,51,711,137,-10,-52,115,37,86,33,-9,353,29,-54,-178,29,8,550,63,105,-97,30,-41,-254,127,89,99,67,-59,-153,40,-40,-292,85,119,-23,28,33,983,65,-51,-348,53,-77,-161,87,-73,-139,78,-135,-353,67,-134,-353,61,-124,-356,72,-117,-357,83,-124,-355,84,-232,-697,60,-232,-697,88,-199,-702,56,-201,-705,55,-138,-412,71,-118,-417,61,-150,-469,71,-144,-471,97,-137,-412,82,-158,-467,89,-160,-407,77,-165,-465,63,-160,-407,66,-164,-465,64,-211,-682,73,-206,-684,80,-212,-682,78,-220,-680,68,-219,-680,28,55,193,38,-36,-294,406,-252,220,350,-144,-26,194,19,-1,366,-126,-88,383,-257,236,133,32,116,397,-210,82,323,-76,9,294,-31,150,276,-43,168,261,-54,147,268,-65,-164,376,-134,-61,271,-47,-172,244,-55,-195,392,-260,246,379,-251,-66,369,-253,-77,411,-504,201,392,-334,-36,387,-509,217,397,-512,226,365,-212,89,358,-336,-30,383,-499,184,410,-498,181,406,-448,142,378,-449,145,402,-458,79,372,-458,79,399,-402,46,367,-401,45,396,-394,3,363,-395,6,392,-608,87,384,-542,17,379,-475,-26,375,-410,-56,400,-599,206,398,-647,159,147,33,33,263,-55,16,72,-221,-769,-77,-221,-766,40,78,897,46,84,841,44,92,872,45,59,861,43,74,866,41,80,879,38,87,856,48,103,852,33,83,867,-33,59,861,-27,78,897,-34,85,841,-35,103,852,-21,84,868,-29,80,880,-31,74,866,-27,87,857,-32,92,872], + &[0,112,83,0,63,191,0,-60,-188,0,105,-81,-122,19,-41,1,-49,324,-25,-24,425,-95,-68,52,6,12,909,-64,-104,24,2,3,542,0,-83,-125,-70,-50,-150,-111,99,73,-27,-40,288,0,-120,25,-23,103,821,2,-47,552,6,114,818,6,21,999,3,53,705,-69,54,-188,-82,-98,-136,6,-3,948,6,107,893,0,37,233,-129,0,-100,-20,16,716,-55,-10,196,-17,-5,969,0,77,-178,5,-79,975,-18,3,425,0,121,-13,5,29,814,-93,69,135,-66,-34,-158,1,10,420,0,-3,-266,-24,53,905,-32,11,286,-31,-14,-259,-26,51,825,-57,24,195,-25,-33,553,-64,-96,-154,1,-46,422,-20,87,903,-40,76,-158,-36,-4,303,-25,39,708,-137,-17,-52,6,59,969,4,76,755,-115,29,86,-30,-22,353,-33,-62,-175,1,-41,358,-24,-11,549,-63,99,-95,-30,-45,-255,-127,86,102,5,5,877,-69,-64,-153,-40,-42,-293,0,-42,-286,-85,112,-21,-16,24,981,0,26,275,-65,-51,-350,0,-66,244,0,-21,-365,-56,-82,-162,-89,-78,-140,-80,-135,-355,-69,-134,-355,-63,-124,-358,-74,-117,-359,-85,-124,-358,-91,-223,-702,-63,-223,-701,-95,-186,-708,-58,-188,-710,-57,-137,-415,-74,-116,-419,-65,-147,-472,-75,-140,-473,-100,-136,-415,-86,-155,-470,-92,-159,-410,-81,-161,-469,-66,-158,-410,-70,-161,-469,-67,-200,-687,-75,-195,-688,-83,-201,-687,-81,-209,-685,-71,-208,-685,-28,45,193,-38,-38,-294,-536,-78,210,-405,-7,-20,-188,66,4,-402,18,-81,-520,-95,228,-144,37,122,-491,-43,78,-346,35,-4,-320,60,141,-311,41,161,-299,25,140,-270,22,-170,-419,15,-56,-265,40,-176,-241,22,-197,-531,-93,236,-476,-85,-71,-467,-90,-82,-659,-296,170,-531,-151,-49,-643,-312,188,-654,-310,197,-465,-61,88,-503,-169,-40,-630,-305,157,-652,-291,151,-620,-248,117,-597,-262,122,-613,-257,54,-588,-272,57,-580,-209,27,-552,-224,28,-568,-202,-14,-540,-219,-8,-678,-394,51,-631,-338,-11,-589,-281,-49,-550,-226,-74,-696,-384,169,-711,-426,118,-151,32,36,-284,27,11,123,20,-40,28,-25,425,95,-44,75,64,-104,24,70,-50,-150,111,99,73,28,-40,288,34,102,820,69,55,-188,79,-98,-136,129,0,-100,28,16,715,55,-10,196,30,-5,968,22,3,425,93,69,135,66,-34,-158,36,53,905,34,11,286,31,-14,-259,37,50,825,57,24,195,29,-33,552,62,-96,-154,33,86,902,40,76,-158,37,-4,303,33,38,708,137,-17,-52,115,29,86,33,-22,352,33,-62,-174,29,-11,549,63,99,-95,30,-45,-255,127,86,102,67,-64,-153,40,-42,-293,85,112,-21,29,23,980,65,-51,-350,53,-82,-162,87,-78,-140,78,-135,-355,67,-134,-355,61,-124,-358,72,-117,-359,83,-124,-358,84,-221,-702,60,-221,-702,88,-188,-707,56,-190,-710,55,-137,-415,71,-116,-419,61,-146,-472,71,-140,-473,97,-136,-415,82,-155,-470,89,-159,-410,77,-161,-469,63,-158,-410,66,-161,-469,64,-200,-687,73,-195,-688,80,-201,-687,78,-209,-685,68,-208,-685,28,45,193,38,-38,-294,550,-58,200,406,1,-26,189,67,5,399,28,-86,536,-76,218,144,38,123,497,-25,69,348,39,-4,321,59,142,314,39,162,304,22,141,270,22,-168,416,27,-61,265,41,-175,241,22,-196,547,-73,226,485,-65,-80,477,-71,-90,697,-258,153,548,-125,-60,683,-276,171,694,-273,179,475,-46,79,522,-147,-52,669,-270,140,689,-253,134,652,-214,102,630,-231,107,645,-222,38,621,-240,42,605,-178,13,579,-197,14,591,-172,-28,566,-192,-22,725,-350,31,670,-299,-29,621,-247,-65,576,-196,-87,744,-341,149,763,-380,97,151,32,36,287,24,12,72,-210,-774,-77,-210,-771,40,68,894,46,75,838,44,82,869,45,49,858,43,64,863,41,70,877,38,77,854,48,93,849,33,74,865,-33,50,858,-27,69,895,-34,75,838,-35,94,849,-21,74,865,-29,71,877,-31,65,864,-26,78,854,-32,83,869], + &[0,99,84,0,48,192,0,-70,-189,0,94,-80,-128,42,-30,1,-65,323,-25,-44,424,-95,-81,51,6,-3,907,-64,-116,23,2,-19,542,0,-94,-126,-70,-61,-150,-110,91,77,-27,-56,288,0,-132,23,-23,87,818,2,-71,551,6,98,815,6,5,996,3,34,702,-68,46,-184,-82,-108,-138,6,-19,946,6,91,890,0,22,234,-129,-9,-100,-20,-1,714,-55,-25,196,-17,-21,966,0,67,-177,5,-95,973,-18,-16,425,0,109,-12,5,13,811,-93,56,136,-66,-44,-158,1,-8,420,0,-11,-266,-24,37,903,-32,-3,286,-31,-23,-259,-26,35,823,-57,10,196,-25,-56,552,-64,-106,-155,1,-66,421,-20,71,900,-40,66,-157,-36,-20,303,-25,20,706,-137,-28,-52,6,43,966,4,59,751,-115,15,87,-30,-39,352,-41,-72,-173,1,-58,357,-24,-34,549,-63,88,-94,-30,-54,-256,-127,79,106,5,-10,875,-69,-74,-154,-40,-49,-294,0,-50,-286,-85,100,-20,-16,7,978,0,11,276,-65,-57,-351,0,-81,243,0,-26,-365,-56,-92,-163,-89,-88,-141,-80,-140,-357,-69,-140,-357,-63,-129,-360,-74,-123,-361,-85,-130,-359,-91,-216,-706,-63,-216,-706,-95,-179,-713,-58,-180,-715,-57,-141,-417,-74,-120,-421,-65,-148,-474,-75,-142,-476,-100,-140,-417,-86,-157,-473,-92,-164,-413,-81,-163,-472,-66,-163,-413,-70,-163,-472,-67,-193,-692,-75,-187,-693,-83,-194,-692,-81,-201,-690,-71,-201,-690,-28,31,194,-38,-46,-295,-557,166,192,-408,152,-38,-172,112,14,-386,177,-96,-557,142,207,-153,45,127,-497,175,61,-325,157,-8,-306,158,141,-312,136,159,-308,116,139,-248,112,-167,-401,183,-70,-236,127,-173,-220,101,-193,-564,150,216,-512,152,-92,-509,144,-103,-795,100,140,-598,140,-72,-795,75,155,-802,83,164,-491,144,68,-590,107,-67,-780,75,123,-786,101,121,-733,113,89,-726,86,91,-733,109,25,-725,81,25,-675,124,0,-665,93,-1,-661,125,-40,-653,93,-38,-874,56,12,-800,71,-46,-730,87,-82,-663,103,-103,-882,62,132,-922,48,79,-154,29,38,-280,116,11,127,37,-27,28,-44,424,95,-57,74,64,-116,23,70,-61,-150,109,90,77,28,-56,288,34,86,818,67,45,-184,79,-108,-138,129,-9,-100,28,-1,714,55,-25,196,30,-22,966,22,-16,425,93,56,136,66,-44,-158,36,36,902,34,-3,286,31,-23,-259,37,35,822,57,10,196,29,-56,552,62,-106,-155,33,70,900,40,66,-157,37,-20,303,33,20,706,137,-28,-52,115,15,87,33,-39,352,41,-73,-173,28,-34,549,63,88,-94,30,-54,-256,127,78,106,67,-74,-154,40,-49,-294,85,100,-20,29,7,978,65,-57,-351,53,-92,-163,87,-88,-141,78,-140,-357,67,-140,-357,61,-129,-360,72,-123,-361,83,-130,-359,84,-214,-707,60,-214,-707,88,-181,-712,56,-182,-715,55,-141,-417,71,-120,-421,61,-148,-474,71,-142,-476,97,-140,-417,82,-157,-473,89,-164,-413,77,-163,-472,63,-163,-413,66,-163,-472,64,-193,-692,73,-187,-693,80,-194,-692,78,-202,-690,69,-201,-690,28,31,194,38,-46,-295,546,202,191,400,168,-38,171,106,16,373,191,-96,552,177,205,152,42,129,484,204,61,321,157,-5,304,150,144,312,128,162,311,109,140,248,106,-165,386,199,-69,234,121,-170,219,95,-190,557,186,215,501,192,-93,500,183,-104,792,186,135,588,196,-74,797,161,149,802,170,158,484,172,66,587,162,-71,782,160,118,783,187,116,728,189,85,726,161,86,728,189,21,725,159,20,667,192,-2,664,160,-5,653,192,-43,651,159,-42,876,165,6,800,167,-52,727,170,-86,659,174,-107,885,167,125,926,163,71,153,28,38,283,108,13,72,-204,-779,-77,-204,-776,40,52,892,46,59,835,44,66,866,45,33,856,43,48,861,41,54,874,39,61,851,48,77,846,33,58,862,-33,34,856,-27,53,892,-34,59,836,-35,78,847,-21,58,862,-29,55,874,-31,49,861,-26,62,851,-32,66,867], + &[0,84,85,0,32,192,0,-83,-189,0,80,-79,-132,61,-21,1,-83,322,-25,-63,424,-95,-96,50,6,-24,906,-64,-131,22,2,-40,541,0,-107,-127,-70,-74,-151,-108,79,80,-27,-73,287,0,-147,22,-23,66,818,2,-92,550,6,77,815,6,-15,996,3,14,701,-69,33,-182,-82,-122,-139,6,-40,945,6,70,890,0,5,234,-129,-23,-100,-20,-21,713,-55,-41,196,-17,-42,965,0,54,-177,5,-116,972,-18,-35,425,0,95,-11,5,-6,810,-93,40,136,-66,-57,-158,1,-28,420,0,-24,-265,-24,16,902,-32,-21,286,-31,-36,-259,-26,15,822,-57,-6,196,-25,-78,551,-64,-119,-156,1,-85,420,-20,50,900,-40,53,-156,-36,-37,303,-25,0,705,-137,-42,-52,6,22,965,4,39,751,-115,0,87,-30,-58,352,-51,-82,-173,1,-77,357,-24,-55,548,-63,74,-93,-30,-66,-256,-126,69,109,5,-31,874,-69,-88,-154,-40,-61,-295,0,-62,-287,-85,86,-19,-15,-13,977,0,-6,276,-65,-66,-352,0,-98,242,0,-35,-365,-56,-105,-164,-89,-102,-142,-80,-150,-359,-69,-149,-359,-63,-139,-361,-74,-132,-362,-85,-139,-361,-91,-213,-709,-63,-213,-709,-95,-176,-717,-58,-178,-719,-57,-149,-419,-74,-129,-422,-65,-154,-476,-75,-148,-477,-100,-148,-419,-86,-163,-475,-92,-172,-415,-81,-169,-474,-66,-171,-415,-70,-169,-474,-67,-190,-695,-75,-184,-696,-83,-191,-696,-81,-198,-694,-71,-198,-694,-28,14,194,-38,-57,-296,-441,358,177,-347,293,-72,-147,141,25,-313,309,-129,-460,338,188,-155,51,132,-392,350,42,-263,248,0,-258,228,150,-276,211,166,-281,194,144,-209,178,-159,-318,318,-100,-190,187,-163,-185,157,-183,-458,346,199,-416,381,-109,-421,376,-121,-651,496,152,-484,430,-78,-670,476,163,-669,484,174,-411,324,42,-504,402,-80,-659,473,130,-644,495,133,-598,472,95,-613,449,92,-600,484,32,-616,459,27,-550,458,2,-565,431,-6,-539,458,-40,-557,430,-44,-735,553,34,-673,523,-33,-613,491,-75,-555,459,-104,-738,535,152,-775,566,104,-155,23,40,-250,187,18,131,50,-18,28,-63,424,95,-73,74,64,-131,22,70,-74,-151,108,77,81,28,-73,287,34,66,817,69,31,-181,79,-122,-139,129,-23,-100,28,-21,713,55,-41,196,30,-42,965,22,-35,425,93,40,136,66,-57,-158,36,16,902,34,-21,286,31,-36,-259,37,15,822,57,-6,196,29,-78,551,62,-119,-156,33,50,899,40,53,-156,37,-37,303,33,0,705,137,-42,-52,115,0,87,33,-58,352,51,-84,-172,28,-56,548,63,74,-93,30,-66,-256,126,66,109,67,-88,-154,40,-61,-295,85,86,-19,29,-13,977,65,-66,-352,53,-105,-164,87,-102,-142,78,-150,-359,67,-149,-359,61,-139,-361,72,-132,-362,83,-139,-361,84,-211,-710,60,-211,-710,88,-178,-716,56,-180,-719,55,-149,-419,71,-129,-422,61,-154,-476,71,-148,-477,97,-149,-418,82,-163,-475,89,-172,-415,77,-169,-474,63,-171,-415,66,-169,-474,64,-190,-695,73,-184,-696,80,-191,-696,78,-198,-694,69,-198,-694,28,14,194,38,-57,-296,405,375,188,325,305,-65,146,129,28,288,317,-121,427,359,197,155,45,133,357,365,52,256,240,5,255,214,154,275,198,169,283,182,146,210,167,-156,291,325,-92,190,175,-160,184,146,-180,424,366,209,374,408,-96,379,405,-109,581,555,172,430,469,-63,603,540,181,600,546,193,381,343,51,455,445,-66,593,536,148,574,554,152,533,524,113,553,505,109,532,540,51,553,519,44,489,505,19,509,483,9,477,505,-23,501,482,-29,650,635,57,595,597,-11,542,556,-56,493,514,-87,657,612,174,686,653,128,154,20,40,253,176,20,72,-203,-782,-77,-202,-779,40,32,891,46,39,835,44,46,866,45,13,855,43,28,860,41,34,873,39,41,850,48,57,846,33,37,861,-33,14,855,-27,32,892,-34,39,835,-35,57,846,-21,38,862,-29,34,874,-31,28,860,-26,41,851,-32,46,866], + &[0,68,86,0,16,192,0,-97,-189,0,65,-78,-132,71,-18,1,-99,323,-25,-79,424,-95,-112,50,6,-45,907,-64,-146,21,2,-56,541,0,-122,-127,-70,-89,-151,-107,66,81,-27,-89,287,0,-162,22,-23,46,820,2,-107,550,6,57,817,6,-37,997,3,-4,703,-71,20,-181,-82,-136,-139,6,-61,946,6,49,892,0,-10,234,-129,-38,-100,-20,-40,714,-55,-57,196,-17,-64,966,0,39,-176,5,-138,972,-18,-51,425,0,80,-10,5,-27,812,-93,24,137,-66,-72,-158,1,-44,420,0,-38,-265,-24,-4,904,-32,-37,286,-31,-50,-259,-26,-5,823,-57,-22,196,-25,-93,551,-64,-134,-157,1,-101,420,-20,29,901,-40,38,-156,-36,-53,303,-25,-18,707,-137,-57,-52,6,0,967,4,20,753,-115,-14,87,-30,-74,352,-58,-92,-173,1,-93,357,-24,-71,549,-63,60,-93,-30,-80,-256,-125,57,110,5,-52,875,-69,-102,-155,-40,-74,-295,0,-76,-287,-85,71,-19,-16,-34,978,0,-22,276,-65,-79,-352,0,-114,242,0,-48,-365,-56,-119,-164,-89,-116,-142,-80,-162,-360,-69,-161,-360,-63,-151,-362,-74,-144,-363,-85,-151,-362,-91,-215,-711,-63,-215,-711,-95,-178,-720,-58,-180,-722,-57,-161,-419,-74,-140,-422,-65,-164,-477,-75,-157,-478,-100,-160,-419,-86,-172,-476,-92,-183,-416,-81,-179,-476,-66,-183,-416,-70,-178,-476,-67,-191,-697,-75,-185,-698,-83,-192,-698,-81,-200,-696,-71,-200,-696,-28,-1,194,-38,-71,-296,-297,440,151,-252,376,-112,-124,150,29,-213,380,-168,-324,435,159,-154,52,133,-257,429,12,-195,289,7,-205,261,155,-230,252,170,-241,240,147,-169,208,-155,-214,384,-138,-147,210,-158,-150,181,-179,-319,438,171,-249,495,-128,-255,497,-141,-373,681,167,-273,569,-84,-400,675,175,-395,679,188,-288,421,10,-306,560,-89,-392,672,142,-367,679,147,-344,640,103,-370,632,96,-334,662,43,-362,654,34,-311,616,4,-339,607,-6,-300,617,-37,-331,608,-45,-396,798,67,-364,749,-8,-335,695,-61,-309,640,-99,-416,765,180,-422,820,142,-154,14,40,-211,227,21,133,55,-15,28,-79,424,95,-88,74,64,-146,21,70,-89,-151,107,63,82,28,-89,287,34,46,819,71,17,-181,79,-136,-139,129,-38,-100,28,-40,714,55,-57,196,30,-64,966,22,-51,425,93,24,137,66,-72,-158,36,-4,903,34,-37,286,31,-50,-259,37,-5,823,57,-22,196,29,-93,551,62,-134,-157,33,29,901,40,38,-156,37,-53,303,33,-18,706,137,-57,-52,115,-14,87,33,-74,352,58,-94,-173,28,-71,548,63,60,-93,30,-80,-256,125,54,110,67,-102,-155,40,-74,-295,85,71,-19,29,-35,978,65,-79,-352,53,-119,-164,87,-116,-142,78,-162,-360,67,-161,-360,61,-151,-362,72,-144,-363,83,-151,-362,84,-213,-711,60,-213,-711,88,-180,-719,56,-182,-721,55,-161,-419,71,-140,-422,61,-164,-477,71,-157,-478,97,-160,-419,82,-172,-476,89,-184,-416,77,-179,-476,63,-183,-416,66,-178,-476,64,-191,-697,73,-185,-698,80,-192,-698,78,-200,-696,69,-200,-696,28,-1,194,38,-71,-296,271,431,160,233,371,-104,125,134,32,194,371,-160,299,429,169,154,44,135,232,419,22,191,273,12,205,244,159,230,235,173,242,225,150,171,193,-152,194,375,-130,148,195,-155,151,165,-176,293,431,181,216,489,-116,221,491,-129,317,678,184,230,563,-70,344,676,193,339,678,205,264,415,19,264,559,-75,337,673,159,311,677,164,292,636,119,319,632,113,280,659,60,309,655,51,262,612,20,291,607,8,251,613,-22,283,608,-30,325,801,88,298,751,11,276,696,-42,257,639,-82,349,767,201,349,823,164,154,11,41,214,213,23,72,-207,-784,-77,-206,-781,40,10,893,46,18,836,44,25,867,45,-7,856,43,7,862,41,13,875,39,20,852,48,36,848,33,16,863,-33,-6,857,-27,11,893,-34,18,837,-35,37,848,-21,17,863,-29,13,875,-31,7,862,-26,20,852,-32,25,868], + &[0,56,86,0,3,192,0,-111,-189,0,51,-79,-131,68,-25,1,-111,323,-25,-89,424,-95,-125,50,6,-62,909,-64,-159,22,2,-63,542,0,-135,-127,-70,-102,-151,-107,54,80,-27,-102,287,0,-175,22,-23,30,823,2,-115,550,6,41,820,6,-54,999,3,-17,706,-72,6,-182,-82,-150,-139,6,-78,948,6,33,895,0,-22,234,-129,-51,-100,-20,-54,716,-55,-70,196,-17,-81,968,0,26,-177,5,-155,973,-18,-61,425,0,67,-11,5,-43,814,-93,12,136,-66,-85,-158,1,-53,420,0,-51,-265,-24,-20,906,-32,-49,286,-31,-63,-259,-26,-21,826,-57,-34,196,-25,-101,552,-64,-147,-156,1,-110,421,-20,13,904,-40,25,-156,-36,-65,303,-25,-31,709,-137,-70,-52,6,-16,969,4,5,756,-115,-27,87,-30,-85,352,-61,-103,-174,1,-104,357,-24,-78,549,-63,46,-93,-30,-94,-256,-124,46,108,5,-68,877,-69,-116,-154,-40,-89,-295,0,-90,-287,-85,58,-19,-16,-51,981,0,-34,275,-65,-94,-352,0,-126,243,0,-62,-365,-56,-132,-164,-89,-130,-142,-80,-175,-360,-69,-174,-360,-63,-164,-362,-74,-157,-363,-85,-164,-361,-91,-221,-711,-63,-222,-710,-95,-185,-721,-58,-187,-723,-57,-173,-419,-74,-152,-422,-65,-175,-477,-75,-169,-478,-100,-172,-419,-86,-183,-477,-92,-196,-416,-81,-190,-476,-66,-195,-417,-70,-190,-476,-67,-197,-698,-75,-192,-698,-83,-198,-698,-81,-206,-697,-71,-206,-697,-28,-13,194,-38,-85,-296,-218,452,122,-191,397,-145,-112,145,23,-153,391,-201,-245,456,131,-152,47,129,-181,438,-15,-158,292,2,-177,264,149,-203,260,163,-217,251,139,-146,210,-162,-152,393,-170,-124,208,-164,-131,180,-185,-239,456,143,-146,509,-151,-151,513,-163,-203,702,159,-143,582,-101,-231,706,167,-225,706,180,-213,442,-19,-177,586,-107,-224,702,133,-198,700,139,-189,658,91,-216,661,85,-171,680,34,-199,683,25,-164,632,-8,-193,635,-20,-152,633,-50,-184,636,-58,-181,827,69,-166,776,-10,-156,720,-67,-151,662,-109,-214,794,180,-199,851,146,-153,5,39,-189,236,13,134,51,-22,28,-89,424,95,-101,74,64,-159,22,70,-102,-151,107,51,80,28,-102,287,34,30,822,72,4,-182,79,-150,-139,129,-51,-100,28,-54,715,55,-70,196,30,-81,968,22,-61,425,93,12,136,66,-85,-158,36,-21,906,34,-49,286,31,-63,-259,37,-21,826,57,-34,196,29,-101,552,62,-147,-156,33,12,904,40,25,-156,37,-65,303,33,-31,709,137,-70,-52,115,-27,87,33,-85,352,61,-106,-174,29,-78,549,63,46,-93,30,-94,-256,124,42,109,67,-116,-154,40,-89,-295,85,58,-19,29,-52,980,65,-94,-352,53,-132,-164,87,-130,-142,78,-175,-360,67,-174,-360,61,-164,-362,72,-157,-363,83,-164,-361,84,-219,-711,60,-219,-711,88,-187,-720,56,-189,-722,55,-173,-419,71,-152,-422,61,-175,-477,71,-169,-478,97,-173,-419,82,-184,-476,89,-196,-416,77,-190,-476,63,-195,-417,66,-190,-476,64,-197,-698,73,-192,-698,80,-199,-698,78,-206,-697,69,-206,-697,28,-13,194,38,-85,-296,221,430,131,195,381,-137,114,128,26,157,377,-194,249,433,140,154,38,131,185,419,-7,161,274,6,179,245,152,204,239,167,218,231,143,149,194,-159,156,379,-163,126,191,-161,133,162,-182,243,433,152,154,494,-141,159,498,-154,214,679,173,153,566,-90,242,682,181,236,682,194,217,422,-10,186,569,-95,235,679,147,209,677,153,199,637,104,226,639,98,182,661,47,211,663,38,174,614,3,204,616,-8,163,616,-38,195,618,-46,197,806,85,180,758,4,170,703,-53,163,647,-97,227,770,195,215,828,162,154,1,39,190,217,16,72,-216,-784,-77,-215,-781,40,-5,895,46,2,839,44,9,870,45,-23,859,43,-8,864,41,-2,878,39,4,855,48,20,851,33,0,866,-33,-22,859,-27,-4,896,-34,2,840,-35,21,851,-21,1,866,-29,-2,878,-31,-8,865,-26,4,855,-32,9,870], + &[0,48,85,0,-2,192,0,-121,-189,0,42,-80,-133,49,-37,1,-116,324,-25,-91,425,-95,-133,51,6,-70,911,-64,-168,23,2,-61,543,0,-145,-126,-70,-112,-150,-107,45,76,-27,-108,288,0,-184,23,-23,22,826,2,-113,551,6,33,823,6,-63,1001,3,-22,709,-71,-3,-185,-82,-159,-138,6,-87,950,6,24,897,0,-29,233,-129,-61,-100,-20,-59,717,-55,-76,196,-18,-90,970,0,16,-177,5,-164,975,-18,-63,425,0,58,-12,5,-51,816,-93,4,136,-66,-95,-158,1,-56,419,0,-62,-266,-24,-29,909,-32,-55,286,-31,-74,-259,-26,-30,829,-57,-41,196,-25,-99,552,-64,-157,-156,1,-113,422,-20,4,907,-40,15,-157,-36,-71,303,-25,-36,712,-137,-79,-52,6,-25,972,4,-1,760,-115,-35,87,-30,-89,352,-59,-115,-176,1,-108,358,-24,-77,550,-63,37,-94,-30,-104,-256,-124,36,105,5,-76,879,-69,-125,-154,-40,-100,-294,0,-101,-286,-85,49,-20,-16,-60,983,0,-41,275,-65,-107,-351,0,-133,243,0,-76,-365,-56,-142,-163,-89,-139,-141,-80,-185,-359,-69,-185,-359,-63,-175,-361,-74,-168,-362,-85,-175,-361,-91,-231,-709,-63,-231,-709,-95,-195,-720,-58,-197,-723,-57,-184,-418,-74,-163,-421,-65,-186,-476,-75,-179,-477,-100,-184,-418,-86,-194,-476,-92,-207,-416,-81,-201,-475,-66,-206,-416,-70,-200,-475,-67,-207,-697,-75,-201,-697,-83,-208,-697,-81,-215,-696,-71,-215,-696,-28,-20,194,-38,-96,-295,-259,412,119,-236,377,-152,-121,128,11,-199,379,-210,-286,412,128,-153,31,123,-225,411,-21,-184,269,-6,-196,236,139,-221,228,154,-234,219,130,-166,191,-172,-197,379,-179,-143,191,-175,-147,162,-197,-280,412,140,-205,493,-152,-211,498,-165,-273,659,170,-209,563,-98,-301,659,180,-295,659,192,-258,411,-23,-243,563,-103,-295,659,146,-269,659,150,-256,622,100,-284,622,94,-243,649,43,-272,649,35,-232,605,-1,-262,605,-13,-222,609,-44,-255,609,-51,-270,791,88,-251,747,5,-237,696,-55,-226,643,-101,-294,748,197,-288,808,167,-154,-6,36,-207,209,3,134,33,-34,28,-91,425,95,-109,74,64,-168,23,70,-112,-150,107,41,77,28,-108,288,34,21,825,72,-5,-184,79,-159,-138,129,-61,-100,28,-59,717,55,-76,196,30,-90,970,22,-63,425,93,4,136,66,-95,-158,36,-29,908,34,-55,286,31,-74,-259,37,-30,828,57,-41,196,29,-99,552,62,-157,-156,33,4,906,40,15,-157,37,-71,303,33,-36,711,137,-79,-52,115,-35,87,33,-89,352,59,-117,-175,29,-77,549,63,37,-94,30,-104,-256,124,33,106,67,-125,-154,40,-100,-294,85,49,-20,28,-61,983,65,-107,-351,53,-142,-163,87,-140,-141,78,-185,-359,67,-185,-359,61,-174,-361,72,-168,-362,83,-175,-361,84,-229,-710,60,-229,-710,88,-197,-720,56,-199,-722,55,-184,-418,71,-163,-421,61,-186,-476,71,-179,-477,97,-184,-418,82,-194,-476,89,-207,-416,77,-201,-475,63,-206,-416,66,-200,-475,64,-207,-697,73,-201,-697,80,-208,-697,78,-215,-696,69,-215,-696,28,-20,194,38,-96,-295,279,383,126,256,354,-145,123,112,14,220,362,-203,306,379,136,154,23,125,248,388,-14,189,252,-2,196,218,143,220,207,158,232,196,134,167,176,-169,218,362,-173,144,175,-172,149,146,-194,300,380,148,241,474,-144,248,477,-156,327,625,182,254,542,-89,354,621,191,348,622,203,280,383,-15,288,537,-93,348,622,157,322,625,161,306,591,110,333,587,105,298,621,54,326,617,46,281,579,8,311,575,-2,273,585,-34,305,581,-41,343,757,101,320,717,17,300,669,-43,282,618,-91,359,710,210,362,770,180,154,-9,37,206,190,7,72,-227,-783,-77,-227,-780,40,-13,898,46,-6,842,44,0,873,45,-32,861,43,-17,867,41,-11,880,38,-4,858,48,11,853,33,-7,868,-33,-31,862,-27,-13,898,-34,-5,842,-35,12,854,-21,-7,869,-29,-11,881,-31,-16,867,-26,-3,858,-32,0,873], + &[0,48,83,0,-1,191,0,-124,-188,0,41,-81,-136,15,-49,1,-112,326,-25,-84,425,-95,-133,52,5,-69,913,-64,-168,24,2,-50,543,0,-147,-125,-70,-114,-150,-107,40,73,-27,-105,289,0,-184,25,-23,23,828,2,-102,551,5,34,825,6,-62,1003,3,-18,712,-70,-6,-189,-82,-162,-137,6,-86,952,6,25,899,0,-27,233,-129,-63,-100,-20,-55,719,-55,-75,196,-18,-89,972,0,13,-178,5,-162,977,-18,-56,424,0,57,-13,4,-50,818,-93,5,135,-66,-98,-158,1,-49,419,0,-66,-266,-24,-28,910,-32,-53,285,-31,-78,-259,-26,-28,831,-57,-39,196,-25,-88,553,-64,-159,-155,1,-106,423,-20,5,909,-40,12,-158,-36,-68,303,-25,-32,714,-137,-81,-52,6,-24,974,4,0,763,-115,-35,86,-30,-84,353,-51,-123,-178,1,-103,360,-24,-65,550,-63,35,-95,-30,-108,-255,-125,29,102,5,-75,881,-69,-128,-153,-40,-105,-293,0,-106,-286,-85,48,-21,-16,-59,985,0,-39,274,-65,-114,-350,0,-131,244,0,-84,-365,-56,-145,-162,-89,-142,-140,-80,-191,-357,-69,-190,-357,-63,-180,-359,-74,-173,-361,-85,-180,-359,-91,-241,-707,-63,-241,-707,-95,-205,-719,-58,-207,-721,-57,-191,-417,-74,-170,-420,-65,-193,-475,-75,-186,-475,-100,-190,-417,-86,-201,-474,-92,-213,-414,-81,-208,-473,-66,-213,-414,-70,-207,-474,-67,-217,-695,-75,-211,-696,-83,-218,-696,-81,-226,-694,-71,-225,-694,-28,-18,193,-38,-102,-295,-396,273,135,-386,265,-139,-154,91,2,-361,287,-198,-418,258,146,-151,4,118,-382,294,-6,-273,192,-4,-254,156,140,-271,136,155,-280,122,132,-236,134,-176,-357,287,-168,-215,142,-179,-208,114,-202,-412,261,158,-423,378,-132,-431,379,-144,-538,470,206,-459,433,-72,-560,455,217,-554,458,229,-409,277,-6,-488,414,-75,-558,459,183,-536,473,186,-510,450,132,-534,435,128,-520,482,77,-545,466,71,-491,452,27,-517,436,18,-490,463,-14,-517,445,-19,-615,585,134,-584,561,47,-551,527,-17,-517,489,-68,-601,533,241,-632,587,215,-154,-17,34,-263,128,3,134,5,-48,28,-84,425,95,-109,75,64,-168,24,70,-114,-150,107,38,73,28,-105,289,34,23,828,70,-7,-188,79,-162,-137,129,-63,-100,28,-55,719,55,-75,196,30,-89,972,22,-56,424,93,5,135,66,-98,-158,36,-28,910,34,-53,285,31,-78,-259,37,-29,830,57,-39,196,29,-88,552,62,-159,-155,33,5,908,40,12,-158,37,-68,303,33,-32,714,137,-81,-52,115,-35,86,33,-84,353,51,-125,-178,29,-66,550,63,35,-95,30,-108,-255,124,27,102,67,-128,-153,40,-105,-293,85,48,-21,28,-60,985,65,-114,-350,53,-145,-162,87,-142,-140,78,-191,-357,67,-190,-357,61,-180,-359,72,-173,-361,83,-180,-359,84,-239,-708,60,-239,-708,88,-208,-718,56,-209,-720,55,-191,-417,71,-170,-420,61,-193,-475,71,-186,-475,97,-190,-417,82,-201,-474,89,-214,-414,77,-208,-473,63,-213,-414,66,-207,-474,64,-217,-695,73,-211,-696,80,-218,-696,78,-226,-694,69,-225,-694,28,-18,193,38,-102,-295,413,234,139,403,229,-134,152,80,3,383,256,-194,431,214,150,150,0,119,404,258,-2,277,178,-2,252,145,142,265,123,158,272,108,134,234,124,-174,379,256,-164,213,132,-178,207,104,-200,426,218,162,461,332,-127,470,331,-139,590,398,213,507,378,-67,609,378,224,603,383,235,427,235,-2,532,354,-69,608,383,189,589,401,192,560,384,138,580,365,134,576,414,83,597,393,77,542,390,33,564,369,24,543,401,-8,566,378,-13,689,495,142,655,478,54,615,452,-11,575,422,-62,664,446,248,705,493,222,154,-19,34,257,116,5,72,-239,-781,-77,-238,-778,40,-12,900,46,-4,844,44,1,875,45,-30,863,43,-16,869,41,-10,882,38,-2,860,47,13,856,33,-6,870,-33,-30,864,-27,-12,900,-34,-4,845,-35,13,856,-21,-6,871,-29,-9,883,-31,-15,869,-27,-2,860,-32,2,875], + &[0,57,82,0,9,190,0,-118,-187,0,48,-82,-135,-21,-61,1,-100,327,-25,-68,426,-95,-124,53,5,-57,914,-64,-160,25,2,-30,543,0,-140,-124,-70,-108,-149,-108,42,69,-27,-93,289,0,-175,26,-23,35,829,2,-82,551,5,47,826,6,-50,1004,3,-3,714,-73,0,-193,-82,-155,-136,6,-73,953,6,38,900,0,-16,232,-129,-56,-100,-20,-41,719,-55,-64,196,-18,-76,973,0,19,-179,5,-150,978,-18,-40,424,0,65,-15,4,-38,819,-93,15,134,-66,-91,-157,1,-33,418,0,-62,-266,-24,-15,911,-32,-41,285,-31,-73,-259,-26,-17,832,-57,-29,195,-24,-68,553,-64,-153,-153,1,-90,424,-20,17,910,-40,19,-159,-36,-56,303,-25,-17,715,-137,-73,-52,6,-12,975,4,13,765,-115,-25,86,-30,-70,353,-41,-118,-181,1,-89,361,-24,-45,550,-63,42,-96,-30,-103,-254,-123,29,98,5,-63,882,-69,-122,-152,-40,-102,-292,0,-101,-285,-85,56,-23,-16,-47,986,0,-27,273,-65,-113,-349,0,-120,245,0,-83,-365,-56,-139,-161,-89,-135,-139,-80,-190,-355,-69,-189,-355,-63,-179,-357,-74,-172,-359,-85,-179,-357,-91,-253,-703,-63,-253,-703,-95,-217,-715,-58,-219,-717,-57,-191,-415,-74,-171,-418,-65,-196,-472,-75,-189,-473,-100,-190,-415,-86,-204,-471,-92,-214,-411,-81,-211,-470,-66,-213,-411,-70,-210,-470,-67,-228,-692,-75,-223,-692,-83,-229,-692,-81,-237,-691,-71,-237,-691,-28,-8,193,-38,-98,-294,-471,17,172,-487,26,-101,-185,30,-1,-492,59,-160,-474,-9,183,-138,-19,113,-491,44,32,-341,44,12,-284,27,150,-281,1,165,-282,-15,141,-299,23,-166,-486,62,-130,-287,41,-171,-269,21,-197,-470,-3,195,-593,73,-82,-600,68,-94,-703,43,268,-651,82,-16,-706,16,279,-703,23,291,-497,12,32,-657,48,-19,-711,21,245,-706,47,248,-678,51,191,-683,24,188,-713,67,140,-719,38,134,-677,69,86,-683,39,77,-688,78,45,-694,46,40,-847,64,211,-817,73,120,-777,76,51,-731,77,-4,-788,37,312,-851,52,292,-151,-21,32,-291,1,13,134,-23,-60,28,-68,426,95,-99,75,64,-160,25,70,-108,-149,107,42,69,28,-93,289,34,35,829,72,0,-193,79,-155,-136,129,-56,-100,28,-41,719,55,-64,196,30,-77,973,22,-40,424,93,15,134,66,-91,-157,36,-16,911,34,-41,285,31,-73,-259,37,-17,832,57,-29,195,29,-68,552,62,-153,-153,33,17,909,40,19,-159,37,-56,303,33,-18,715,137,-73,-52,115,-25,86,33,-71,353,41,-119,-181,29,-45,550,63,42,-96,30,-103,-254,123,29,98,67,-122,-152,40,-102,-292,85,56,-23,28,-47,986,65,-113,-349,53,-139,-161,87,-135,-139,78,-190,-355,67,-189,-355,61,-179,-357,72,-172,-359,83,-179,-357,84,-251,-704,60,-251,-704,88,-219,-714,56,-221,-716,55,-191,-415,71,-171,-418,61,-196,-472,71,-189,-473,97,-191,-414,82,-204,-471,89,-214,-411,77,-211,-470,63,-213,-411,66,-210,-470,64,-228,-692,73,-223,-692,80,-229,-692,78,-237,-690,69,-237,-691,28,-8,193,38,-98,-294,468,-22,169,480,-10,-104,184,28,-1,491,21,-162,465,-49,179,137,-20,113,491,3,29,343,34,12,285,26,150,279,0,166,278,-15,142,297,21,-166,487,24,-132,286,39,-171,268,19,-197,463,-42,191,594,12,-87,600,5,-98,702,-48,261,654,7,-22,699,-75,271,697,-68,283,489,-29,28,653,-26,-25,704,-71,237,705,-44,240,677,-33,184,677,-60,180,714,-24,132,714,-53,126,678,-13,80,678,-43,70,690,-5,38,689,-38,33,845,-56,201,817,-40,110,777,-26,42,732,-14,-12,784,-73,302,849,-72,281,150,-22,32,286,2,13,72,-251,-777,-77,-250,-774,40,0,901,46,7,845,44,14,876,45,-18,864,43,-3,870,41,2,883,38,9,861,47,25,857,33,5,871,-33,-18,865,-27,0,901,-34,7,846,-35,25,857,-21,5,872,-29,2,884,-31,-3,870,-27,9,861,-32,14,876], + &[0,72,81,0,25,190,0,-106,-187,0,61,-83,-127,-52,-70,1,-81,328,-25,-47,426,-95,-109,53,5,-37,915,-64,-145,26,2,-6,543,0,-128,-123,-70,-96,-149,-108,50,65,-27,-76,290,0,-161,28,-23,54,829,2,-58,551,5,66,827,6,-30,1004,3,16,714,-78,9,-195,-82,-143,-134,6,-54,953,6,57,900,0,0,232,-129,-43,-100,-20,-21,719,-55,-48,196,-18,-57,974,0,31,-180,5,-131,978,-18,-19,423,0,79,-16,4,-20,819,-93,31,133,-66,-79,-157,1,-12,417,0,-51,-266,-24,3,912,-32,-24,285,-31,-62,-259,-26,1,832,-57,-12,195,-24,-44,552,-64,-141,-152,1,-69,425,-20,37,910,-40,31,-159,-36,-39,303,-25,2,716,-137,-60,-51,6,7,975,4,32,766,-115,-10,86,-30,-52,354,-35,-104,-185,1,-70,361,-24,-21,550,-63,55,-97,-30,-92,-253,-121,36,95,5,-43,882,-69,-110,-152,-40,-93,-291,0,-91,-284,-85,70,-24,-16,-27,986,0,-10,272,-65,-106,-347,0,-103,246,0,-77,-364,-56,-127,-160,-89,-123,-138,-80,-184,-352,-69,-184,-352,-63,-174,-355,-74,-167,-357,-85,-174,-355,-91,-264,-698,-63,-265,-698,-95,-228,-709,-58,-230,-712,-57,-188,-412,-74,-167,-416,-65,-195,-469,-75,-189,-470,-100,-187,-412,-86,-204,-468,-92,-210,-407,-81,-210,-466,-66,-209,-407,-70,-210,-467,-67,-240,-686,-75,-234,-687,-83,-241,-687,-81,-248,-685,-71,-248,-685,-28,8,192,-38,-89,-293,-381,-242,202,-421,-219,-68,-189,-37,-2,-454,-198,-122,-361,-262,209,-118,-26,106,-427,-225,66,-321,-119,30,-248,-95,159,-227,-112,171,-220,-125,146,-301,-109,-153,-450,-195,-92,-301,-87,-158,-279,-93,-187,-363,-256,222,-524,-273,-46,-525,-281,-58,-543,-412,296,-563,-319,19,-523,-432,303,-525,-426,316,-406,-250,62,-541,-345,12,-533,-429,270,-549,-409,276,-539,-379,221,-522,-400,214,-578,-392,171,-560,-414,161,-561,-357,119,-543,-380,106,-578,-356,79,-558,-380,70,-656,-502,239,-651,-465,150,-633,-425,83,-609,-384,28,-589,-484,337,-642,-521,317,-144,-18,30,-256,-117,21,132,-47,-71,28,-47,426,95,-85,76,64,-145,26,70,-96,-149,109,51,65,28,-76,290,34,54,829,78,9,-195,79,-143,-134,129,-43,-100,28,-21,719,55,-48,196,30,-57,973,22,-19,423,93,31,133,66,-79,-157,36,3,911,34,-24,285,31,-62,-259,37,1,832,57,-12,195,29,-44,552,62,-141,-152,33,36,910,40,31,-159,37,-39,303,33,2,715,137,-60,-51,115,-10,86,33,-52,354,36,-103,-185,29,-21,550,63,55,-97,30,-92,-253,122,37,95,67,-110,-152,40,-93,-291,85,70,-24,28,-28,986,65,-106,-347,53,-127,-160,87,-123,-138,78,-184,-352,67,-184,-352,61,-174,-355,72,-167,-357,83,-174,-355,84,-262,-699,60,-262,-699,88,-231,-709,56,-232,-711,55,-188,-412,71,-167,-416,61,-195,-469,71,-189,-470,97,-187,-412,82,-204,-468,89,-210,-407,77,-210,-466,63,-209,-407,66,-210,-467,64,-240,-686,73,-234,-687,80,-241,-687,78,-248,-685,69,-248,-685,28,8,192,38,-89,-293,364,-262,191,404,-232,-79,194,-32,-3,439,-214,-132,341,-279,198,120,-24,106,410,-247,55,323,-121,28,256,-91,159,234,-106,171,226,-118,146,304,-103,-154,436,-212,-102,306,-82,-159,284,-88,-188,344,-275,210,495,-305,-62,495,-312,-74,495,-463,272,527,-360,0,473,-479,278,476,-475,291,385,-267,50,501,-381,-7,482,-477,245,502,-460,252,496,-426,199,476,-443,191,531,-442,147,510,-460,137,520,-402,98,498,-421,84,537,-402,57,512,-422,47,590,-568,207,591,-526,121,579,-480,56,562,-433,4,529,-544,308,575,-589,285,145,-17,29,260,-110,21,72,-261,-772,-77,-260,-769,40,18,901,46,26,845,44,33,876,45,0,865,43,15,870,41,21,883,38,28,861,47,44,857,33,24,872,-33,0,865,-27,19,901,-35,26,846,-36,44,857,-21,25,872,-29,21,884,-31,15,871,-27,28,861,-32,33,876], + &[0,89,80,0,42,189,0,-92,-186,0,76,-84,-116,-68,-77,1,-63,328,-25,-27,426,-95,-93,54,5,-15,915,-64,-129,27,2,15,543,0,-113,-122,-70,-81,-148,-109,62,63,-27,-58,290,0,-145,29,-23,76,829,2,-37,551,5,87,826,6,-8,1004,3,38,714,-82,18,-197,-82,-128,-133,6,-31,953,6,79,900,0,17,231,-129,-28,-100,-20,0,719,-55,-30,196,-18,-34,974,0,45,-181,5,-108,979,-18,0,423,0,95,-17,4,1,819,-93,47,133,-66,-65,-156,1,7,417,0,-38,-266,-24,25,911,-32,-6,284,-31,-49,-259,-26,23,832,-57,4,195,-24,-22,552,-64,-127,-150,1,-49,425,-20,59,909,-40,45,-160,-36,-20,303,-25,23,715,-137,-44,-51,6,30,975,4,54,766,-115,5,85,-30,-32,354,-34,-86,-187,1,-51,362,-24,0,550,-63,70,-98,-30,-79,-252,-119,48,93,5,-21,882,-69,-95,-152,-40,-80,-290,0,-78,-283,-85,85,-25,-16,-5,986,0,7,272,-65,-95,-346,0,-85,247,0,-66,-364,-56,-113,-159,-89,-108,-138,-80,-176,-349,-69,-176,-350,-63,-166,-353,-74,-159,-354,-85,-166,-352,-91,-273,-692,-63,-273,-692,-95,-237,-703,-58,-239,-705,-57,-182,-409,-74,-161,-414,-65,-192,-466,-75,-186,-467,-100,-181,-409,-86,-200,-464,-92,-204,-403,-81,-207,-462,-66,-203,-403,-70,-206,-462,-67,-249,-680,-75,-243,-682,-83,-250,-680,-81,-257,-678,-71,-257,-678,-28,25,192,-38,-77,-292,-211,-372,206,-280,-337,-58,-192,-56,-21,-323,-335,-108,-183,-376,210,-104,-17,101,-268,-368,73,-245,-217,36,-185,-157,160,-157,-161,170,-148,-169,144,-250,-198,-147,-319,-334,-78,-261,-180,-151,-241,-176,-182,-187,-375,223,-323,-448,-49,-320,-453,-62,-221,-618,263,-318,-518,5,-192,-622,267,-196,-621,280,-237,-372,65,-286,-522,-4,-204,-621,234,-229,-618,243,-245,-580,195,-219,-584,184,-271,-606,142,-244,-610,129,-284,-561,98,-257,-565,82,-302,-564,58,-272,-569,45,-256,-750,187,-283,-705,106,-300,-653,47,-312,-598,2,-207,-709,288,-227,-768,261,-138,-6,28,-193,-180,23,128,-60,-78,28,-27,426,95,-68,76,64,-129,27,70,-81,-148,112,63,63,28,-58,290,34,76,828,84,19,-197,79,-128,-133,129,-28,-100,28,0,719,55,-30,196,30,-35,973,22,0,423,93,47,133,66,-65,-156,36,25,911,34,-6,284,31,-49,-259,37,23,832,57,4,195,29,-22,552,62,-127,-150,33,59,909,40,45,-160,37,-20,303,33,23,715,137,-44,-51,115,5,85,33,-33,354,36,-85,-187,29,0,549,63,70,-98,30,-79,-252,122,50,93,67,-95,-152,40,-80,-290,85,85,-25,28,-5,986,65,-95,-346,53,-113,-159,87,-108,-138,78,-176,-349,67,-176,-350,61,-166,-353,72,-159,-354,83,-166,-352,84,-271,-693,60,-271,-693,88,-239,-702,56,-241,-705,55,-181,-409,71,-161,-414,61,-192,-466,71,-186,-467,97,-181,-409,82,-200,-464,89,-204,-403,77,-207,-462,63,-203,-403,66,-206,-462,64,-249,-680,73,-243,-682,80,-250,-680,78,-257,-678,69,-257,-678,28,25,192,38,-77,-292,209,-372,195,279,-331,-68,184,-74,-5,323,-330,-118,181,-374,199,110,-13,101,266,-366,62,254,-213,34,198,-153,160,171,-156,170,161,-162,144,261,-190,-148,319,-330,-88,273,-173,-152,252,-168,-183,185,-374,212,314,-445,-63,311,-450,-76,202,-620,242,305,-516,-11,173,-622,246,177,-622,259,235,-368,55,273,-518,-21,185,-621,214,210,-619,223,228,-581,176,202,-582,165,253,-607,122,226,-608,109,269,-561,79,241,-562,63,286,-564,39,255,-566,26,228,-750,161,257,-704,82,278,-651,25,294,-596,-18,182,-711,264,197,-770,234,140,-5,27,205,-173,22,72,-269,-766,-77,-268,-763,40,41,901,46,48,845,44,55,876,45,22,864,43,37,870,41,43,883,38,50,861,47,66,856,33,46,871,-33,22,865,-27,41,901,-35,48,846,-36,66,857,-21,47,872,-29,43,883,-31,37,870,-27,50,861,-32,55,876], +]; + +const BIT_QUAD: u16 = 0x01; +const BIT_MATERIAL: u16 = 0x02; +const BIT_VERTEX_UV: u16 = 0x08; +const BIT_NORMAL: u16 = 0x10; +const BIT_VERTEX_NORMAL: u16 = 0x20; +const BIT_COLOR: u16 = 0x40; +const BIT_VERTEX_COLOR: u16 = 0x80; + +fn make_vertices(slice: &[i16]) -> Vec> { + slice.chunks(3).map(|v| + mint::Point3 { + x: v[0] as f32 * SCALE, + y: v[1] as f32 * SCALE, + z: v[2] as f32 * SCALE, + } + ).collect() +} + +fn make_indices(meta: &[u16]) -> Vec<[u16; 3]> { + let mut data = Vec::new(); + let mut iter = meta.iter(); + let uv_layers = 1; + while let Some(flags) = iter.next() { + let a = *iter.next().unwrap(); + let b = *iter.next().unwrap(); + let c = *iter.next().unwrap(); + let ni = if flags & BIT_QUAD != 0 { + let d = *iter.next().unwrap(); + data.push([a, b, d]); + data.push([b, c, d]); + 4 + } else { + data.push([a, b, c]); + 3 + }; + if flags & BIT_MATERIAL != 0 { + iter.next().unwrap(); + } + if flags & BIT_VERTEX_UV != 0 { + iter.nth(ni * uv_layers - 1).unwrap(); + } + if flags & BIT_NORMAL != 0 { + iter.next().unwrap(); + } + if flags & BIT_VERTEX_NORMAL != 0 { + iter.nth(ni - 1).unwrap(); + } + if flags & BIT_COLOR != 0 { + iter.next().unwrap(); + } + if flags & BIT_VERTEX_COLOR != 0 { + iter.nth(ni - 1).unwrap(); + } + } + data +} + +fn make_geometry() -> three::Geometry { + three::Geometry { + base_shape: three::GeometryShape { + vertices: make_vertices(VERTICES), + normals: Vec::new(), + }, + faces: make_indices(INDICES), + .. three::Geometry::empty() + } +} + +fn main() { + let mut win = three::Window::new("Three-rs mesh blending example", "data/shaders"); + let mut cam = win.factory.perspective_camera(60.0, 1.0, 1000.0); + cam.look_at([100.0, 0.0, 100.0], [0.0, 0.0, 30.0], Some([0.0, 1.0, 0.0].into())); + + let mut geom = make_geometry(); + for (i, &data) in V_FLY.iter().enumerate() { + let name = format!("fly{:02}", i); + geom.shapes.insert(name, three::GeometryShape { + vertices: make_vertices(data), + normals: Vec::new(), + }); + } + + let mesh = win.factory.mesh_dynamic(geom, three::Material::MeshBasic { + color: 0xffffff, map: None, wireframe: true + }); + win.scene.add(&mesh); + + let mut shape = 0; + let (mut name0, mut name1) = ("fly00".to_string(), "fly01".to_string()); + let blend_time = 0.2f32; + let mut timer = win.input.time(); + + while win.update() && !three::KEY_ESCAPE.is_hit(&win.input) { + let kf = timer.get(&win.input) / blend_time; + win.factory.mix(&mesh, &[(&name1, kf), (&name0, 1.0 - kf)]); + if kf > 1.0 { + shape += 1; + if shape == V_FLY.len() { + shape = 0; + } + let shape1 = if shape + 1 < V_FLY.len() { + shape + 1 + } else { + 0 + }; + name0 = format!("fly{:02}", shape); + name1 = format!("fly{:02}", shape1); + timer = win.input.time(); + } + win.render(&cam); + } +} diff --git a/examples/aviator/plane.rs b/examples/aviator/plane.rs index 9f20bfa..830327d 100644 --- a/examples/aviator/plane.rs +++ b/examples/aviator/plane.rs @@ -22,7 +22,7 @@ impl AirPlane { let cockpit = { let mut geo = three::Geometry::new_box(80.0, 50.0, 50.0); - for v in geo.vertices.iter_mut() { + for v in geo.base_shape.vertices.iter_mut() { if v.x < 0.0 { v.z += if v.y > 0.0 {-20.0} else {20.0}; v.y += if v.y > 0.0 {-10.0} else {30.0}; diff --git a/examples/group.rs b/examples/group.rs index 77740e1..fb5e57d 100644 --- a/examples/group.rs +++ b/examples/group.rs @@ -21,7 +21,7 @@ fn create_cubes(factory: &mut three::Factory, -> Vec { let mut geometry = three::Geometry::new_box(2.0, 2.0, 2.0); - for v in geometry.vertices.iter_mut() { + for v in geometry.base_shape.vertices.iter_mut() { v.z += 1.0; } diff --git a/src/factory.rs b/src/factory.rs index c2838f5..86d3817 100644 --- a/src/factory.rs +++ b/src/factory.rs @@ -4,7 +4,7 @@ use std::io::BufReader; use std::fs::File; use std::path::Path; -use cgmath::Transform as Transform_; +use cgmath::{Vector3, Transform as Transform_}; use genmesh::{Polygon, EmitTriangles, Triangulate, Vertex as GenVertex}; use genmesh::generators::{self, IndexedPolygon, SharedVertex}; use gfx; @@ -16,11 +16,12 @@ use mint; use obj; use camera::{Orthographic, Perspective}; -use render::{BackendFactory, BackendResources, GpuData, Vertex, ShadowFormat}; -use scene::{Color, Background, Group, Mesh, Sprite, Material, +use render::{BackendFactory, BackendResources, GpuData, DynamicData, + Vertex, ShadowFormat}; +use scene::{Color, Background, Group, Sprite, Material, AmbientLight, DirectionalLight, HemisphereLight, PointLight}; use {Hub, HubPtr, SubLight, Node, SubNode, - LightData, Object, Scene, Camera}; + LightData, Object, Scene, Camera, Mesh, DynamicMesh}; const NORMAL_Z: [I8Norm; 4] = [I8Norm(0), I8Norm(0), I8Norm(1), I8Norm(0)]; @@ -179,35 +180,76 @@ impl Factory { Group::new(self.hub.lock().unwrap().spawn_empty()) } - /// Create new `Mesh` with desired `Geometry` and `Material`. - pub fn mesh(&mut self, geom: Geometry, mat: Material) -> Mesh { - let vertices: Vec<_> = if geom.normals.is_empty() { - geom.vertices.iter().map(|v| Vertex { + fn mesh_vertices(shape: &GeometryShape) -> Vec { + if shape.normals.is_empty() { + shape.vertices.iter().map(|v| Vertex { pos: [v.x, v.y, v.z, 1.0], uv: [0.0, 0.0], //TODO normal: NORMAL_Z, }).collect() } else { let f2i = |x: f32| I8Norm(cmp::min(cmp::max((x * 127.) as isize, -128), 127) as i8); - geom.vertices.iter().zip(geom.normals.iter()).map(|(v, n)| Vertex { + shape.vertices.iter().zip(shape.normals.iter()).map(|(v, n)| Vertex { pos: [v.x, v.y, v.z, 1.0], uv: [0.0, 0.0], //TODO normal: [f2i(n.x), f2i(n.y), f2i(n.z), I8Norm(0)], }).collect() - }; - //TODO: dynamic geometry + } + } + + /// Create new `Mesh` with desired `Geometry` and `Material`. + pub fn mesh(&mut self, geometry: Geometry, mat: Material) -> Mesh { + let vertices = Self::mesh_vertices(&geometry.base_shape); let cbuf = self.backend.create_constant_buffer(1); - let (vbuf, slice) = if geom.faces.is_empty() { + let (vbuf, slice) = if geometry.faces.is_empty() { self.backend.create_vertex_buffer_with_slice(&vertices, ()) } else { - let faces: &[u16] = gfx::memory::cast_slice(&geom.faces); + let faces: &[u16] = gfx::memory::cast_slice(&geometry.faces); self.backend.create_vertex_buffer_with_slice(&vertices, faces) }; - Mesh::new(self.hub.lock().unwrap().spawn_visual(mat, GpuData { - slice, - vertices: vbuf, - constants: cbuf, - })) + Mesh { + object: self.hub.lock().unwrap().spawn_visual(mat, GpuData { + slice, + vertices: vbuf, + constants: cbuf, + pending: None, + }), + } + } + + /// Create a new `DynamicMesh` with desired `Geometry` and `Material`. + pub fn mesh_dynamic(&mut self, geometry: Geometry, mat: Material) -> DynamicMesh { + let slice = { + let data: &[u16] = gfx::memory::cast_slice(&geometry.faces); + gfx::Slice { + start: 0, + end: data.len() as u32, + base_vertex: 0, + instances: None, + buffer: self.backend.create_index_buffer(data), + } + }; + let (num_vertices, vertices) = { + let data = Self::mesh_vertices(&geometry.base_shape); + let buf = self.backend.create_buffer_immutable(&data, + gfx::buffer::Role::Vertex, gfx::memory::TRANSFER_DST).unwrap(); + (data.len(), buf) + }; + let constants = self.backend.create_constant_buffer(1); + + DynamicMesh { + object: self.hub.lock().unwrap().spawn_visual(mat, GpuData { + slice, + vertices, + constants, + pending: None, + }), + geometry, + dynamic: DynamicData { + num_vertices, + buffer: self.backend.create_upload_buffer(num_vertices).unwrap(), + }, + } } /// Create a `Mesh` sharing the geometry with another one. @@ -221,7 +263,9 @@ impl Factory { }, _ => unreachable!() }; - Mesh::new(hub.spawn_visual(mat, gpu_data)) + Mesh { + object: hub.spawn_visual(mat, gpu_data), + } } /// Create new sprite from `Material`. @@ -230,6 +274,7 @@ impl Factory { slice: gfx::Slice::new_match_vertex_buffer(&self.quad_buf), vertices: self.quad_buf.clone(), constants: self.backend.create_constant_buffer(1), + pending: None, })) } @@ -285,35 +330,55 @@ impl Factory { } } -/// A collection of vertices, their normals, and faces that defines the -/// shape of a polyhedral object. + +/// A shape of geometry that is used for mesh blending. #[derive(Clone, Debug)] -pub struct Geometry { +pub struct GeometryShape { /// Vertices. pub vertices: Vec>, /// Normals. pub normals: Vec>, +} + +impl GeometryShape { + /// Create an empty shape. + pub fn empty() -> Self { + GeometryShape { + vertices: Vec::new(), + normals: Vec::new(), + } + } +} + +/// A collection of vertices, their normals, and faces that defines the +/// shape of a polyhedral object. +#[derive(Clone, Debug)] +pub struct Geometry { + /// The original shape of geometry. + pub base_shape: GeometryShape, + /// A map containing blend shapes and their names. + pub shapes: HashMap, /// Faces. pub faces: Vec<[u16; 3]>, - /// Whether geometry is dynamic or not. - pub is_dynamic: bool, } impl Geometry { /// Create new `Geometry` without any data in it. - pub fn empty() -> Geometry { + pub fn empty() -> Self { Geometry { - vertices: Vec::new(), - normals: Vec::new(), + base_shape: GeometryShape::empty(), + shapes: HashMap::new(), faces: Vec::new(), - is_dynamic: false, } } /// Create `Geometry` from vector of vertices. - pub fn from_vertices(verts: Vec>) -> Geometry { + pub fn from_vertices(vertices: Vec>) -> Self { Geometry { - vertices: verts, + base_shape: GeometryShape { + vertices, + normals: Vec::new(), + }, .. Geometry::empty() } } @@ -325,17 +390,19 @@ impl Geometry { Fnor: Fn(GenVertex) -> mint::Vector3, { Geometry { - vertices: gen.shared_vertex_iter() - .map(fpos) - .collect(), - normals: gen.shared_vertex_iter() - .map(fnor) - .collect(), + base_shape: GeometryShape { + vertices: gen.shared_vertex_iter() + .map(fpos) + .collect(), + normals: gen.shared_vertex_iter() + .map(fnor) + .collect(), + }, + shapes: HashMap::new(), faces: gen.indexed_polygon_iter() .triangulate() .map(|t| [t.x as u16, t.y as u16, t.z as u16]) .collect(), - is_dynamic: false, } } @@ -390,6 +457,7 @@ impl Geometry { } } + /// An image applied (mapped) to the surface of a shape or polygon. #[derive(Clone, Debug)] pub struct Texture { @@ -579,11 +647,14 @@ impl Factory { let (vbuf, slice) = self.backend.create_vertex_buffer_with_slice(&vertices, &indices[..]); let cbuf = self.backend.create_constant_buffer(1); - let mesh = Mesh::new(hub.spawn_visual(material, GpuData { - slice, - vertices: vbuf, - constants: cbuf, - })); + let mesh = Mesh { + object: hub.spawn_visual(material, GpuData { + slice, + vertices: vbuf, + constants: cbuf, + pending: None, + }), + }; group.add(&mesh); meshes.push(mesh); } @@ -593,4 +664,37 @@ impl Factory { (groups, meshes) } + + /// Update the geometry of `DynamicMesh`. + pub fn mix(&mut self, mesh: &DynamicMesh, shapes: &[(&str, f32)]) { + let f2i = |x: f32| I8Norm(cmp::min(cmp::max((x * 127.) as isize, -128), 127) as i8); + + self.hub.lock().unwrap().update_mesh(mesh); + let shapes: Vec<_> = shapes.iter().map(|&(name, k)| + (&mesh.geometry.shapes[name], k) + ).collect(); + let mut mapping = self.backend.write_mapping(&mesh.dynamic.buffer).unwrap(); + + for i in 0 .. mesh.geometry.base_shape.vertices.len() { + let (mut pos, ksum) = shapes.iter().fold((Vector3::new(0.0, 0.0, 0.0), 0.0), |(pos, ksum), &(ref shape, k)| { + let p: [f32; 3] = shape.vertices[i].into(); + (pos + k * Vector3::from(p), ksum + k) + }); + if ksum != 1.0 { + let p: [f32; 3] = mesh.geometry.base_shape.vertices[i].into(); + pos += (1.0 - ksum) * Vector3::from(p); + } + let normal = if mesh.geometry.base_shape.normals.is_empty() { + NORMAL_Z + } else { + let n = mesh.geometry.base_shape.normals[i]; + [f2i(n.x), f2i(n.y), f2i(n.z), I8Norm(0)] + }; + mapping[i] = Vertex { + pos: [pos.x, pos.y, pos.z, 1.0], + uv: [0.0, 0.0], //TODO + normal, + }; + } + } } diff --git a/src/lib.rs b/src/lib.rs index 65f3d64..ab1f4f8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -30,13 +30,13 @@ mod scene; mod window; pub use camera::{OrbitControls, Orthographic, Perspective}; -pub use factory::{Factory, Geometry, ShadowMap, Texture}; +pub use factory::{Factory, Geometry, GeometryShape, ShadowMap, Texture}; pub use input::{Button, KeyAxis, Timer, Input, KEY_ESCAPE, KEY_SPACE, MOUSE_LEFT, MOUSE_RIGHT, AXIS_LEFT_RIGHT, AXIS_DOWN_UP}; pub use render::{ColorFormat, DepthFormat, Renderer, ShadowType, DebugQuadHandle}; pub use scene::{Color, Background, Material, NodeTransform, NodeInfo, - Group, Mesh, Sprite, + Group, Sprite, AmbientLight, DirectionalLight, HemisphereLight, PointLight}; #[cfg(feature = "opengl")] pub use window::Window; @@ -47,7 +47,7 @@ use std::sync::{mpsc, Arc, Mutex}; use cgmath::Transform as Transform_; use factory::SceneId; -use render::GpuData; +use render::{DynamicData, GpuData}; /// Pointer to a Node pub type NodePointer = froggy::Pointer; @@ -218,6 +218,14 @@ impl Hub { item.world_transform = transform; } } + + fn update_mesh(&mut self, mesh: &DynamicMesh) { + match self.nodes[&mesh.node].sub_node { + SubNode::Visual(_, ref mut gpu_data) => + gpu_data.pending = Some(mesh.dynamic.clone()), + _ => unreachable!() + } + } } /// Game scene contains game objects and can be rendered by [`Camera`](struct.Camera.html). @@ -229,3 +237,16 @@ pub struct Scene { /// See [`Background`](struct.Background.html). pub background: scene::Background, } + +/// [`Geometry`](struct.Geometry.html) with some [`Material`](struct.Material.html). +pub struct Mesh { + object: Object, +} + +/// A dynamic version of a mesh allows changing the geometry on CPU side +/// in order to animate the mesh. +pub struct DynamicMesh { + object: Object, + geometry: Geometry, + dynamic: DynamicData, +} diff --git a/src/render.rs b/src/render.rs index f1cfb22..82729a8 100644 --- a/src/render.rs +++ b/src/render.rs @@ -141,6 +141,13 @@ pub struct GpuData { pub slice: gfx::Slice, pub vertices: gfx::handle::Buffer, pub constants: gfx::handle::Buffer, + pub pending: Option, +} + +#[derive(Clone, Debug)] +pub struct DynamicData { + pub num_vertices: usize, + pub buffer: gfx::handle::Buffer, } /// Shadow type is used to specify shadow's rendering algorithm. @@ -305,6 +312,19 @@ impl Renderer { hub.process_messages(); hub.update_graph(); + // update dynamic meshes + for mut node in hub.nodes.iter_alive_mut() { + if !node.visible || node.scene_id != Some(scene.unique_id) { + continue + } + if let SubNode::Visual(_, ref mut gpu_data) = node.sub_node { + if let Some(dynamic) = gpu_data.pending.take() { + self.encoder.copy_buffer(&dynamic.buffer, &gpu_data.vertices, 0, 0, dynamic.num_vertices) + .unwrap(); + } + } + } + // gather lights struct ShadowRequest { target: gfx::handle::DepthStencilView, diff --git a/src/scene.rs b/src/scene.rs index a44dee0..6114474 100644 --- a/src/scene.rs +++ b/src/scene.rs @@ -3,9 +3,10 @@ use std::ops; use mint; use {Object, Operation, NodePointer, SubNode, + Mesh, DynamicMesh, Scene, ShadowProjection, Transform}; use camera::Orthographic; -use factory::{Geometry, ShadowMap, Texture}; +use factory::{ShadowMap, Texture}; /// Color represented by 4-bytes hex number. pub type Color = u32; @@ -182,21 +183,15 @@ impl Group { } } -/// [`Geometry`](struct.Geometry.html) with some [`Material`](struct.Material.html). -pub struct Mesh { - object: Object, - _geometry: Option, -} - impl Mesh { - #[doc(hidden)] - pub fn new(object: Object) -> Self { - Mesh { - object, - _geometry: None, - } + /// Set mesh material. + pub fn set_material(&mut self, material: Material) { + let msg = Operation::SetMaterial(material); + let _ = self.tx.send((self.node.downgrade(), msg)); } +} +impl DynamicMesh { /// Set mesh material. pub fn set_material(&mut self, material: Material) { let msg = Operation::SetMaterial(material); @@ -336,7 +331,7 @@ macro_rules! as_node { } } -as_node!(Object, Group, Mesh, Sprite, +as_node!(Object, Group, Mesh, DynamicMesh, Sprite, AmbientLight, DirectionalLight, HemisphereLight, PointLight); macro_rules! deref_objects { @@ -358,5 +353,5 @@ macro_rules! deref_objects { } } -deref_objects!(Group, Mesh, Sprite, +deref_objects!(Group, Mesh, DynamicMesh, Sprite, AmbientLight, HemisphereLight, DirectionalLight, PointLight);