initial commit of mdm-viewer

This commit is contained in:
Paul Sajna committed 2023-04-09 17:50:43 -07:00
1 parent 839f7885fb
commit ffcc144bb6
21 files changed
+4961 -133

No files matched your search

Generated
+1453 -133
View File
File diff suppressed because it is too large. Load diff
+1
View File
@@ -47,6 +47,7 @@ members = [
# Programs: Desktop apps
"crates/programs/aichatbot-sidecar",
"crates/programs/mdm-viewer",
# Services: API servers, jobs, workers, etc.
"crates/service/job/analytics_job",
+1
View File
@@ -0,0 +1 @@
*.log
File diff suppressed because it is too large. Load diff
+12
View File
@@ -0,0 +1,12 @@
[package]
name = "mdm-viewer"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
fyrox = { git = "https://github.com/FyroxEngine/Fyrox", rev="9a4f1c0fbce96eb55839405492ff554757fac6e0"}
ndarray = "0.15.6"
serde = { version = "1.0.159", features = ["derive"] }
serde_json = "1.0.95"
Binary file not shown.
@@ -0,0 +1 @@
{"joint_map": ["Hips", "LeftUpLeg", "RightUpLeg", "Spine", "LeftLeg", "RightLeg", "Spine1", "LeftFoot", "RightFoot", "Spine2", "LeftToeBase", "RightToeBase", "Neck", "LeftShoulder", "RightShoulder", "Head", "LeftArm", "RightArm", "LeftForeArm", "RightForeArm", "LeftHand", "RightHand"], "thetas": [[[[2.03106427192688, -18.75054359436035, 1.3278865814208984], [-6.120968341827393, 3.9750916957855225, 2.567340135574341], [5.757377624511719, -3.7807488441467285, 0.4459919333457947], [3.7528469562530518, 3.9528005123138428, 0.9510968923568726], [11.038130760192871, 7.045173645019531, -2.458817720413208], [-3.1020939350128174, -3.914801836013794, 0.6926640868186951], [5.527799606323242, -1.6439255475997925, 0.15385420620441437], [-3.178042411804199, 13.641267776489258, 1.037602186203003], [-6.529130935668945, -8.661418914794922, -3.2072107791900635], [-2.041452646255493, 1.0062202215194702, -0.5530557036399841], [-5.044497966766357, 5.063436985015869, 3.9958643913269043], [9.711397171020508, -2.3810412883758545, 6.066860675811768], [11.646537780761719, 5.749516487121582, 0.02610483206808567], [1.5783969163894653, 3.0580179691314697, -25.63871955871582], [2.1563360691070557, 5.449275493621826, 27.291946411132812], [6.132938385009766, 3.145101308822632, -0.01197897270321846], [5.13370418548584, -15.639087677001953, -53.54275131225586], [6.326976776123047, 14.734569549560547, 53.53369903564453], [5.784238815307617, -21.259098052978516, 11.227493286132812], [0.6779769062995911, 20.339542388916016, -8.426377296447754], [2.47957181930542, -13.181086540222168, -10.192920684814453], [-3.477168083190918, 10.271886825561523, 7.051610946655273], [-12.099485397338867, -1.7910120487213135, -11.085472106933594], [-3.652040719985962, 4.5306220054626465, 10.814247131347656]], [[2.3171446323394775, -19.660884857177734, 1.439484715461731], [-7.129613876342773, 3.742736577987671, 3.113529920578003], [5.601938724517822, -3.5275909900665283, 0.5200863480567932], [4.009231090545654, 4.009494304656982, 0.9757032990455627], [13.682687759399414, 7.336271286010742, -2.710404396057129], [-2.9756643772125244, -3.5608596801757812, 0.7416874170303345], [5.605612277984619, -1.7002888917922974, 0.20707568526268005], [-3.2517476081848145, 13.791121482849121, 0.9901719093322754], [-6.760733127593994, -8.438523292541504, -3.582566499710083], [-2.0180652141571045, 0.9961000680923462, -0.5397628545761108], [-5.505047798156738, 5.0592193603515625, 4.190332889556885], [9.771798133850098, -2.5662386417388916, 6.333200454711914], [11.938506126403809, 5.898192405700684, -0.009825215674936771], [1.553299069404602, 3.15982723236084, -25.588096618652344], [2.1931228637695312, 5.353734493255615, 27.23920440673828], [6.262124061584473, 3.2875561714172363, -0.05062737315893173], [5.068545818328857, -15.72238826751709, -53.566734313964844], [6.376531600952148, 14.66812515258789, 53.470191955566406], [5.809123992919922, -21.4490909576416, 11.463191986083984], [0.8968050479888916, 20.749549865722656, -8.466951370239258], [2.3885087966918945, -13.364996910095215, -10.324952125549316], [-3.5541324615478516, 10.463605880737305, 7.1118059158325195], [-11.797411918640137, -1.7850548028945923, -11.072400093078613], [-3.455199956893921, 4.513914585113525, 10.857826232910156]], [[2.5588486194610596, -21.213542938232422, 1.4193873405456543], [-9.4752197265625, 3.0112409591674805, 4.102313041687012], [5.439895153045654, -3.057105779647827, 0.5826795697212219], [4.50769567489624, 4.297774314880371, 0.990039050579071], [19.150999069213867, 7.695703029632568, -3.4628429412841797], [-2.5632433891296387, -2.782291889190674, 0.9211568832397461], [5.783545017242432, -1.7198225259780884, 0.22207535803318024], [-3.198939561843872, 13.998563766479492, 0.7834417819976807], [-7.1761674880981445, -8.031264305114746, -4.280980587005615], [-1.9536586999893188, 1.074763536453247, -0.5391568541526794], [-6.50226354598999, 4.949704170227051, 4.70660400390625], [9.753036499023438, -2.799469232559204, 6.755975723266602], [12.200167655944824, 6.3183913230896, -0.03890233114361763], [1.5418339967727661, 3.362967014312744, -25.5731258392334], [2.3271894454956055, 5.338535308837891, 27.2824764251709], [6.845359802246094, 3.671485424041748, -0.12624870240688324], [4.850167274475098, -15.792562484741211, -53.524696350097656], [6.309472560882568, 14.624929428100586, 53.234222412109375], [5.704424858093262, -21.524208068847656, 11.84507942199707], [1.118586540222168, 21.158672332763672, -8.467469215393066], [2.100891590118408, -13.775664329528809, -10.55246353149414], [-3.5915236473083496, 10.840123176574707, 7.0990705490112305], [-11.014416694641113, -1.745030403137207, -10.847249031066895], [-2.9752049446105957, 4.476255893707275, 10.758650779724121]], [[2.618084192276001, -22.657167434692383, 1.2655651569366455], [-12.832072257995605, 1.8315448760986328, 5.207208156585693], [5.511909484863281, -2.6128084659576416, 0.4550289213657379], [5.149789333343506, 4.8391499519348145, 0.9955631494522095], [2Line truncated
Binary file not shown.
@@ -0,0 +1 @@
{"joint_map": ["Hips", "LeftUpLeg", "RightUpLeg", "Spine", "LeftLeg", "RightLeg", "Spine1", "LeftFoot", "RightFoot", "Spine2", "LeftToeBase", "RightToeBase", "Neck", "LeftShoulder", "RightShoulder", "Head", "LeftArm", "RightArm", "LeftForeArm", "RightForeArm", "LeftHand", "RightHand"], "thetas": [[[[5.467503547668457, 15.934134483337402, -9.08014965057373], [-6.2753825187683105, 3.9613702297210693, 9.474159240722656], [-26.9811954498291, 1.143561601638794, -8.002421379089355], [14.99827766418457, -3.249314546585083, -0.014775867573916912], [18.464157104492188, -0.9143807888031006, -1.9066675901412964], [7.66969633102417, -6.000504493713379, 1.8150901794433594], [-0.7233057022094727, -8.282331466674805, 8.771685600280762], [-17.84868621826172, 5.527249813079834, 4.181504726409912], [11.217578887939453, -3.838836193084717, 20.314769744873047], [1.4092044830322266, -5.750782012939453, 5.857841491699219], [-3.288994073867798, 7.884649276733398, 3.106720209121704], [-0.9037767052650452, 2.3337061405181885, -21.600685119628906], [-0.2238776981830597, -17.64483642578125, 7.817104816436768], [-2.2864394187927246, -20.287038803100586, -7.558629035949707], [-8.072043418884277, 9.670024871826172, 10.362568855285645], [13.049989700317383, -21.189117431640625, 13.72021484375], [-26.188308715820312, -32.92147445678711, -65.44725036621094], [-9.946019172668457, 13.95793342590332, 52.02675247192383], [34.26494216918945, -55.63215637207031, 44.06476974487305], [12.44713306427002, 58.77227020263672, -51.6109504699707], [-14.319973945617676, -4.21311616897583, 2.5136899948120117], [-5.150778770446777, 2.076508045196533, -2.7235188484191895], [-2.002668857574463, -4.200062274932861, -11.203028678894043], [-7.562265872955322, 8.83970832824707, 12.973882675170898]], [[5.582523345947266, 14.613210678100586, -8.819766998291016], [-6.966118812561035, 3.986631155014038, 9.620370864868164], [-26.053430557250977, 1.408429741859436, -8.350895881652832], [14.571937561035156, -3.3629677295684814, 0.2833799123764038], [19.316062927246094, -0.2766510546207428, -2.0399386882781982], [7.88300895690918, -4.686621189117432, 1.1648939847946167], [-0.6909183859825134, -8.662055015563965, 9.03845500946045], [-17.765199661254883, 5.80699348449707, 4.129086971282959], [10.446803092956543, -3.680290460586548, 20.137882232666016], [1.463354229927063, -6.010002136230469, 5.945803642272949], [-3.6470541954040527, 7.642251968383789, 3.468153476715088], [-1.2394930124282837, 1.9159841537475586, -21.677574157714844], [-0.37210512161254883, -17.952943801879883, 7.766056537628174], [-1.9195971488952637, -20.365924835205078, -7.731883525848389], [-7.841255187988281, 9.205591201782227, 10.093060493469238], [12.70028018951416, -20.88649559020996, 13.60639476776123], [-26.01751136779785, -33.2342414855957, -66.96268463134766], [-9.88315200805664, 13.524042129516602, 51.83861541748047], [35.738739013671875, -54.8019905090332, 43.665950775146484], [10.170729637145996, 57.49854278564453, -49.540687561035156], [-14.98676872253418, -4.0081706047058105, 1.5238910913467407], [-5.337751865386963, 1.6473883390426636, -2.0710980892181396], [-1.9748337268829346, -4.030743598937988, -11.239887237548828], [-7.770012855529785, 8.690213203430176, 12.787870407104492]], [[5.7844743728637695, 13.764625549316406, -8.586181640625], [-6.868415355682373, 4.103175163269043, 9.7874755859375], [-26.18825340270996, 1.4353774785995483, -8.226814270019531], [14.479924201965332, -3.4483749866485596, 0.3367474675178528], [19.299028396606445, -0.22669166326522827, -2.068995475769043], [8.131352424621582, -4.603088855743408, 1.4151127338409424], [-0.6752403974533081, -8.68319034576416, 9.100953102111816], [-17.638601303100586, 6.000809669494629, 4.008824348449707], [10.181665420532227, -3.5763232707977295, 19.967683792114258], [1.5156463384628296, -6.027714252471924, 5.977616310119629], [-3.7407302856445312, 7.567543983459473, 3.6248390674591064], [-1.2098309993743896, 1.7470877170562744, -21.472015380859375], [-0.19236651062965393, -18.219552993774414, 7.92957067489624], [-1.9074394702911377, -20.193748474121094, -7.393083095550537], [-7.915910243988037, 9.111021995544434, 9.629098892211914], [12.587199211120605, -21.093461990356445, 13.738096237182617], [-25.90407371520996, -33.18856430053711, -66.69632720947266], [-9.96056842803955, 13.578302383422852, 51.662559509277344], [36.14103698730469, -55.08977508544922, 44.161251068115234], [11.026519775390625, 57.7147216796875, -50.00410842895508], [-15.114005088806152, -4.085815906524658, 1.590478539466858], [-5.393459320068359, 1.6968694925308228, -2.07757306098938], [-1.928836464881897, -3.9321272373199463, -11.105406761169434], [-7.639109134674072, 8.636758804321289, 12.605361938476562]], [[6.1406941413879395, 12.831308364868164, -8.20043659210205], [-6.780738353729248, 4.176958084106445, 9.895416259765625], [-26.566444396972656, 1.4874646663665771, -8.145125389099121], [14.474721908569336, -3.524153232574463, 0.42377862334251404], [19.23310Line truncated
@@ -0,0 +1 @@
{"joint_map": ["Hips", "LeftUpLeg", "RightUpLeg", "Spine", "LeftLeg", "RightLeg", "Spine1", "LeftFoot", "RightFoot", "Spine2", "LeftToeBase", "RightToeBase", "Neck", "LeftShoulder", "RightShoulder", "Head", "LeftArm", "RightArm", "LeftForeArm", "RightForeArm", "LeftHand", "RightHand"], "thetas": [[[[-0.3866535425186157, 3.578826665878296, 0.3816697597503662], [-9.589378356933594, 4.703688144683838, 1.7432349920272827], [-9.864250183105469, -2.346255302429199, -9.156423568725586], [10.737293243408203, -0.640487551689148, 5.0760931968688965], [20.10806655883789, 2.8378758430480957, -3.8567004203796387], [21.438560485839844, -0.5584354996681213, -1.5996527671813965], [-8.081740379333496, -1.1412473917007446, -5.829880714416504], [-4.586296558380127, 1.5304948091506958, 5.520969867706299], [-8.0420503616333, -6.3308634757995605, 0.01884954795241356], [-1.9892644882202148, -0.13688386976718903, -3.472311019897461], [-10.663229942321777, 20.412052154541016, -2.8723666667938232], [2.4661571979522705, 5.413250923156738, 2.330415725708008], [-1.7577714920043945, -0.010878415778279305, 4.284958839416504], [-15.229578971862793, -30.158065795898438, -13.649079322814941], [-15.272608757019043, 35.72880554199219, 5.661762237548828], [21.688467025756836, -2.9683666229248047, -5.694263935089111], [-49.581459045410156, -39.88006591796875, -70.05650329589844], [-55.39814376831055, 44.66470718383789, 60.83835220336914], [10.915209770202637, -34.59050750732422, 36.95048904418945], [-22.664735794067383, 31.2255802154541, -24.28580093383789], [-7.928735733032227, -5.29421329498291, 13.244050025939941], [-15.215853691101074, 4.213501930236816, -21.457942962646484], [6.422789573669434, 1.6169828176498413, -1.2265037298202515], [3.0520179271698, 3.8766839504241943, 5.546128749847412]], [[0.09739017486572266, 4.106882572174072, 0.38723406195640564], [-9.45800495147705, 4.581082820892334, 2.0534827709198], [-8.995217323303223, -2.97464656829834, -9.064427375793457], [10.06467056274414, -0.40546998381614685, 5.030548095703125], [19.09524917602539, 2.9191741943359375, -3.780266523361206], [19.377607345581055, -0.7871446013450623, -1.3099784851074219], [-8.230196952819824, -1.1573435068130493, -5.9471435546875], [-4.0389251708984375, 1.5276157855987549, 5.098475933074951], [-7.498805999755859, -6.217210292816162, 0.24919822812080383], [-2.0493361949920654, 0.05763375759124756, -3.3091835975646973], [-10.312522888183594, 19.882932662963867, -2.8694417476654053], [2.8968777656555176, 5.107559680938721, 2.4246037006378174], [-1.728163480758667, -0.3637513816356659, 4.121850490570068], [-15.765060424804688, -30.502914428710938, -12.85720157623291], [-15.314018249511719, 36.05024719238281, 4.191081523895264], [21.275541305541992, -2.5290424823760986, -5.389336109161377], [-50.38446044921875, -40.23286056518555, -70.08634948730469], [-56.472042083740234, 44.935909271240234, 58.78447341918945], [10.933533668518066, -35.929176330566406, 38.249267578125], [-23.39731788635254, 32.3476448059082, -25.122695922851562], [-8.573586463928223, -5.79760217666626, 13.299271583557129], [-14.99033260345459, 4.343860626220703, -21.099365234375], [6.8718719482421875, 1.6616837978363037, -1.2532843351364136], [3.38744854927063, 3.7724790573120117, 5.23115873336792]], [[0.5448071956634521, 4.458432674407959, 0.3828311562538147], [-9.29457950592041, 4.479250431060791, 2.3393068313598633], [-8.173257827758789, -3.5101728439331055, -8.926198959350586], [9.427772521972656, -0.226080521941185, 4.966001033782959], [18.113956451416016, 2.956070899963379, -3.729524612426758], [17.440732955932617, -0.9156919717788696, -1.0280224084854126], [-8.37568473815918, -1.2039240598678589, -6.059848308563232], [-3.5156760215759277, 1.5035706758499146, 4.700930118560791], [-6.997411727905273, -6.097700595855713, 0.46551278233528137], [-2.0817325115203857, 0.18697455525398254, -3.177603244781494], [-10.009819030761719, 19.435989379882812, -2.869662046432495], [3.2996349334716797, 4.901177883148193, 2.515685558319092], [-1.6126333475112915, -0.49322542548179626, 3.9798743724823], [-16.268760681152344, -30.787975311279297, -12.20548152923584], [-15.378499031066895, 36.214969635009766, 2.9101016521453857], [20.988311767578125, -2.01716947555542, -5.192025184631348], [-51.18056106567383, -40.59279251098633, -70.14240264892578], [-57.41397476196289, 45.25752258300781, 57.07026290893555], [10.624250411987305, -36.78887176513672, 38.99229431152344], [-24.110151290893555, 33.04068374633789, -25.64959144592285], [-9.174750328063965, -6.198948383331299, 13.221794128417969], [-14.939935684204102, 4.410663604736328, -20.644866943359375], [7.264750003814697, 1.7063676118850708, -1.2483316659927368], [3.7032217979431152, 3.6760356426239014, 4.9510016441345215]], [[0.7968589067459106, 4.693453788757324, 0.36439400911331177], [-9.018125534057617, 4.474632740020752, 2.57196307182312], [-7.469768047332764, -3.8601250648498535, -8.795491218566895], [8.933686256408691, -0.14185874164104462, 4.9139308Line truncated
@@ -0,0 +1 @@
{"joint_map": ["Hips", "LeftUpLeg", "RightUpLeg", "Spine", "LeftLeg", "RightLeg", "Spine1", "LeftFoot", "RightFoot", "Spine2", "LeftToeBase", "RightToeBase", "Neck", "LeftShoulder", "RightShoulder", "Head", "LeftArm", "RightArm", "LeftForeArm", "RightForeArm", "LeftHand", "RightHand"], "thetas": [[[[1.1163116693496704, 5.577524662017822, -2.6750078201293945], [3.3691163063049316, 8.696317672729492, 7.920865535736084], [2.4320595264434814, -5.3524169921875, -4.610220909118652], [5.642988681793213, 0.37766075134277344, 1.1509119272232056], [-4.679698467254639, -2.689807176589966, -1.7008055448532104], [-3.687941074371338, 3.46921706199646, 1.1733782291412354], [-4.722110748291016, -4.205047130584717, 0.9378839135169983], [0.24329008162021637, 12.37343978881836, -5.323651313781738], [-1.3519134521484375, -11.110550880432129, 7.88387393951416], [0.3674285113811493, -0.8886459469795227, 1.7313480377197266], [-2.5050745010375977, 1.8446617126464844, 6.061509132385254], [3.9228010177612305, 1.3449935913085938, -6.9290242195129395], [0.5416126847267151, -3.7503254413604736, 2.6948599815368652], [-6.0648393630981445, -5.364870071411133, -4.393022060394287], [-6.92983341217041, 6.473362445831299, 3.694599151611328], [7.055031776428223, -3.9477550983428955, 4.405917644500732], [-15.370176315307617, -8.759979248046875, -20.953493118286133], [-15.520882606506348, 6.438925266265869, 23.55572509765625], [0.787096381187439, -28.84973907470703, 23.998001098632812], [-15.940613746643066, 33.67522048950195, -22.592641830444336], [12.754179954528809, -8.884575843811035, 8.814859390258789], [-9.557649612426758, 6.204172611236572, -4.567685127258301], [-13.019998550415039, 1.9299805164337158, -9.51132583618164], [-3.078383684158325, 2.440791130065918, 7.802062034606934]], [[1.0757668018341064, 5.743898868560791, -2.658008575439453], [3.2977993488311768, 8.737957000732422, 8.037235260009766], [2.384575843811035, -5.27142858505249, -4.767708778381348], [5.82962703704834, 0.3670220673084259, 1.124837875366211], [-4.507038116455078, -2.454143524169922, -1.7501401901245117], [-3.4979724884033203, 3.198166608810425, 1.2281816005706787], [-4.487558364868164, -4.280864715576172, 1.069689154624939], [0.1681762933731079, 12.072334289550781, -5.142012119293213], [-1.4327014684677124, -10.762184143066406, 7.600882053375244], [0.16846036911010742, -0.9827484488487244, 1.7045578956604004], [-2.4681103229522705, 2.115232467651367, 5.796001434326172], [4.086643218994141, 1.104880690574646, -6.4068403244018555], [0.5059378743171692, -3.6411521434783936, 2.88310170173645], [-5.811127185821533, -5.60461950302124, -5.516483783721924], [-6.747442245483398, 6.581067085266113, 4.877732753753662], [7.290273189544678, -4.161865234375, 4.2915940284729], [-15.084197998046875, -9.015006065368652, -21.560956954956055], [-15.123090744018555, 6.613794326782227, 24.407360076904297], [1.2308151721954346, -28.939620971679688, 24.03252410888672], [-15.86743450164795, 34.40801239013672, -22.86920928955078], [13.144704818725586, -8.936718940734863, 8.881721496582031], [-9.963360786437988, 6.4606852531433105, -4.855018615722656], [-13.240691184997559, 1.8749302625656128, -9.771352767944336], [-3.178905487060547, 2.556112051010132, 8.134893417358398]], [[1.0446112155914307, 5.812331199645996, -2.606966257095337], [3.2285962104797363, 8.724944114685059, 8.104227066040039], [2.311124324798584, -5.156038761138916, -4.937614440917969], [5.998713493347168, 0.3904683589935303, 1.0789258480072021], [-4.291294574737549, -2.10790753364563, -1.7964612245559692], [-3.280308723449707, 2.7405102252960205, 1.290166974067688], [-4.181278228759766, -4.336239337921143, 1.2418756484985352], [0.09956797957420349, 11.549651145935059, -4.9085588455200195], [-1.5050005912780762, -10.148889541625977, 7.290456771850586], [-0.11637838184833527, -1.0591466426849365, 1.6672985553741455], [-2.5017151832580566, 2.535022020339966, 5.492920398712158], [4.223531246185303, 0.7386834621429443, -5.80850887298584], [0.23085978627204895, -3.3485679626464844, 3.090585231781006], [-5.496094703674316, -5.932257652282715, -7.0879974365234375], [-6.499792098999023, 6.794961929321289, 6.632663726806641], [7.554502487182617, -4.452653884887695, 4.0753068923950195], [-14.689987182617188, -9.515069007873535, -22.952613830566406], [-14.619948387145996, 7.068014144897461, 26.161827087402344], [2.082127094268799, -29.457387924194336, 24.515132904052734], [-15.618603706359863, 35.60503387451172, -23.62383270263672], [13.500490188598633, -8.942376136779785, 9.152033805847168], [-10.377077102661133, 6.752048015594482, -5.422793388366699], [-13.447678565979004, 1.741245985031128, -10.21495532989502], [-3.3856360912323, 2.770597219467163, 8.701754570007324]], [[1.0147539377212524, 5.859945297241211, -2.5326411724090576], [3.197700023651123, 8.66627311706543, 8.106501579284668], [2.2547354698181152, -5.046766757965088, -5.085355281829834], [6.101076602935791, 0.4213879406452179, 1.0431339740753174], [-4.138856887817383,Line truncated
@@ -0,0 +1 @@
{"joint_map": ["Hips", "LeftUpLeg", "RightUpLeg", "Spine", "LeftLeg", "RightLeg", "Spine1", "LeftFoot", "RightFoot", "Spine2", "LeftToeBase", "RightToeBase", "Neck", "LeftShoulder", "RightShoulder", "Head", "LeftArm", "RightArm", "LeftForeArm", "RightForeArm", "LeftHand", "RightHand"], "thetas": [[[[2.369710922241211, -3.0559442043304443, -1.6779457330703735], [-3.8974289894104004, 3.854501724243164, 2.510875940322876], [0.8486663103103638, -4.719178676605225, -4.110958099365234], [8.871639251708984, 1.8651998043060303, 1.4965753555297852], [8.520210266113281, 1.2582639455795288, -2.475558280944824], [-3.518371343612671, 1.074006199836731, 1.1003581285476685], [-4.198940753936768, -1.5251020193099976, -0.054298922419548035], [-7.604578971862793, 9.954671859741211, 3.4356956481933594], [-2.4452550411224365, -10.928833961486816, 9.195329666137695], [1.6266517639160156, -1.127687931060791, 0.1870478093624115], [-4.733394622802734, 8.078431129455566, 1.4623421430587769], [2.059783697128296, 5.941490650177002, -12.670244216918945], [-5.410330772399902, -1.521551251411438, 2.0556392669677734], [3.535531520843506, 1.4911167621612549, -20.789709091186523], [0.20465101301670074, 2.0696349143981934, 23.38835906982422], [7.938186168670654, -5.21131706237793, 0.5718061923980713], [-0.5127073526382446, -9.666610717773438, -47.60362243652344], [5.08218240737915, 12.412759780883789, 49.05012130737305], [16.29062843322754, -24.421424865722656, 8.046610832214355], [2.387691020965576, 23.368080139160156, -6.6143412590026855], [0.8163022398948669, -0.884920597076416, -4.144776821136475], [1.0504323244094849, 0.6790631413459778, 2.2918264865875244], [-10.6151762008667, -2.7994272708892822, -10.409492492675781], [-8.48975658416748, 6.211604595184326, 13.279114723205566]], [[2.3521125316619873, -3.0376410484313965, -1.7110220193862915], [-3.911515712738037, 3.8785972595214844, 2.597355604171753], [0.9345817565917969, -4.739995002746582, -4.154020309448242], [8.875754356384277, 1.8511309623718262, 1.5197577476501465], [8.561184883117676, 1.2452090978622437, -2.4997825622558594], [-3.6019442081451416, 1.0898804664611816, 1.1406387090682983], [-4.186735153198242, -1.5683486461639404, -0.021407475695014], [-7.592048168182373, 9.926424026489258, 3.4463233947753906], [-2.4499306678771973, -10.828710556030273, 9.116118431091309], [1.6110813617706299, -1.1514700651168823, 0.1942664235830307], [-4.706953048706055, 8.093523979187012, 1.3923709392547607], [2.102470636367798, 5.823354721069336, -12.484704971313477], [-5.1206159591674805, -1.5741689205169678, 2.080815315246582], [3.56744122505188, 1.5368868112564087, -20.78058624267578], [0.2097901701927185, 1.9993464946746826, 23.362600326538086], [8.002667427062988, -5.22169303894043, 0.5802223682403564], [-0.564801037311554, -9.63470458984375, -47.54961395263672], [4.980896949768066, 12.392675399780273, 49.032405853271484], [16.21449089050293, -24.318815231323242, 8.057589530944824], [2.2790374755859375, 23.239578247070312, -6.635807037353516], [0.7827691435813904, -0.8364399671554565, -4.2139177322387695], [0.9979601502418518, 0.6349785923957825, 2.322890043258667], [-10.603474617004395, -2.784987449645996, -10.393538475036621], [-8.46321964263916, 6.217637062072754, 13.273021697998047]], [[2.3571767807006836, -3.0873115062713623, -1.7720887660980225], [-4.040746212005615, 3.8592584133148193, 2.696183681488037], [0.9369564056396484, -4.75827693939209, -4.200687408447266], [8.920909881591797, 1.858664631843567, 1.529840350151062], [8.768513679504395, 1.2326313257217407, -2.5293068885803223], [-3.5724215507507324, 1.10775625705719, 1.211283564567566], [-4.191956996917725, -1.5783209800720215, 0.00897478498518467], [-7.645719051361084, 9.926870346069336, 3.4759302139282227], [-2.561600923538208, -10.749258041381836, 9.02566909790039], [1.6316754817962646, -1.154797911643982, 0.2096242755651474], [-4.721362113952637, 8.103439331054688, 1.3694497346878052], [2.1319282054901123, 5.716860294342041, -12.339767456054688], [-4.903591632843018, -1.4834010601043701, 2.0746185779571533], [3.602639675140381, 1.6149803400039673, -20.767353057861328], [0.24601565301418304, 1.9183154106140137, 23.367063522338867], [8.089568138122559, -5.136928558349609, 0.5397086143493652], [-0.566981852054596, -9.60190486907959, -47.513999938964844], [4.9240875244140625, 12.388949394226074, 49.02641677856445], [16.220998764038086, -24.348562240600586, 8.107612609863281], [2.2419886589050293, 23.182260513305664, -6.639880657196045], [0.7200028896331787, -0.8132447004318237, -4.229081630706787], [0.945564329624176, 0.6108056902885437, 2.3288798332214355], [-10.577032089233398, -2.7697434425354004, -10.383041381835938], [-8.450040817260742, 6.216065883636475, 13.273027420043945]], [[2.400273323059082, -3.154939889907837, -1.8240092992782593], [-4.16174840927124, 3.824321985244751, 2.7580814361572266], [0.8874973654747009, -4.770133972167969, -4.247639179229736], [8.98039436340332, 1.8765735626220703, 1.5347168445587158], Line truncated
@@ -0,0 +1 @@
{"joint_map": ["Hips", "LeftUpLeg", "RightUpLeg", "Spine", "LeftLeg", "RightLeg", "Spine1", "LeftFoot", "RightFoot", "Spine2", "LeftToeBase", "RightToeBase", "Neck", "LeftShoulder", "RightShoulder", "Head", "LeftArm", "RightArm", "LeftForeArm", "RightForeArm", "LeftHand", "RightHand"], "thetas": [[[[-3.307560682296753, -7.458465099334717, -2.862720012664795], [-10.753884315490723, -3.0440938472747803, -3.281085252761841], [-13.326932907104492, 0.8010392785072327, -0.3297083377838135], [15.825294494628906, 2.3616085052490234, 1.568211317062378], [22.51706886291504, -8.997729301452637, -1.6200226545333862], [29.694381713867188, 3.9037468433380127, 0.6428393721580505], [0.5535932183265686, -0.2909684181213379, -0.03534752503037453], [-10.80207347869873, 7.384609222412109, 6.325085639953613], [-11.788708686828613, -9.449522972106934, 5.054720401763916], [3.2649831771850586, 1.1041369438171387, -0.1704031229019165], [-8.448753356933594, 10.149137496948242, 1.3978924751281738], [-0.6432614326477051, 6.935351848602295, -10.960977554321289], [3.5422158241271973, 0.9167853593826294, 3.2351505756378174], [-3.937117099761963, -14.294214248657227, -18.098323822021484], [-3.6626083850860596, 19.506986618041992, 17.196060180664062], [12.680249214172363, -5.584395885467529, 1.8425041437149048], [-8.008538246154785, -23.23447036743164, -54.71928024291992], [-6.639284610748291, 23.12957000732422, 51.688297271728516], [8.516545295715332, -23.51087760925293, 6.771971225738525], [0.9425613284111023, 20.66520881652832, -7.8770670890808105], [-4.839034080505371, 0.7779673337936401, 3.873603582382202], [0.3483024835586548, -1.2730381488800049, -2.306227207183838], [-6.248373985290527, -2.050062417984009, -7.059922695159912], [-6.808749675750732, 6.274335861206055, 8.290375709533691]], [[0.06501822918653488, -6.9848713874816895, -2.2278339862823486], [-13.85242748260498, -3.3717191219329834, -3.484144926071167], [-16.701391220092773, 1.3122488260269165, -0.5090197324752808], [9.374979972839355, 3.5384140014648438, 0.3412192463874817], [21.5728702545166, -7.246626853942871, -1.491735577583313], [29.157846450805664, 1.6715418100357056, 1.0013402700424194], [10.499884605407715, -2.7801647186279297, 2.5619819164276123], [-7.203589916229248, 6.917510032653809, 2.9031472206115723], [-8.252998352050781, -8.702200889587402, 1.7949743270874023], [-5.466713905334473, 2.153172254562378, -1.0168358087539673], [-8.763493537902832, 8.914186477661133, 6.703607559204102], [4.750067234039307, 5.196405410766602, -6.454799652099609], [10.460626602172852, 1.0768568515777588, -1.358860969543457], [-6.205836772918701, -13.603507041931152, -19.377592086791992], [-4.6824116706848145, 20.75554847717285, 21.004182815551758], [6.245257377624512, -2.995699644088745, 3.7647016048431396], [-2.86051607131958, -25.730316162109375, -56.019447326660156], [-2.121774435043335, 21.384864807128906, 51.68473434448242], [-7.640747547149658, -21.867828369140625, 0.1126943901181221], [-11.546457290649414, 23.566408157348633, -6.009952068328857], [3.45501708984375, -5.113624572753906, -7.000260353088379], [-3.3655829429626465, 8.47121524810791, 8.780591011047363], [-11.834757804870605, -5.670936107635498, -17.992238998413086], [-7.363576889038086, 6.12604284286499, 16.879703521728516]], [[0.0012860017595812678, -6.78786563873291, -2.2883243560791016], [-13.616021156311035, -3.3485312461853027, -3.4160587787628174], [-17.019678115844727, 1.3937463760375977, -0.5149076581001282], [9.54692268371582, 3.3034415245056152, 0.37510615587234497], [21.88162612915039, -7.251462459564209, -1.7018038034439087], [30.64495277404785, 1.888168454170227, 1.2374300956726074], [10.231825828552246, -2.733103036880493, 2.5390565395355225], [-7.417642593383789, 7.116889476776123, 2.9280214309692383], [-8.362794876098633, -8.723736763000488, 1.9888781309127808], [-5.135660171508789, 1.9904251098632812, -0.9956753253936768], [-9.037849426269531, 8.7643404006958, 7.037436008453369], [4.309589385986328, 5.3679375648498535, -6.775213241577148], [9.959888458251953, 1.2330288887023926, -0.9547227621078491], [-5.773804664611816, -13.424935340881348, -19.68630027770996], [-4.358107089996338, 20.357803344726562, 21.247791290283203], [7.108256816864014, -2.5996460914611816, 3.718989849090576], [-2.7149925231933594, -25.630163192749023, -56.218318939208984], [-1.7773879766464233, 21.582067489624023, 52.2705192565918], [-6.679861068725586, -21.803001403808594, -0.18151193857192993], [-10.852275848388672, 23.212337493896484, -5.6969451904296875], [3.178643226623535, -4.984373092651367, -6.625010013580322], [-3.674543619155884, 8.118311882019043, 8.545434951782227], [-11.975859642028809, -5.554793357849121, -17.843366622924805], [-7.369699001312256, 6.117069721221924, 16.672122955322266]], [[-0.21382758021354675, -6.541026592254639, -2.3510494232177734], [-13.413017272949219, -3.359048366546631, -3.4399197101593018], [-17.557422637939453, 1.4647703170776367, -0.4129980802536011], [9.666953086853027, 3.0389211Line truncated
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1018 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB

@@ -0,0 +1 @@
{"joint_map": ["Hips", "LeftUpLeg", "RightUpLeg", "Spine", "LeftLeg", "RightLeg", "Spine1", "LeftFoot", "RightFoot", "Spine2", "LeftToeBase", "RightToeBase", "Neck", "LeftShoulder", "RightShoulder", "Head", "LeftArm", "RightArm", "LeftForeArm", "RightForeArm", "LeftHand", "RightHand"], "thetas": [[[[-6.229917526245117, -16.710294723510742, 1.7448399066925049], [-24.51107406616211, -3.742011785507202, -1.5558631420135498], [24.220783233642578, -2.9597136974334717, -3.765812873840332], [8.896180152893066, 9.686854362487793, -0.857179582118988], [16.731584548950195, 3.315844774246216, -5.316115856170654], [26.517925262451172, 23.678813934326172, -6.170501232147217], [-0.31458187103271484, 0.14358413219451904, 0.08652734756469727], [-3.1533546447753906, 11.303503036499023, 0.7062103748321533], [8.116186141967773, -0.6171143054962158, 16.611562728881836], [1.1307051181793213, 3.4197962284088135, -2.9880051612854004], [-6.225342750549316, 9.582575798034668, 13.248101234436035], [-10.207061767578125, 8.212409973144531, -13.830078125], [-7.443209171295166, -0.6405114531517029, 8.018325805664062], [5.722445011138916, 9.604071617126465, -35.604087829589844], [-5.49259614944458, 4.51501989364624, 32.57786560058594], [14.01197338104248, -7.659536361694336, -3.4543063640594482], [9.830193519592285, 9.739481925964355, -45.355201721191406], [-5.063714027404785, 22.422441482543945, 41.536930084228516], [-7.899331569671631, -6.705225467681885, 6.161837577819824], [-16.192174911499023, 45.9588737487793, -13.755594253540039], [12.313324928283691, 2.782299041748047, 5.103115081787109], [-2.4862678050994873, 4.299219131469727, -12.546552658081055], [-28.88639259338379, 0.1897139996290207, -25.37077522277832], [-16.35264778137207, 4.350668907165527, 25.489728927612305]], [[-6.8010969161987305, -17.541608810424805, 2.6956686973571777], [-21.571062088012695, -3.8167102336883545, -5.244935512542725], [16.629261016845703, -3.1337571144104004, -5.256000995635986], [9.373148918151855, 8.125935554504395, -1.3181941509246826], [23.463239669799805, 0.7166261076927185, -6.435205459594727], [42.35493087768555, 20.22230339050293, -8.490995407104492], [-0.869960606098175, 1.1572352647781372, -0.3381804823875427], [-5.038776397705078, 10.04051399230957, 5.225789546966553], [23.047929763793945, -0.9740166664123535, 24.731616973876953], [1.3344290256500244, 2.700092315673828, -3.7046403884887695], [-8.277034759521484, 10.986743927001953, 9.557822227478027], [-15.11902141571045, 16.865732192993164, -21.383968353271484], [-9.552935600280762, -2.1539816856384277, 6.793356895446777], [5.849520206451416, 8.347644805908203, -36.07698440551758], [-5.321943759918213, 4.133412837982178, 33.698509216308594], [15.639703750610352, -5.980651378631592, -3.7086920738220215], [6.84581184387207, 8.529241561889648, -44.50084686279297], [-1.6928774118423462, 19.65350341796875, 41.00495910644531], [-8.781744003295898, -7.330596446990967, 5.07875919342041], [-20.210289001464844, 42.4173469543457, -10.078254699707031], [13.555415153503418, 3.943188190460205, 4.814816951751709], [1.7823960781097412, 2.7635083198547363, -11.273374557495117], [-29.429597854614258, -1.2056690454483032, -27.17051887512207], [-17.104284286499023, 4.959829330444336, 27.390371322631836]], [[-7.668184280395508, -16.384374618530273, 3.3536667823791504], [-15.695798873901367, -3.324122905731201, -8.663219451904297], [6.054638385772705, -1.3912627696990967, -4.9416937828063965], [10.770169258117676, 5.225957870483398, -1.5705009698867798], [24.000995635986328, -2.4644315242767334, -5.745731353759766], [60.161624908447266, 14.879158973693848, -8.766509056091309], [-1.4136160612106323, 1.7536824941635132, -0.3740008771419525], [-9.965216636657715, 9.281323432922363, 10.492945671081543], [27.475427627563477, -4.548601150512695, 27.725473403930664], [1.591251254081726, 1.2965033054351807, -4.045331954956055], [-8.67846393585205, 12.32140827178955, 5.378384590148926], [-16.405649185180664, 22.58989715576172, -24.255285263061523], [-11.229399681091309, -2.8200557231903076, 6.48445987701416], [5.2178144454956055, 5.572815418243408, -36.64863586425781], [-5.461309909820557, 4.342429161071777, 35.04185485839844], [16.90372657775879, -5.552309036254883, -4.322893142700195], [3.7547996044158936, 5.2675461769104, -44.407474517822266], [1.304233431816101, 17.15964126586914, 41.418209075927734], [-8.06013011932373, -8.121492385864258, 4.347626209259033], [-21.712770462036133, 37.040645599365234, -8.55474853515625], [14.088446617126465, 4.95542573928833, 3.6903836727142334], [4.854328155517578, 1.3287214040756226, -8.85655403137207], [-28.438066482543945, -2.5783495903015137, -25.98659896850586], [-16.083620071411133, 5.7041521072387695, 26.165109634399414]], [[-6.892439365386963, -12.826958656311035, 3.545560836791992], [-10.700249671936035, -3.2892112731933594, -10.51524829864502], [-5.90322732925415, -0.20282500982284546, -3.58681583404541], [8.594566345214844, 1.7748154401779175, -1.6065592765808105], [2Line truncated
+478
View File
@@ -0,0 +1,478 @@
//! Example 01. Simple scene.
//!
//! Difficulty: Easy.
//!
//! This example shows how to create simple scene with animated model.
use fyrox::{
core::{
algebra::{Matrix4, UnitQuaternion, Vector3},
color::Color,
pool::Handle,
sstorage::ImmutableString,
},
engine::{
executor::Executor, resource_manager::ResourceManager, GraphicsContextParams, GraphicsContext,
},
event::{ElementState, Event, VirtualKeyCode, WindowEvent},
event_loop::ControlFlow,
gui::{
message::MessageDirection,
text::{TextBuilder, TextMessage},
widget::WidgetBuilder,
UiNode,
},
material::{shader::SamplerFallback, Material, PropertyValue, SharedMaterial},
plugin::{Plugin, PluginConstructor, PluginContext},
scene::{
base::BaseBuilder,
light::{point::PointLightBuilder, BaseLightBuilder},
mesh::{
surface::{SurfaceBuilder, SurfaceData, SurfaceSharedData},
MeshBuilder,
},
node::Node,
transform::TransformBuilder,
Scene, graph::Graph, camera::{SkyBoxBuilder, CameraBuilder}, sound::listener::ListenerBuilder,
}, resource::texture::TextureWrapMode, window::WindowAttributes,
};
struct GameSceneLoader {
scene: Scene,
model_handle: Handle<Node>,
}
impl GameSceneLoader {
async fn load_with(resource_manager: ResourceManager) -> Self {
let mut scene = Scene::new();
// Set ambient light.
scene.ambient_lighting_color = Color::opaque(200, 200, 200);
// Camera is our eyes in the world - you won't see anything without it.
create_camera(
resource_manager.clone(),
Vector3::new(0.0, 6.0, -15.0),
&mut scene.graph,
)
.await;
// Add some light.
PointLightBuilder::new(BaseLightBuilder::new(
BaseBuilder::new().with_local_transform(
TransformBuilder::new()
.with_local_position(Vector3::new(0.0, 12.0, 0.0))
.build(),
),
))
.with_radius(20.0)
.build(&mut scene.graph);
// Load model and animation resource in parallel. Is does *not* adds anything to
// our scene - it just loads a resource then can be used later on to instantiate
// models from it on scene. Why loading of resource is separated from instantiation?
// Because it is too inefficient to load a resource every time you trying to
// create instance of it - much more efficient is to load it once and then make copies
// of it. In case of models it is very efficient because single vertex and index buffer
// can be used for all models instances, so memory footprint on GPU will be lower.
let model_resource = resource_manager.request_model("data/Roko.fbx").await.unwrap();
// Instantiate model on scene - but only geometry, without any animations.
// Instantiation is a process of embedding model resource data in desired scene.
let model_handle = model_resource.instantiate(&mut scene);
// Now we have whole sub-graph instantiated, we can start modifying model instance.
scene.graph[model_handle]
.local_transform_mut()
// Our model is too big, fix it by scale.
.set_scale(Vector3::new(0.05, 0.05, 0.05))
.set_rotation(UnitQuaternion::from_axis_angle(&Vector3::x_axis(), -90.0f32.to_radians()));
let mut material = Material::standard();
material
.set_property(
&ImmutableString::new("diffuseTexture"),
PropertyValue::Sampler {
value: Some(resource_manager.request_texture("data/concrete2.dds")),
fallback: SamplerFallback::White,
},
)
.unwrap();
// Add floor.
MeshBuilder::new(
BaseBuilder::new().with_local_transform(
TransformBuilder::new()
.with_local_position(Vector3::new(0.0, -1.25, 0.0))
.build(),
),
)
.with_surfaces(vec![SurfaceBuilder::new(SurfaceSharedData::new(
SurfaceData::make_cube(Matrix4::new_nonuniform_scaling(&Vector3::new(
25.0, 0.25, 25.0,
))),
))
.with_material(SharedMaterial::new(material))
.build()])
.build(&mut scene.graph);
Self {
scene,
model_handle,
}
}
}
struct InputController {
rotate_left: bool,
rotate_right: bool,
}
use serde::Deserialize;
use ndarray::prelude::*;
#[derive(Deserialize, Debug)]
struct AnimationJson {
joint_map: Vec<String>,
thetas: Vec<Vec<Vec<Vec<f32>>>>,
root_translation: Vec<Vec<Vec<f32>>>,
}
#[derive(Debug)]
struct AnimationNdarray {
joint_map: Vec<String>,
thetas: Array4<f32>,
root_translation: Array3<f32>
}
use ndarray::s;
struct Game {
scene: Handle<Scene>,
model_handle: Handle<Node>,
input_controller: InputController,
debug_text: Handle<UiNode>,
model_angle: f32,
animation_frame: usize,
animation_ndarray: AnimationNdarray,
}
impl Plugin for Game {
fn update(&mut self, context: &mut PluginContext, _control_flow: &mut ControlFlow) {
let scene = &mut context.scenes[self.scene];
// Rotate model according to input controller state
if self.input_controller.rotate_left {
self.model_angle -= 5.0f32.to_radians();
} else if self.input_controller.rotate_right {
self.model_angle += 5.0f32.to_radians();
}
let joint_map = vec![
"DEF-spine",
"DEF-thigh.L",
"DEF-thigh.R",
"DEF-spine.001",
"DEF-shin.L",
"DEF-shin.R",
"DEF-spine.002",
"DEF-foot.L",
"DEF-foot.R",
"DEF-spine.003",
"DEF-toe.L",
"DEF-toe.R",
"DEF-spine.004",
"DEF-shoulder.L",
"DEF-shoulder.R",
"DEF-spine.006",
"DEF-upper_arm.L",
"DEF-upper_arm.R",
"DEF-forearm.L",
"DEF-forearm.R",
"DEF-hand.L",
"DEF-hand.R"
];
for joint_index in 0..joint_map.len() {
let bone_handle = scene.graph.find_by_name_from_root(joint_map[joint_index]).unwrap().0;
let bone_node = &mut scene.graph[bone_handle];
let transform = bone_node.local_transform_mut();
let axes_rotations = self.animation_ndarray.thetas.slice(s![0, self.animation_frame, joint_index, 0..3usize]);
// default bones - just apply the rotations raw
transform.set_rotation(
UnitQuaternion::from_axis_angle(&Vector3::x_axis(), axes_rotations[0usize].to_radians()) *
UnitQuaternion::from_axis_angle(&Vector3::y_axis(), axes_rotations[1usize].to_radians()) *
UnitQuaternion::from_axis_angle(&Vector3::z_axis(), axes_rotations[2usize].to_radians())
);
// Spine - needs an offset otherwise the model floats diagonally in the air
if joint_index == 0 {
transform.set_rotation(
UnitQuaternion::from_axis_angle(&Vector3::x_axis(), axes_rotations[0usize].to_radians()+1.5) *
UnitQuaternion::from_axis_angle(&Vector3::y_axis(), axes_rotations[1usize].to_radians()) *
UnitQuaternion::from_axis_angle(&Vector3::z_axis(), axes_rotations[2usize].to_radians())
);
}
// Left thigh - needs offset to not be rotated toward the head, and inverted axis to move the correct
// direction
if joint_index == 1 {
transform.set_rotation(
UnitQuaternion::from_axis_angle(&Vector3::x_axis(), axes_rotations[0usize].to_radians()+3.14) *
UnitQuaternion::from_axis_angle(&Vector3::y_axis(), axes_rotations[1usize].to_radians()) *
UnitQuaternion::from_axis_angle(&Vector3::z_axis(), (-1.0*(axes_rotations[2usize]+5.0)).to_radians())
);
}
// Right thigh - needs offset to not be rotated toward the head, and inverted axis to move the correct
// direction
if joint_index == 2 {
transform.set_rotation(
UnitQuaternion::from_axis_angle(&Vector3::x_axis(), axes_rotations[0usize].to_radians()+3.14) *
UnitQuaternion::from_axis_angle(&Vector3::y_axis(), axes_rotations[1usize].to_radians()) *
UnitQuaternion::from_axis_angle(&Vector3::z_axis(), (-1.0*(axes_rotations[2usize]-5.0)).to_radians())
);
}
// Left Foot
if joint_index == 7 {
transform.set_rotation(
UnitQuaternion::from_axis_angle(&Vector3::x_axis(), (axes_rotations[0usize]-90.0).to_radians()) *
UnitQuaternion::from_axis_angle(&Vector3::y_axis(), (axes_rotations[1usize]-160.0).to_radians()) *
UnitQuaternion::from_axis_angle(&Vector3::z_axis(), axes_rotations[2usize].to_radians())
);
}
// Right foot
if joint_index == 8 {
transform.set_rotation(
UnitQuaternion::from_axis_angle(&Vector3::x_axis(), (axes_rotations[0usize]-90.0).to_radians()) *
UnitQuaternion::from_axis_angle(&Vector3::y_axis(), (axes_rotations[1usize]-160.0).to_radians()) *
UnitQuaternion::from_axis_angle(&Vector3::z_axis(), axes_rotations[2usize].to_radians())
);
}
// Left Toe
if joint_index == 10 {
transform.set_rotation(
UnitQuaternion::from_axis_angle(&Vector3::x_axis(), (axes_rotations[0usize]).to_radians()) *
UnitQuaternion::from_axis_angle(&Vector3::y_axis(), (axes_rotations[1usize]-180.0).to_radians()) *
UnitQuaternion::from_axis_angle(&Vector3::z_axis(), (axes_rotations[2usize]).to_radians())
);
}
// Right Toe
if joint_index == 11 {
transform.set_rotation(
UnitQuaternion::from_axis_angle(&Vector3::x_axis(), (axes_rotations[0usize]).to_radians()) *
UnitQuaternion::from_axis_angle(&Vector3::y_axis(), (axes_rotations[1usize]+180.0).to_radians()) *
UnitQuaternion::from_axis_angle(&Vector3::z_axis(), (axes_rotations[2usize]).to_radians())
);
}
// Left Shoulder - offset from T-pose to resting by the side
if joint_index == 13 {
transform.set_rotation(
UnitQuaternion::from_axis_angle(&Vector3::x_axis(), axes_rotations[0usize].to_radians()) *
UnitQuaternion::from_axis_angle(&Vector3::y_axis(), axes_rotations[1usize].to_radians()) *
UnitQuaternion::from_axis_angle(&Vector3::z_axis(), (axes_rotations[2usize]-80.0).to_radians())
);
}
// Right Shoulder - offset from T-pose to resting by the side
if joint_index == 14 {
transform.set_rotation(
UnitQuaternion::from_axis_angle(&Vector3::x_axis(), axes_rotations[0usize].to_radians()) *
UnitQuaternion::from_axis_angle(&Vector3::y_axis(), axes_rotations[1usize].to_radians()) *
UnitQuaternion::from_axis_angle(&Vector3::z_axis(), (axes_rotations[2usize]+80.0).to_radians())
);
}
}
let root_handle = self.model_handle;
let bone_node = &mut scene.graph[root_handle];
let transform = bone_node.local_transform_mut();
let xyz = self.animation_ndarray.root_translation.slice(s![0,self.animation_frame, 0..3usize]);
transform.set_position(Vector3::new(-xyz[0usize], xyz[1usize], -xyz[2usize]));
self.animation_frame += 1;
if self.animation_frame >= 120 {
self.animation_frame = 0;
};
scene.graph[self.model_handle]
.local_transform_mut()
.set_rotation(UnitQuaternion::from_axis_angle(&Vector3::x_axis(), -90.0) * UnitQuaternion::from_axis_angle(
&Vector3::z_axis(),
self.model_angle,
));
if let GraphicsContext::Initialized(ref graphics_context) = context.graphics_context {
context.user_interface.send_message(TextMessage::text(
self.debug_text,
MessageDirection::ToWidget,
format!(
"Storyteller Animation Viewer\nUse [A][D] keys to rotate model.\nFPS: {}",
graphics_context.renderer.get_statistics().frames_per_second
),
));
}
}
fn on_os_event(
&mut self,
event: &Event<()>,
_context: PluginContext,
_control_flow: &mut ControlFlow,
) {
if let Event::WindowEvent {
event: WindowEvent::KeyboardInput { input, .. },
..
} = event
{
if let Some(key_code) = input.virtual_keycode {
match key_code {
VirtualKeyCode::A => {
self.input_controller.rotate_left = input.state == ElementState::Pressed
}
VirtualKeyCode::D => {
self.input_controller.rotate_right = input.state == ElementState::Pressed
}
_ => (),
}
}
}
}
}
struct GameConstructor;
impl PluginConstructor for GameConstructor {
fn create_instance(
&self,
_override_scene: Handle<Scene>,
context: PluginContext,
) -> Box<dyn Plugin> {
let scene = fyrox::core::futures::executor::block_on(GameSceneLoader::load_with(
context.resource_manager.clone(),
));
let json = std::fs::read_to_string("data/jumping-jacks.json").unwrap();
let v: AnimationJson = serde_json::from_str(&json).unwrap();
let thetas_shape = [v.thetas.len(), v.thetas[0].len(), v.thetas[0][0].len(), v.thetas[0][0][0].len()];
let thetas_flat = v.thetas.iter().flatten().flatten().flatten().map(|f| *f).collect();
let thetas_ndarray = Array4::from_shape_vec(thetas_shape, thetas_flat).unwrap();
let translations_shape = [v.root_translation.len(), v.root_translation[0].len(), v.root_translation[0][0].len()];
let translations_flat = v.root_translation.iter().flatten().flatten().map(|f| *f).collect();
let translations_ndarray = Array3::from_shape_vec(translations_shape, translations_flat).unwrap();
let animation_ndarray = AnimationNdarray {
joint_map: v.joint_map,
thetas: thetas_ndarray,
root_translation: translations_ndarray
};
Box::new(Game {
debug_text: TextBuilder::new(WidgetBuilder::new())
.build(&mut context.user_interface.build_ctx()),
scene: context.scenes.add(scene.scene),
model_handle: scene.model_handle,
// Create input controller - it will hold information about needed actions.
input_controller: InputController {
rotate_left: false,
rotate_right: false,
},
// We will rotate model using keyboard input.
model_angle: 180.0f32.to_radians(),
animation_frame: 0,
animation_ndarray,
})
}
}
fn main() {
let mut executor = Executor::from_params(
Default::default(),
GraphicsContextParams {
window_attributes: WindowAttributes {
title: "Storyteller Animation Viewer".to_string(),
..Default::default()
},
vsync: true,
},
);
executor.add_plugin_constructor(GameConstructor);
executor.set_desired_update_rate(24.0);
executor.run()
}
/// Creates a camera at given position with a skybox.
pub async fn create_camera(
resource_manager: ResourceManager,
position: Vector3<f32>,
graph: &mut Graph,
) -> Handle<Node> {
// Load skybox textures in parallel.
let (front, back, left, right, top, bottom) = fyrox::core::futures::join!(
resource_manager
.request_texture("data/skyboxes/DarkStormy/DarkStormyFront2048.png"),
resource_manager
.request_texture("data/skyboxes/DarkStormy/DarkStormyBack2048.png"),
resource_manager
.request_texture("data/skyboxes/DarkStormy/DarkStormyLeft2048.png"),
resource_manager
.request_texture("data/skyboxes/DarkStormy/DarkStormyRight2048.png"),
resource_manager.request_texture("data/skyboxes/DarkStormy/DarkStormyUp2048.png"),
resource_manager
.request_texture("data/skyboxes/DarkStormy/DarkStormyDown2048.png")
);
// Unwrap everything.
let skybox = SkyBoxBuilder {
front: Some(front.unwrap()),
back: Some(back.unwrap()),
left: Some(left.unwrap()),
right: Some(right.unwrap()),
top: Some(top.unwrap()),
bottom: Some(bottom.unwrap()),
}
.build()
.unwrap();
// Set S and T coordinate wrap mode, ClampToEdge will remove any possible seams on edges
// of the skybox.
if let Some(cubemap) = skybox.cubemap() {
let mut data = cubemap.data_ref();
data.set_s_wrap_mode(TextureWrapMode::ClampToEdge);
data.set_t_wrap_mode(TextureWrapMode::ClampToEdge);
}
// Camera is our eyes in the world - you won't see anything without it.
CameraBuilder::new(
BaseBuilder::new()
.with_local_transform(
TransformBuilder::new()
.with_local_position(position)
.build(),
)
.with_children(&[
// Create sound listener, otherwise we'd heat sound as if we'd be in (0,0,0)
ListenerBuilder::new(BaseBuilder::new()).build(graph),
]),
)
.with_skybox(skybox)
.build(graph)
}