Download common.py from DenSnoychik/SonnetMakingNewRobloxRig: direct link, hf CLI and curl.
- Browser
- Download file 1.44 kB
-
https://huggingface.co/datasets/DenSnoychik/SonnetMakingNewRobloxRig/resolve/main/common.py
- Command line
-
hf download hf://datasets/DenSnoychik/SonnetMakingNewRobloxRig/common.py
-
curl -L -o common.py https://huggingface.co/datasets/DenSnoychik/SonnetMakingNewRobloxRig/resolve/main/common.py
1.44 kB
| import numpy as np | |
| from refload import load_ref, load_mesh | |
| PART_ORDER=['Head','UpperTorso','LowerTorso','LeftUpperArm','LeftLowerArm','LeftHand','RightUpperArm','RightLowerArm','RightHand','LeftUpperLeg','LeftLowerLeg','LeftFoot','RightUpperLeg','RightLowerLeg','RightFoot'] | |
| HEAD_CENTER=np.array([0,1.0+0.471,0.0]) | |
| def ref_world(): | |
| ref=load_ref(); out={} | |
| for n,d in ref.items(): | |
| V=d['Vl']@d['R'].T+d['t'] | |
| att={a:(np.array(R),np.array(p)) for a,(R,p) in d['att'].items()} | |
| out[n]=dict(V=V,F=d['F'],R=d['R'],t=d['t'],att=att) | |
| pos,nor,F=load_mesh('ref/head.mesh') | |
| headatt={'FaceCenterAttachment':(0,0,0),'FaceFrontAttachment':(0,0,-0.5652000308036804),'HairAttachment':(0,0.5652000308036804,0),'HatAttachment':(0,0.5652000308036804,0),'NeckRigAttachment':(0,-0.47099998593330383,0)} | |
| out['Head']=dict(V=pos+HEAD_CENTER,F=F,R=np.eye(3),t=HEAD_CENTER,att={k:(np.eye(3),np.array(v)) for k,v in headatt.items()}) | |
| return out | |
| def load_src(path='src/base.obj'): | |
| V=[];G={};cur=None | |
| for l in open(path): | |
| if l.startswith('v '): V.append(list(map(float,l.split()[1:4]))) | |
| elif l.startswith('g '): cur=l.split()[1]; G[cur]=[] | |
| elif l.startswith('f '): G[cur].append([int(t.split('/')[0])-1 for t in l.split()[1:]]) | |
| return np.array(V),G | |
| def quads_to_tris(q): | |
| out=[] | |
| for f in q: | |
| for i in range(1,len(f)-1): out.append([f[0],f[i],f[i+1]]) | |
| return np.array(out) | |