Preserve initial outfit review and tested heel-safe gait for reference revision
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
"""Encode the exact frame ranges; ignore older surplus capture frames."""
|
||||
from pathlib import Path
|
||||
import argparse
|
||||
import subprocess
|
||||
|
||||
parser=argparse.ArgumentParser()
|
||||
parser.add_argument('--ffmpeg',required=True)
|
||||
args=parser.parse_args()
|
||||
root=Path(__file__).resolve().parent.parent
|
||||
project=root/'Demon_v0.19'
|
||||
out=project/'reviews/heels_v01'
|
||||
for sequence,count,name in [('full',72,'walking'),('feet',48,'boots'),('outfit',96,'outfit')]:
|
||||
subprocess.run([args.ffmpeg,'-hide_banner','-loglevel','error','-y','-framerate','24',
|
||||
'-i',str(project/'captures/heels-v01'/sequence/'%03d.png'),
|
||||
'-filter_complex','[0:v]scale=1120:-1:flags=lanczos,split[a][b];[a]palettegen=max_colors=192[p];[b][p]paletteuse=dither=sierra2_4a',
|
||||
'-frames:v',str(count),'-loop','0',str(out/(name+'.gif'))],check=True)
|
||||
print(name,count,'frames',flush=True)
|
||||
@@ -0,0 +1,188 @@
|
||||
"""Build an approval-only shoe revision; keep the production GLB unchanged."""
|
||||
from pathlib import Path
|
||||
import copy
|
||||
import json
|
||||
import struct
|
||||
import numpy as np
|
||||
|
||||
root = Path(__file__).resolve().parent.parent
|
||||
source = root / 'Demon_v0.19/art/succubus/succubus_v02.glb'
|
||||
target = root / 'Demon_v0.19/reviews/heels_v01/succubus_heels.glb'
|
||||
raw = source.read_bytes()
|
||||
length = struct.unpack_from('<I', raw, 12)[0]
|
||||
doc = json.loads(raw[20:20+length])
|
||||
blob = bytearray(raw[28+length:])
|
||||
types = {5126:'<f4', 5125:'<u4', 5123:'<u2', 5121:'u1'}
|
||||
sizes = {'SCALAR':1, 'VEC2':2, 'VEC3':3, 'VEC4':4, 'MAT4':16}
|
||||
def read(i):
|
||||
a = doc['accessors'][i]; v = doc['bufferViews'][a['bufferView']]
|
||||
return np.frombuffer(blob, types[a['componentType']], a['count']*sizes[a['type']],
|
||||
v.get('byteOffset',0)+a.get('byteOffset',0)).reshape(-1,sizes[a['type']]).copy()
|
||||
def accessor(data, kind, component=5126):
|
||||
data = np.asarray(data,dtype=types[component]); blob.extend(b'\0'*((-len(blob))%4))
|
||||
offset=len(blob); blob.extend(data.tobytes()); view=len(doc['bufferViews'])
|
||||
doc['bufferViews'].append({'buffer':0,'byteOffset':offset,'byteLength':data.nbytes})
|
||||
a={'bufferView':view,'componentType':component,'count':len(data),'type':kind}
|
||||
if kind=='VEC3': a.update(min=data.min(axis=0).tolist(),max=data.max(axis=0).tolist())
|
||||
doc['accessors'].append(a); return len(doc['accessors'])-1
|
||||
|
||||
joints = doc['skins'][0]['joints']
|
||||
foot_ids = {side:joints.index(next(i for i,n in enumerate(doc['nodes']) if n.get('name')=='foot.'+side)) for side in ['L','R']}
|
||||
# Move the anatomical ankle above the raised heel, and rebind only these joints.
|
||||
# Merely raising shoe vertices leaves a bare-foot ankle pivot inside the heel.
|
||||
inverse=read(doc['skins'][0]['inverseBindMatrices']).reshape(-1,4,4).transpose(0,2,1)
|
||||
bind=np.linalg.inv(inverse);parents={child:i for i,node in enumerate(doc['nodes']) for child in node.get('children',[])}
|
||||
joint_map={node:i for i,node in enumerate(joints)};translation_delta={}
|
||||
for side in ['L','R']:
|
||||
joint=foot_ids[side];node=joints[joint];parent=parents[node]
|
||||
delta=np.linalg.inv(bind[joint_map[parent],:3,:3])@np.array([0,.080,0])
|
||||
doc['nodes'][node]['translation']=(np.array(doc['nodes'][node]['translation'])+delta).tolist();translation_delta[node]=delta
|
||||
new_bind=bind[joint].copy();new_bind[1,3]+=.080
|
||||
for child in doc['nodes'][node].get('children',[]):
|
||||
if child not in joint_map:continue
|
||||
local_bind=np.linalg.inv(new_bind)@bind[joint_map[child]]
|
||||
old=np.array(doc['nodes'][child]['translation']);translation_delta[child]=local_bind[:3,3]-old
|
||||
doc['nodes'][child]['translation']=local_bind[:3,3].tolist()
|
||||
inverse[joint]=np.linalg.inv(new_bind)
|
||||
doc['skins'][0]['inverseBindMatrices']=accessor(inverse.transpose(0,2,1).reshape(-1,16),'MAT4')
|
||||
for animation in doc.get('animations',[]):
|
||||
for channel in animation['channels']:
|
||||
target_node=channel['target'].get('node')
|
||||
if channel['target']['path']!='translation' or target_node not in translation_delta:continue
|
||||
sampler=animation['samplers'][channel['sampler']]
|
||||
sampler['output']=accessor(read(sampler['output'])+translation_delta[target_node],'VEC3')
|
||||
initial=copy.deepcopy(doc['meshes'][1]['primitives'][:-2]) # Replace the old open-ended heel columns.
|
||||
primitives=[]
|
||||
wing_ids=[joints.index(next(i for i,n in enumerate(doc['nodes']) if n.get('name')=='Wing.'+side)) for side in ['L','R']]
|
||||
doc['materials'][17]['pbrMetallicRoughness'].update(baseColorFactor=[.012,.014,.017,1],metallicFactor=.04,roughnessFactor=.27)
|
||||
sole_material=len(doc['materials'])
|
||||
doc['materials'].append({'name':'Dark tan outsole edge','pbrMetallicRoughness':{'baseColorFactor':[.15,.105,.065,1],'roughnessFactor':.62}})
|
||||
for p in initial:
|
||||
attr=p['attributes']; v=read(attr['POSITION'])
|
||||
if not {'JOINTS_0','WEIGHTS_0'}<=attr.keys():continue
|
||||
j=read(attr['JOINTS_0']); w=read(attr['WEIGHTS_0'])
|
||||
faces=read(p['indices']).reshape(-1,3).astype(np.int64)
|
||||
old_wing=(np.isin(j,wing_ids)*w).sum(axis=1)>.25
|
||||
faces=faces[~old_wing[faces].any(axis=1)]
|
||||
if p['material'] in [0,4,10]:
|
||||
center=v[faces].mean(axis=1);x=center[:,0]
|
||||
cup_top=1.313-.060*np.exp(-(x/.037)**2)+.018*np.exp(-((np.abs(x)-.105)/.055)**2)
|
||||
trim=(center[:,1]>cup_top)&(center[:,1]<1.385)&(center[:,2]>.07)&(np.abs(x)<.225)
|
||||
faces=faces[~trim]
|
||||
if p['material']==3:
|
||||
arm_ids=[k for k,node in enumerate(joints) if 'arm' in doc['nodes'][node].get('name','')]
|
||||
arm=(np.isin(j,arm_ids)*w).sum(axis=1)>.30
|
||||
faces=faces[~arm[faces].any(axis=1)]
|
||||
faces=faces[v[faces].mean(axis=1)[:,1]>1.045]
|
||||
if p['material'] in [4,10]:
|
||||
center=v[faces].mean(axis=1)
|
||||
faces=faces[~((center[:,1]>.12)&(center[:,1]<.74)&(np.abs(center[:,0])<.30))]
|
||||
if not len(faces):continue
|
||||
p['indices']=accessor(faces.reshape(-1,1),'SCALAR',5125)
|
||||
if p['material'] in [0,1,10,16,17]:
|
||||
mask=(v[:,1]<.17)&(v[:,2]>.09)&(np.abs(v[:,0])<.3)
|
||||
t=np.clip((v[mask,2]-.09)/.15,0,1)
|
||||
center=np.sign(v[mask,0])*.1745
|
||||
v[mask,0]=center+(v[mask,0]-center)*(1-.78*t*t)
|
||||
v[mask,2]+=.046*t*t
|
||||
foot=(v[:,1]<.145)&(np.abs(v[:,0])<.3)
|
||||
bottom=np.interp(v[foot,2],[-.06,-.025,.025,.080,.135,.190,.230,.285],[.105,.107,.091,.050,.013,.008,.010,.015])
|
||||
v[foot,1]=np.maximum(v[foot,1],bottom+.015)
|
||||
attr['POSITION']=accessor(v,'VEC3')
|
||||
faces=read(p['indices']).reshape(-1,3).astype(np.int64)
|
||||
normal=np.zeros_like(v);cross=np.cross(v[faces[:,1]]-v[faces[:,0]],v[faces[:,2]]-v[faces[:,0]])
|
||||
for k in range(3):np.add.at(normal,faces[:,k],cross)
|
||||
normal/=np.maximum(np.linalg.norm(normal,axis=1,keepdims=True),1e-12)
|
||||
attr['NORMAL']=accessor(normal,'VEC3');attr.pop('TANGENT',None)
|
||||
for i in np.flatnonzero((v[:,1]<.14)&(np.abs(v[:,0])<.30)):
|
||||
side='L' if v[i,0]>0 else 'R'; foot=foot_ids[side]
|
||||
# Shoes must not flex with the toes: a stiletto and sole are one rigid piece.
|
||||
if v[i,1]<.105 or p['material'] in [0,10]:
|
||||
j[i]=[foot,0,0,0]; w[i]=[1,0,0,0]
|
||||
attr['JOINTS_0']=accessor(j,'VEC4',5123);attr['WEIGHTS_0']=accessor(w,'VEC4')
|
||||
primitives.append(p)
|
||||
|
||||
def mesh(vertices, faces, foot, material,smooth=False):
|
||||
vertices=np.asarray(vertices,dtype='<f4');faces=np.asarray(faces,dtype=np.int64)
|
||||
cross=np.cross(vertices[faces[:,1]]-vertices[faces[:,0]],vertices[faces[:,2]]-vertices[faces[:,0]])
|
||||
faces=faces[np.linalg.norm(cross,axis=1)>1e-10]
|
||||
# Flat faces preserve crisp bevels on leather panels, soles and heels.
|
||||
pos=vertices[faces].reshape(-1,3);normal=np.cross(vertices[faces[:,1]]-vertices[faces[:,0]],vertices[faces[:,2]]-vertices[faces[:,0]])
|
||||
normal/=np.maximum(np.linalg.norm(normal,axis=1,keepdims=True),1e-12)
|
||||
normals=np.repeat(normal,3,axis=0)
|
||||
if smooth:
|
||||
averaged=np.zeros_like(vertices)
|
||||
for k in range(3):np.add.at(averaged,faces[:,k],normal)
|
||||
averaged/=np.maximum(np.linalg.norm(averaged,axis=1,keepdims=True),1e-12)
|
||||
normals=averaged[faces].reshape(-1,3)
|
||||
attr={'POSITION':accessor(pos,'VEC3'),'NORMAL':accessor(normals,'VEC3'),
|
||||
'JOINTS_0':accessor(np.tile([foot,0,0,0],(len(pos),1)),'VEC4',5123),
|
||||
'WEIGHTS_0':accessor(np.tile([1,0,0,0],(len(pos),1)),'VEC4')}
|
||||
primitives.append({'attributes':attr,'material':material,'indices':accessor(np.arange(len(pos)).reshape(-1,1),'SCALAR',5125)})
|
||||
|
||||
for side,sign in [('L',1),('R',-1)]:
|
||||
x=sign*.1745;foot=foot_ids[side]
|
||||
vertices=[];faces=[];rings=[(.006,.026,.031,-.040),(.018,.025,.030,-.039),(.078,.028,.032,-.030),(.112,.031,.034,-.024)]
|
||||
outline=[(-.72,-1),(.72,-1),(1,-.72),(1,.72),(.72,1),(-.72,1),(-1,.72),(-1,-.72)]
|
||||
for y,rx,rz,z in rings:
|
||||
for dx,dz in outline:vertices.append([x+dx*rx,y,z+dz*rz])
|
||||
for ring in range(3):
|
||||
for n in range(8):
|
||||
a=ring*8+n;b=ring*8+(n+1)%8;c=b+8;d=a+8;faces.extend([[a,c,b],[a,d,c]])
|
||||
for n in range(1,7):faces.extend([[0,n,n+1],[24,24+n+1,24+n]])
|
||||
mesh(vertices,faces,foot,17)
|
||||
# Closed sculpted outsole: raised heel seat, concave arch, low forefoot.
|
||||
sections=[(-.060,.021,.105),(-.025,.040,.107),(.025,.042,.091),(.080,.038,.050),(.135,.043,.013),(.190,.033,.008),(.250,.015,.010),(.285,.002,.015)]
|
||||
vertices=[];faces=[]
|
||||
for z,width,y in sections:
|
||||
vertices.extend([[x-width,y,z],[x+width,y,z],[x+width,y+.013,z],[x-width,y+.013,z]])
|
||||
for n in range(len(sections)-1):
|
||||
for edge in range(4):
|
||||
a=n*4+edge;b=n*4+(edge+1)%4;c=b+4;d=a+4;faces.extend([[a,b,c],[a,c,d]])
|
||||
faces.extend([[0,2,1],[0,3,2]]);a=(len(sections)-1)*4;faces.extend([[a,a+1,a+2],[a,a+2,a+3]])
|
||||
mesh(vertices,faces,foot,sole_material)
|
||||
|
||||
from succubus_review_outfit import augment
|
||||
augment(doc,read,mesh,primitives,accessor)
|
||||
primitives=[p for p in primitives if doc['accessors'][p['indices']]['count']>0 and doc['accessors'][p['attributes']['POSITION']]['count']>0]
|
||||
doc['meshes'][1]['primitives']=primitives
|
||||
doc['meshes'][1]['name']='Approval only - red bat corset, black block heel boots and curved wings'
|
||||
# Remove superseded buffer data, so the approval model remains portable.
|
||||
used=set()
|
||||
for m in doc['meshes']:
|
||||
for p in m['primitives']:
|
||||
used.update(p['attributes'].values())
|
||||
if 'indices' in p:used.add(p['indices'])
|
||||
for morph in p.get('targets',[]):used.update(morph.values())
|
||||
for skin in doc['skins']:
|
||||
if 'inverseBindMatrices' in skin:used.add(skin['inverseBindMatrices'])
|
||||
for animation in doc.get('animations',[]):
|
||||
for sampler in animation['samplers']:used.update([sampler['input'],sampler['output']])
|
||||
mapping={old:new for new,old in enumerate(sorted(used))}
|
||||
doc['accessors']=[doc['accessors'][old] for old in sorted(used)]
|
||||
for m in doc['meshes']:
|
||||
for p in m['primitives']:
|
||||
p['attributes']={key:mapping[value] for key,value in p['attributes'].items()}
|
||||
if 'indices' in p:p['indices']=mapping[p['indices']]
|
||||
p['targets']=[{key:mapping[value] for key,value in morph.items()} for morph in p.get('targets',[])] if 'targets' in p else []
|
||||
for skin in doc['skins']:
|
||||
if 'inverseBindMatrices' in skin:skin['inverseBindMatrices']=mapping[skin['inverseBindMatrices']]
|
||||
for animation in doc.get('animations',[]):
|
||||
for sampler in animation['samplers']:
|
||||
sampler['input']=mapping[sampler['input']];sampler['output']=mapping[sampler['output']]
|
||||
used_views={a['bufferView'] for a in doc['accessors']}
|
||||
used_views.update(i['bufferView'] for i in doc.get('images',[]) if 'bufferView' in i)
|
||||
view_map={old:new for new,old in enumerate(sorted(used_views))};new_blob=bytearray();views=[]
|
||||
for old in sorted(used_views):
|
||||
view=copy.deepcopy(doc['bufferViews'][old]);start=view.get('byteOffset',0)
|
||||
new_blob.extend(b'\0'*((-len(new_blob))%4));view['byteOffset']=len(new_blob)
|
||||
new_blob.extend(blob[start:start+view['byteLength']]);views.append(view)
|
||||
for a in doc['accessors']:a['bufferView']=view_map[a['bufferView']]
|
||||
for image in doc.get('images',[]):
|
||||
if 'bufferView' in image:image['bufferView']=view_map[image['bufferView']]
|
||||
doc['bufferViews']=views;blob=new_blob
|
||||
doc['buffers'][0]['byteLength']=len(blob)
|
||||
data=json.dumps(doc,separators=(',',':')).encode();data+=b' '*((-len(data))%4);blob.extend(b'\0'*((-len(blob))%4))
|
||||
target.parent.mkdir(parents=True,exist_ok=True)
|
||||
target.write_bytes(struct.pack('<III',0x46546c67,2,28+len(data)+len(blob))+struct.pack('<II',len(data),0x4e4f534a)+data+struct.pack('<II',len(blob),0x004e4942)+blob)
|
||||
print('Review GLB:',target,'bytes:',target.stat().st_size,'foot joints:',foot_ids)
|
||||
@@ -0,0 +1,41 @@
|
||||
"""Clip material boundaries through triangles instead of painting whole faces."""
|
||||
import numpy as np
|
||||
|
||||
def split_material(primitive, selected, signed_distance, positive_material, negative_material, doc, read, accessor):
|
||||
faces=read(primitive['indices']).reshape(-1,3).astype(np.int64)
|
||||
arrays={key:read(value) for key,value in primitive['attributes'].items()}
|
||||
output=[]
|
||||
def clip(poly,values,sign):
|
||||
result=[]
|
||||
for i,a in enumerate(poly):
|
||||
b=poly[(i+1)%len(poly)];va=float(a@values)*sign;vb=float(b@values)*sign
|
||||
if va>=0:result.append(a)
|
||||
if (va>=0)!=(vb>=0):result.append(a+(b-a)*(va/(va-vb)))
|
||||
return result
|
||||
for sign,material in [(1,positive_material),(-1,negative_material)]:
|
||||
if material is None:continue
|
||||
rows={key:[] for key in arrays}
|
||||
for face in faces[selected]:
|
||||
values=np.array([signed_distance(p) for p in arrays['POSITION'][face]])
|
||||
poly=clip(list(np.eye(3)),values,sign)
|
||||
for i in range(1,len(poly)-1):
|
||||
for bary in [poly[0],poly[i],poly[i+1]]:
|
||||
for key,array in arrays.items():
|
||||
if key in ['JOINTS_0','WEIGHTS_0']:continue
|
||||
value=bary@array[face]
|
||||
if key=='NORMAL':value/=max(np.linalg.norm(value),1e-12)
|
||||
rows[key].append(value)
|
||||
weights={}
|
||||
for corner in range(3):
|
||||
for joint,weight in zip(arrays['JOINTS_0'][face[corner]],arrays['WEIGHTS_0'][face[corner]]):
|
||||
weights[int(joint)]=weights.get(int(joint),0)+float(weight)*bary[corner]
|
||||
pairs=sorted(weights.items(),key=lambda x:-x[1])[:4];pairs+=[(0,0)]*(4-len(pairs));total=max(sum(w for _,w in pairs),1e-12)
|
||||
rows['JOINTS_0'].append([j for j,_ in pairs]);rows['WEIGHTS_0'].append([w/total for _,w in pairs])
|
||||
if not rows['POSITION']:continue
|
||||
attrs={}
|
||||
for key,values in rows.items():
|
||||
original=doc['accessors'][primitive['attributes'][key]]
|
||||
attrs[key]=accessor(values,original['type'],original['componentType'])
|
||||
output.append({'attributes':attrs,'material':material,'indices':accessor(np.arange(len(rows['POSITION'])).reshape(-1,1),'SCALAR',5125)})
|
||||
primitive['indices']=accessor(faces[~selected].reshape(-1,1),'SCALAR',5125)
|
||||
return output
|
||||
@@ -0,0 +1,133 @@
|
||||
"""Reference-based red leather outfit and bat wings for the approval model."""
|
||||
import numpy as np
|
||||
from review_mesh_cut import split_material
|
||||
|
||||
def augment(doc, read, mesh, primitives,accessor):
|
||||
joints=doc['skins'][0]['joints']
|
||||
def bone(name):return joints.index(next(i for i,n in enumerate(doc['nodes']) if n.get('name')==name))
|
||||
def material(name,color,metal=0,rough=.4):
|
||||
i=len(doc['materials']);doc['materials'].append({'name':name,'doubleSided':True,'pbrMetallicRoughness':{'baseColorFactor':[*color,1],'metallicFactor':metal,'roughnessFactor':rough}});return i
|
||||
red=material('Crimson fitted leather',[.32,.009,.018],.06,.32)
|
||||
seam=material('Red leather stitched piping',[.12,.004,.009],0,.47)
|
||||
silver=material('Antique silver buckles and eyelets',[.46,.48,.50],.9,.25)
|
||||
membrane=material('Rose burgundy bat membrane',[.29,.045,.065],0,.58)
|
||||
spar=material('Dark living wing spars',[.045,.009,.016],0,.44)
|
||||
doc['materials'][3]['pbrMetallicRoughness'].update(baseColorFactor=[.28,.008,.017,1],roughnessFactor=.34)
|
||||
body=read(next(p for p in primitives if p['material']==1)['attributes']['POSITION'])
|
||||
for p in list(primitives):
|
||||
if p['material'] in [16,17]:
|
||||
positions=read(p['attributes']['POSITION']);faces=read(p['indices']).reshape(-1,3).astype(np.int64);center=positions[faces].mean(axis=1)
|
||||
edge=(center[:,1]>.67)&(center[:,1]<.78)&(np.abs(positions[faces][:,:,0]).max(axis=1)<.30)
|
||||
if edge.any():primitives.extend(split_material(p,edge,lambda point:.72-point[1],17,16,doc,read,accessor))
|
||||
if p['material']==3:
|
||||
positions=read(p['attributes']['POSITION']);faces=read(p['indices']).reshape(-1,3).astype(np.int64);center=positions[faces].mean(axis=1)
|
||||
front=(center[:,2]>.07)&(center[:,1]>1.23)&(np.abs(center[:,0])<.225)
|
||||
def cup(point):
|
||||
x,y,z=point;top=1.313-.060*np.exp(-(x/.037)**2)+.018*np.exp(-((abs(x)-.105)/.055)**2)
|
||||
return top-y
|
||||
primitives.extend(split_material(p,front,cup,3,None,doc,read,accessor))
|
||||
continue
|
||||
if p['material'] not in [1,16]:continue
|
||||
positions=read(p['attributes']['POSITION']);faces=read(p['indices']).reshape(-1,3).astype(np.int64);center=positions[faces].mean(axis=1)
|
||||
region=(center[:,1]>.78)&(center[:,1]<1.04)&(np.abs(positions[faces][:,:,0]).max(axis=1)<.24)
|
||||
primitives.extend(split_material(p,region,lambda point:point[1]-.82-.8125*abs(point[0]),red,16,doc,read,accessor))
|
||||
def surface(x,y,front=True):
|
||||
distance=(body[:,0]-x)**2+(body[:,1]-y)**2
|
||||
near=body[np.argpartition(distance,20)[:20]]
|
||||
z=near[:,2].max()+.012 if front else near[:,2].min()-.012
|
||||
return np.array([x,y,z])
|
||||
def tube(points,radius,mat,bn,radii=None):
|
||||
points=np.array(points);v=[];f=[]
|
||||
for i,p in enumerate(points):
|
||||
tangent=points[min(i+1,len(points)-1)]-points[max(0,i-1)];tangent/=max(np.linalg.norm(tangent),1e-8)
|
||||
axis=np.array([0.,0.,1.]) if abs(tangent[2])<.9 else np.array([0.,1.,0.])
|
||||
u=np.cross(tangent,axis);u/=max(np.linalg.norm(u),1e-8);w=np.cross(tangent,u)
|
||||
r=radius*(radii[i] if radii is not None else 1)
|
||||
for j in range(8):v.append(p+r*(u*np.cos(j*np.pi/4)+w*np.sin(j*np.pi/4)))
|
||||
for i in range(len(points)-1):
|
||||
for j in range(8):
|
||||
a=i*8+j;b=i*8+(j+1)%8;f.extend([[a,b,b+8],[a,b+8,a+8]])
|
||||
mesh(v,f,bn,mat,True)
|
||||
def ring(at,rx,ry,wire,mat,bn):
|
||||
at=np.array(at);tube([at+np.array([rx*np.cos(a),ry*np.sin(a),0]) for a in np.linspace(0,2*np.pi,33)],wire,mat,bn)
|
||||
def strap(points,width,mat,bn):
|
||||
points=np.array(points);v=[];f=[]
|
||||
for i,p in enumerate(points):
|
||||
tangent=points[min(i+1,len(points)-1)]-points[max(0,i-1)]
|
||||
normal=np.cross(tangent,[0,0,1]);normal/=max(np.linalg.norm(normal),1e-8)
|
||||
v.extend([p-normal*width/2,p+normal*width/2])
|
||||
for i in range(len(points)-1):a=i*2;f.extend([[a,a+1,a+3],[a,a+3,a+2]])
|
||||
mesh(v,f,bn,mat)
|
||||
def band(y,rx,rz,z,height,mat,bn,x=0):
|
||||
v=[];f=[]
|
||||
for a in np.linspace(0,2*np.pi,65):
|
||||
v.extend([[x+rx*np.cos(a),y-height/2,z+rz*np.sin(a)],[x+rx*np.cos(a),y+height/2,z+rz*np.sin(a)]])
|
||||
for i in range(64):a=i*2;f.extend([[a,a+1,a+3],[a,a+3,a+2]])
|
||||
mesh(v,f,bn,mat)
|
||||
def buckle(at,width,height,bn):
|
||||
at=np.array(at);outline=[[-width/2,-height/2,0],[width/2,-height/2,0],[width/2,height/2,0],[-width/2,height/2,0],[-width/2,-height/2,0]]
|
||||
tube([at+v for v in np.array(outline)],.0025,silver,bn)
|
||||
tube([at+[-width/2,0,0],at+[width*.12,0,.002]],.0017,silver,bn)
|
||||
def rivet(p,bn):ring(p,.0025,.0025,.0018,silver,bn)
|
||||
|
||||
neck=bone('neck02');chest=bone('spine02');waist=bone('spine04')
|
||||
band(1.468,.067,.065,.025,.092,red,neck)
|
||||
for y,r in [(1.49,.012),(1.455,.018),(1.415,.016)]:ring([0,y,.095],r,r,.0024,silver,neck)
|
||||
for y in [1.495,1.468,1.441]:buckle([0,y,-.044],.025,.018,neck)
|
||||
band(1.045,.145,.100,.052,.028,red,waist);buckle([0,1.045,.160],.042,.030,waist)
|
||||
for sign in [-1,1]:
|
||||
for front in [True,False]:
|
||||
path=[surface(sign*x,y,front) for x,y in [(.045,1.425),(.090,1.385),(.145,1.335),(.185,1.285)]]
|
||||
strap(path,.021,red,chest)
|
||||
for p in path[1:]:rivet(p+np.array([0,0,.001 if front else -.001]),chest)
|
||||
for x in [.055,.105]:
|
||||
tube([surface(sign*x,y) for y in np.linspace(.98,1.29,20)],.0016,seam,chest)
|
||||
# Four fan panels create the small leather bat-wing shoulder silhouette.
|
||||
bn=bone('clavicle.L' if sign>0 else 'clavicle.R')
|
||||
center=np.array([sign*.265,1.365,.045])
|
||||
edge=np.array([[.20,1.405,.025],[.455,1.475,.01],[.390,1.385,.035],[.46,1.305,.025],[.355,1.305,.04],[.365,1.225,.015],[.215,1.29,.03]])
|
||||
edge[:,0]*=sign
|
||||
mesh([center,*edge],[[0,i+1,(i+1)%len(edge)+1] for i in range(len(edge))],bn,red)
|
||||
tube([*edge,edge[0]],.0022,seam,bn)
|
||||
for j in [1,3,5]:tube([center,center*.45+edge[j]*.55+np.array([0,0,.009]),edge[j]],.0033,seam,bn,[1,.9,.15])
|
||||
rivet(center+np.array([0,0,.009]),bn)
|
||||
thigh=bone('upperleg01.L' if sign>0 else 'upperleg01.R')
|
||||
if sign==1:
|
||||
for front in [True,False]:
|
||||
tube([surface(x,.82+.8125*abs(x),front) for x in np.linspace(-.155,.155,45)],.0024,seam,waist)
|
||||
for y in [.782,.815]:band(y,.082,.078,.045,.018,red,thigh,sign*.135)
|
||||
for front in [True,False]:
|
||||
path=[surface(sign*x,y,front) for x,y in [(.13,.955),(.15,.905),(.16,.85),(.16,.812)]]
|
||||
strap(path,.016,red,thigh);buckle(path[-2],.023,.025,thigh)
|
||||
# Visible crossed rear lacing, separate metal eyelets and loose tied ends.
|
||||
for y in np.linspace(.97,1.29,12):
|
||||
for sign in [-1,1]:
|
||||
p=surface(sign*.022,y,False);ring(p,.0037,.0037,.0012,silver,chest)
|
||||
tube([surface(-.022,y,False),surface(.022,y+.014,False)],.0014,red,chest)
|
||||
tube([surface(.022,y,False),surface(-.022,y+.014,False)],.0014,red,chest)
|
||||
knot=surface(0,1.04,False)
|
||||
for sign in [-1,1]:
|
||||
tube([knot,knot+[sign*.035,-.018,-.01],knot+[sign*.022,-.038,-.015],knot],.0018,red,chest)
|
||||
tube([knot,knot+[sign*.009,-.08,-.02],knot+[sign*.02,-.12,-.012]],.0016,red,chest)
|
||||
|
||||
# New curved bat wings are weighted to the existing independent wing bones.
|
||||
for side,sign in [('L',1),('R',-1)]:
|
||||
bn=bone('Wing.'+side)
|
||||
root=np.array([sign*.12,1.39,-.09]);knuckle=np.array([sign*.36,1.97,-.15])
|
||||
tips=np.array([[.73,2.015,-.18],[1.06,1.775,-.20],[.98,1.19,-.18],[.69,.80,-.15],[.35,.88,-.11]])
|
||||
tips[:,0]*=sign;edge=[root,*tips,root+[0,-.20,-.02]]
|
||||
tube([root,root*.45+knuckle*.55+np.array([sign*.035,.08,0]),knuckle,knuckle+[sign*.025,.12,.01],knuckle+[sign*.005,.16,.02]],.017,spar,bn,[1.2,1,.7,.4,.02])
|
||||
for tip in tips:
|
||||
tube([knuckle,knuckle*.55+tip*.45+np.array([0,.035,-.025]),tip],.010,spar,bn,[1,.7,.035])
|
||||
for a,b in zip(edge[:-1],edge[1:]):
|
||||
v=[];f=[];n=16
|
||||
for row in range(n+1):
|
||||
u=row/n
|
||||
for col in range(n+1):
|
||||
t=col/n;boundary=a*(1-t)+b*t+(knuckle-(a+b)/2)*(.30*np.sin(np.pi*t))
|
||||
p=knuckle*(1-u)+boundary*u;p[2]-=.045*np.sin(np.pi*u)*np.sin(np.pi*t);v.append(p)
|
||||
for row in range(n):
|
||||
for col in range(n):
|
||||
k=row*(n+1)+col;f.extend([[k,k+1,k+n+2],[k,k+n+2,k+n+1]])
|
||||
mesh(v,f,bn,membrane,True)
|
||||
tube([a*(1-t)+b*t+(knuckle-(a+b)/2)*(.30*np.sin(np.pi*t)) for t in np.linspace(0,1,25)],.003,spar,bn)
|
||||
Reference in New Issue
Block a user