Skip to content

Instantly share code, notes, and snippets.

@mattysmith22
Last active February 24, 2021 17:16
Show Gist options
  • Save mattysmith22/c73cee4fce6130011af232a5e7443ab1 to your computer and use it in GitHub Desktop.
Save mattysmith22/c73cee4fce6130011af232a5e7443ab1 to your computer and use it in GitHub Desktop.

Skeleton Bone Viewer

This is a small script that will graph out the tree structure showing how bones in a model are ordered, showing children. I found it useful for finding a bug in how my bones were ordered.

Installation

You must have the following things installed

  • Python 3
  • The Pyvis library (can be installed with pip install pyvis)

Usage

  1. Copy the skeletonBones[] array across to the bonesRaw variable array. Comments / preprocessor commands etc. aren't allowed, it just has to be basic strings. The skeleton for the apache mod is there as an example.
  2. Run the program, the graph should have popped up in the browser and if not it is in the autogenerated file out.html
import pyvis
bonesRaw = ["velka vrtule","","blade1", "velka vrtule", "blade1_rise1","blade1", "velka vrtule", "blade1","blade1_rise2","blade1","blade1_rise3","blade1","blade1_rise4","blade1","blade1_rise5","blade1","blade2","velka vrtule","blade2_rise1","blade2","blade2_rise2","blade2","blade2_rise3","blade2","blade2_rise4","blade2","blade2_rise5","blade2","blade3","velka vrtule","blade3_rise1","blade3","blade3_rise2","blade3","blade3_rise3","blade3","blade3_rise4","blade3","blade3_rise5","blade3","blade4","velka vrtule","blade4_rise1","blade4","blade4_rise2","blade4","blade4_rise3","blade4","blade4_rise4","blade4","blade4_rise5","blade4","swashplate_up","","swup_arm1","swashplate_up","swup_arm2","velka vrtule","swup_arm3","swashplate_up","swup_arm4","velka vrtule","swashplate_dn","","mr_act","","skin_fcr","","longbow","skin_fcr","mala vrtule","","tr_blade1","mala vrtule","tr_blade2","mala vrtule","tr_blade3","mala vrtule","tr_blade4","mala vrtule","tr_swashplate","mala vrtule","otocvez","","otochlaven","otocvez","gun_rec","otochlaven","pylon_pivot_1","","pylon_pivot_2","","pylon_pivot_3","","pylon_pivot_4","","tads_tur","","tads","tads_tur","pnvs","","pnvs_vert","pnvs","maingear","","mg_piston","","twsus","","tw_castor","twsus","tailwheel","tw_castor","hstab","","mainwheels","maingear","pdoor","","gdoor","","l_ads","","r_ads","","plt_compass_1","","plt_horizon_1","","plt_horbank_1","","plt_spd_1","","plt_baroalt_1","","plt_baroalt_tens","","plt_baroalt_huns","","plt_baroalt_thsn","","plt_baroalt_tths","","plt_rtrbrake","","plt_anticollision","","plt_firesw","","cpg_firesw","","plt_eng1_start","","plt_eng2_start","","plt_eng1_throttle","","plt_eng2_throttle","","mpd_pl_obj1","","mpd_pl_obj2","","mpd_pl_obj3","","mpd_pl_obj4","","mpd_pl_obj5","","mpd_pl_obj6","","mpd_pl_obj7","","mpd_pl_obj8","","mpd_pl_obj9","","mpd_pl_obj10","","mpd_pl_obj11","","mpd_pl_obj12","","mpd_pl_obj13","","mpd_pl_obj14","","mpd_pl_obj15","","mpd_pl_obj16","","mpd_pl_obj17","","mpd_pl_obj18","","mpd_pl_obj19","","mpd_pl_obj20","","mpd_pl_obj21","","mpd_pl_obj22","","mpd_pl_obj23","","mpd_pl_obj24","","mpd_pl_obj25","","mpd_pl_obj26","","mpd_pl_obj27","","mpd_pl_obj28","","mpd_pl_obj29","","mpd_pl_obj30","","mpd_pl_obj31","","mpd_pl_obj32","","mpd_pr_tsd_mmap","","mpd_pr_tsd_mmap_s1","mpd_pr_tsd_mmap","mpd_pr_tsd_mmap_s2","mpd_pr_tsd_mmap_s1","mpd_pr_tsd_mmap_s3","mpd_pr_tsd_mmap","mpd_pr_flt_raltm","","mpd_pr_flt_vsi","","mpd_pr_flt_bank","","mpd_pr_flt_hor","","mpd_pr_flt_hdg","","mpd_pr_flt_hdg2","","mpd_pr_flt_rdr","","mpd_pr_flt_wbear","","mpd_pr_flt_wp","","mpd_pr_flt_slip","","mpd_pr_flt_turn","","mpd_pr_flt_vvi","","mpd_pr_eng_ltrqbar","","mpd_pr_eng_1tgt","","mpd_pr_eng_e1trq","","mpd_pr_eng_e1np","","mpd_pr_eng_2tgt","","mpd_pr_eng_e2trq","","mpd_pr_eng_e2np","","mpd_pr_eng_rtrrpm","","mpd_pl_flt_raltm","","mpd_pl_flt_vsi","","mpd_pl_flt_bank","","mpd_pl_flt_hor","","mpd_pl_flt_hdg","","mpd_pl_flt_hdg2","","mpd_pl_flt_rdr","","mpd_pl_flt_wbear","","mpd_pl_flt_wp","","mpd_pl_flt_slip","","mpd_pl_flt_turn","","mpd_pl_flt_vvi","","mpd_gr_obj1","","mpd_gr_obj2","","mpd_gr_obj3","","mpd_gr_obj4","","mpd_gr_obj5","","mpd_gr_obj6","","mpd_gr_obj7","","mpd_gr_obj8","","mpd_gr_obj9","","mpd_gr_obj10","","mpd_gr_obj11","","mpd_gr_obj12","","mpd_gr_obj13","","mpd_gr_obj14","","mpd_gr_obj15","","mpd_gr_obj16","","mpd_gr_obj17","","mpd_gr_obj18","","mpd_gr_obj19","","mpd_gr_obj20","","mpd_gr_obj21","","mpd_gr_obj22","","mpd_gr_obj23","","mpd_gr_obj24","","mpd_gr_obj25","","mpd_gr_obj26","","mpd_gr_obj27","","mpd_gr_obj28","","mpd_gr_obj29","","mpd_gr_obj30","","mpd_gr_obj31","","mpd_gr_obj32","","mpd_gr_tsd_mmap","","mpd_gr_tsd_mmap_s1","mpd_gr_tsd_mmap","mpd_gr_tsd_mmap_s2","mpd_gr_tsd_mmap_s1","mpd_gr_tsd_mmap_s3","mpd_gr_tsd_mmap","mpd_pr_fcraa_wiper","","mpd_pr_fcrag_wiper","","mpd_pr_mpd_had_apos","","mpd_pr_mpd_had_apos2","","p_cyclic","","p_collective","","plt_nvsmode","","cpg_nvsmode","","plt_batt","","plt_apu","","cpg_ihadss_brt","","hydra_m261_001","pylon_pivot_1","hydra_m261_002","pylon_pivot_2","hydra_m261_003","pylon_pivot_3","hydra_m261_004","pylon_pivot_4","rail_m299_001","pylon_pivot_1","rail_m299_002","pylon_pivot_2","rail_m299_003","pylon_pivot_3","rail_m299_004","pylon_pivot_4"]
def chunk(xs, n):
n = max(1, n)
return (xs[i:i+n] for i in range(0, len(xs), n))
nt = pyvis.network.Network(directed=True, height="100%", width="100%");
nt.show_buttons()
for bone in set(bonesRaw):
nt.add_node(bone, mass=3, size=10, label=bone)
for relation in chunk(bonesRaw, 2):
print(len(relation))
assert(len(relation) == 2)
newBone = relation[0]
parentBone = relation[1]
nt.add_edge(parentBone, newBone)
nt.show("out.html")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment