Replace imps with rigged swamp demon and adapt gait and activities
This commit is contained in:
@@ -12,3 +12,4 @@
|
||||
/Demon_v0.19/reviews/infernal_v01/*.gif filter=lfs diff=lfs merge=lfs -text
|
||||
|
||||
/tools/model_sources/meshy_v01/*.gif filter=lfs diff=lfs merge=lfs -text
|
||||
*.fbx filter=lfs diff=lfs merge=lfs -text
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
{
|
||||
"source_file": "Meshy_AI_Swamp_demon_20250714_texture.fbx",
|
||||
"source_sha256": "4c65404ca40cf50ba871382424b116aab75e69544dc189cdd419ac139e5fc5cf",
|
||||
"texture_sha256": "61cb0c8a705f574179b7735ee2c354054105812e8283a96146f8a7b4706ab8c8",
|
||||
"vertices": 14998,
|
||||
"triangles": 30000,
|
||||
"height": 1.28,
|
||||
"joints": {
|
||||
"Body": {
|
||||
"position": [
|
||||
0,
|
||||
0.57,
|
||||
-0.1
|
||||
],
|
||||
"parent": ""
|
||||
},
|
||||
"Head": {
|
||||
"position": [
|
||||
0,
|
||||
0.78,
|
||||
0.2
|
||||
],
|
||||
"parent": "Body"
|
||||
},
|
||||
"LegL": {
|
||||
"position": [
|
||||
-0.24,
|
||||
0.43,
|
||||
-0.16
|
||||
],
|
||||
"parent": "Body"
|
||||
},
|
||||
"KneeL": {
|
||||
"position": [
|
||||
-0.27,
|
||||
0.27,
|
||||
-0.2
|
||||
],
|
||||
"parent": "LegL"
|
||||
},
|
||||
"FootL": {
|
||||
"position": [
|
||||
-0.28,
|
||||
0.065,
|
||||
0.16
|
||||
],
|
||||
"parent": "KneeL"
|
||||
},
|
||||
"LegR": {
|
||||
"position": [
|
||||
0.24,
|
||||
0.43,
|
||||
-0.16
|
||||
],
|
||||
"parent": "Body"
|
||||
},
|
||||
"KneeR": {
|
||||
"position": [
|
||||
0.27,
|
||||
0.27,
|
||||
-0.2
|
||||
],
|
||||
"parent": "LegR"
|
||||
},
|
||||
"FootR": {
|
||||
"position": [
|
||||
0.28,
|
||||
0.065,
|
||||
0.16
|
||||
],
|
||||
"parent": "KneeR"
|
||||
},
|
||||
"ArmL": {
|
||||
"position": [
|
||||
-0.35,
|
||||
0.8,
|
||||
-0.03
|
||||
],
|
||||
"parent": "Body"
|
||||
},
|
||||
"ElbowL": {
|
||||
"position": [
|
||||
-0.46,
|
||||
0.45,
|
||||
0.12
|
||||
],
|
||||
"parent": "ArmL"
|
||||
},
|
||||
"HandL": {
|
||||
"position": [
|
||||
-0.47,
|
||||
0.16,
|
||||
0.3
|
||||
],
|
||||
"parent": "ElbowL"
|
||||
},
|
||||
"ArmR": {
|
||||
"position": [
|
||||
0.35,
|
||||
0.8,
|
||||
-0.03
|
||||
],
|
||||
"parent": "Body"
|
||||
},
|
||||
"ElbowR": {
|
||||
"position": [
|
||||
0.46,
|
||||
0.45,
|
||||
0.12
|
||||
],
|
||||
"parent": "ArmR"
|
||||
},
|
||||
"HandR": {
|
||||
"position": [
|
||||
0.47,
|
||||
0.16,
|
||||
0.3
|
||||
],
|
||||
"parent": "ElbowR"
|
||||
}
|
||||
},
|
||||
"animation": "Runtime imp_gait.gd IK and imp_activities.gd; original FBX has no rig or clips."
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,36 @@
|
||||
[remap]
|
||||
|
||||
importer="scene"
|
||||
importer_version=1
|
||||
type="PackedScene"
|
||||
uid="uid://cea7mr1nksra6"
|
||||
path="res://.godot/imported/swamp_imp.glb-d40fdf032f82ad5e23c18df7d32671f4.scn"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://art/imps/swamp_v01/swamp_imp.glb"
|
||||
dest_files=["res://.godot/imported/swamp_imp.glb-d40fdf032f82ad5e23c18df7d32671f4.scn"]
|
||||
|
||||
[params]
|
||||
|
||||
nodes/root_type=""
|
||||
nodes/root_name=""
|
||||
nodes/apply_root_scale=true
|
||||
nodes/root_scale=1.0
|
||||
nodes/import_as_skeleton_bones=false
|
||||
meshes/ensure_tangents=true
|
||||
meshes/generate_lods=true
|
||||
meshes/create_shadow_meshes=true
|
||||
meshes/light_baking=1
|
||||
meshes/lightmap_texel_size=0.2
|
||||
meshes/force_disable_compression=false
|
||||
skins/use_named_skins=true
|
||||
animation/import=true
|
||||
animation/fps=30
|
||||
animation/trimming=false
|
||||
animation/remove_immutable_tracks=true
|
||||
animation/import_rest_as_RESET=false
|
||||
import_script/path=""
|
||||
_subresources={}
|
||||
gltf/naming_version=1
|
||||
gltf/embedded_image_handling=1
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.1 MiB |
+37
@@ -0,0 +1,37 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://ufopov3ktek1"
|
||||
path="res://.godot/imported/swamp_imp_Meshy_AI_Swamp_demon_20250714_texture.png-6d779f4f7a37b9d71e2b2acb2b3528ca.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
generator_parameters={
|
||||
"md5": "375a1eb2c34fb7d820291ece3fbc0b5e"
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://art/imps/swamp_v01/swamp_imp_Meshy_AI_Swamp_demon_20250714_texture.png"
|
||||
dest_files=["res://.godot/imported/swamp_imp_Meshy_AI_Swamp_demon_20250714_texture.png-6d779f4f7a37b9d71e2b2acb2b3528ca.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=true
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
+18
-80
@@ -1,81 +1,19 @@
|
||||
extends RefCounted
|
||||
func build(g):
|
||||
var r=Node3D.new();r.name="Imp";r.set_meta("species","imp");r.set_meta("model_revision",2)
|
||||
var s=preload("res://hero.gd").new();s.g=g
|
||||
var skin=Color("785140");var horn=Color("30251f");var hide=Color("352b25");var rim=Color("907558")
|
||||
# A rounded abdomen, narrow waist, stooped chest and articulated limbs.
|
||||
s.loft(r,Vector3.ZERO,[[.35,.13,.12,0],[.44,.19,.145,0],[.55,.205,.17,-.025],[.69,.20,.18,-.045],[.80,.165,.155,-.025],[.88,.085,.09,.025]],skin)
|
||||
for side in [-1,1]:
|
||||
s.tube(r,[Vector3(side*.13,.80,-.035),Vector3(side*.19,.69,-.09),Vector3(side*.13,.54,-.12)],[.065,.075,.04],skin.darkened(.10))
|
||||
var head=Node3D.new();r.add_child(head);head.name="Head";head.position=Vector3(0,.85,.035)
|
||||
s.loft(head,Vector3.ZERO,[[-.055,.075,.075,.02],[.015,.13,.115,.045],[.105,.158,.125,.035],[.19,.137,.105,.015],[.235,.075,.07,0],[.25,.025,.03,0]],skin)
|
||||
for side in [-1,1]:
|
||||
s.tube(head,[Vector3(side*.105,.19,-.02),Vector3(side*.17,.29,-.07),Vector3(side*.15,.40,-.105),Vector3(side*.095,.435,-.075)],[.051,.036,.017,.001],horn)
|
||||
for j in range(4):
|
||||
var ridge=TorusMesh.new();ridge.inner_radius=.030-j*.003;ridge.outer_radius=.036-j*.003;ridge.rings=24;ridge.ring_segments=12
|
||||
var a=g.mesh_node(head,ridge,Vector3(side*(.12+j*.013),.22+j*.026,-.025-j*.015),horn.lightened(.10));a.scale=Vector3(1,.5,1)
|
||||
s.tube(head,[Vector3(side*.13,.13,.005),Vector3(side*.27,.185,-.06),Vector3(side*.23,.075,-.025)],[.056,.009,.001],skin)
|
||||
s.tube(head,[Vector3(side*.16,.135,.006),Vector3(side*.237,.163,-.035)],[.026,.002],skin.darkened(.25))
|
||||
var eye=Node3D.new();head.add_child(eye);eye.name="EyeL" if side<0 else "EyeR";eye.position=Vector3(side*.067,.126,.139)
|
||||
g.ball(eye,Vector3.ZERO,Vector3(.068,.035,.026),Color("c7aa6b"));g.ball(eye,Vector3(0,0,.014),Vector3(.012,.027,.008),Color("17130f"))
|
||||
g.ball(eye,Vector3(-.012,.007,.016),Vector3.ONE*.006,Color("efdaa8"))
|
||||
s.tube(head,[Vector3(side*.018,.168,.117),Vector3(side*.10,.157,.129),Vector3(side*.13,.14,.105)],[.021,.025,.008],skin.darkened(.12))
|
||||
s.tube(head,[Vector3(side*.04,.065,.139),Vector3(side*.10,.070,.12)],[.025,.014],skin.lightened(.05))
|
||||
g.ball(head,Vector3(side*.025,.075,.173),Vector3(.014,.009,.006),horn)
|
||||
s.tube(head,[Vector3(side*.053,.028,.143),Vector3(side*.058,.06,.156)],[.012,.001],Color("b4a48a"))
|
||||
s.tube(head,[Vector3(0,.125,.13),Vector3(0,.070,.184),Vector3(0,.057,.164)],[.026,.030,.018],skin.darkened(.08))
|
||||
s.tube(head,[Vector3(-.07,.022,.12),Vector3(0,.009,.151),Vector3(.07,.022,.12)],[.006,.009,.006],Color("38231d"))
|
||||
g.ball(head,Vector3(0,-.025,.102),Vector3(.09,.05,.065),skin.darkened(.06))
|
||||
for side in [-1,1]:
|
||||
var leg=Node3D.new();r.add_child(leg);leg.name="LegL" if side<0 else "LegR";leg.position=Vector3(side*.135,.44,0)
|
||||
s.tube(leg,[Vector3.ZERO,Vector3(0,-.09,.02),Vector3(0,-.19,.025)],[.077,.070,.054],skin)
|
||||
var knee=Node3D.new();leg.add_child(knee);knee.name="Knee";knee.position=Vector3(0,-.19,.025)
|
||||
g.ball(knee,Vector3(0,0,.014),Vector3(.115,.105,.10),skin.darkened(.08))
|
||||
s.tube(knee,[Vector3.ZERO,Vector3(0,-.08,-.025),Vector3(0,-.19,-.025)],[.052,.046,.033],skin)
|
||||
var foot=Node3D.new();knee.add_child(foot);foot.name="Foot";foot.position=Vector3(0,-.19,-.025)
|
||||
for toe in [-1,1]:
|
||||
s.loft(foot,Vector3(toe*.034,0,0),[[-.052,.032,.080,.052],[-.02,.034,.083,.050],[.025,.031,.065,.035],[.055,.021,.035,.005]],horn)
|
||||
g.line(foot,Vector3(toe*.034,-.025,.130),Vector3(toe*.034,.014,.105),.006,rim.darkened(.3))
|
||||
var arm=Node3D.new();r.add_child(arm);arm.name="ArmL" if side<0 else "ArmR";arm.position=Vector3(side*.18,.77,.005)
|
||||
s.tube(arm,[Vector3.ZERO,Vector3(side*.055,-.10,.005),Vector3(side*.085,-.22,.025)],[.069,.062,.045],skin)
|
||||
var elbow=Node3D.new();arm.add_child(elbow);elbow.name="Elbow";elbow.position=Vector3(side*.085,-.22,.025)
|
||||
g.ball(elbow,Vector3.ZERO,Vector3(.09,.085,.085),skin.darkened(.05))
|
||||
s.tube(elbow,[Vector3.ZERO,Vector3(side*.018,-.12,.035),Vector3(side*.025,-.23,.075)],[.044,.039,.029],skin)
|
||||
g.ball(elbow,Vector3(side*.025,-.25,.078),Vector3(.075,.09,.05),skin)
|
||||
for finger in range(3):
|
||||
var a=Vector3(side*.025+(finger-1)*.024,-.28,.083)
|
||||
s.tube(elbow,[a,a+Vector3(0,-.045,.015),a+Vector3(0,-.055,.035)],[.011,.008,.001],horn)
|
||||
s.tube(elbow,[Vector3(-side*.005,-.23,.085),Vector3(-side*.025,-.265,.11)],[.015,.004],skin)
|
||||
s.loft(r,Vector3.ZERO,[[.33,.16,.13,0],[.40,.185,.15,0],[.47,.19,.16,0]],hide)
|
||||
s.loft(r,Vector3.ZERO,[[.445,.193,.164,0],[.475,.193,.164,0]],rim.darkened(.35))
|
||||
for i in range(7):g.line(r,Vector3(-.12+i*.04,.435,.151),Vector3(-.11+i*.04,.405,.15),.004,rim)
|
||||
var tail=Node3D.new();r.add_child(tail);tail.name="Tail"
|
||||
s.tube(tail,[Vector3(0,.41,-.13),Vector3(.08,.32,-.30),Vector3(.23,.35,-.44),Vector3(.29,.49,-.44),Vector3(.25,.56,-.39)],[.033,.026,.019,.012,.002],skin)
|
||||
for i in range(5):g.ball(r,Vector3(0,.49+i*.055,-.18),Vector3(.035,.035,.045),horn)
|
||||
merge_parts(r)
|
||||
return r
|
||||
|
||||
func merge_parts(root):
|
||||
# Bake fixed details per articulated part, preserving vertex colours and rig nodes.
|
||||
for child in root.get_children():
|
||||
if child is Node3D and not child is MeshInstance3D:merge_parts(child)
|
||||
var st=SurfaceTool.new();st.begin(Mesh.PRIMITIVE_TRIANGLES)
|
||||
var sources=[]
|
||||
for n in root.get_children():
|
||||
if not n is MeshInstance3D:continue
|
||||
sources.append(n)
|
||||
var color=n.material_override.albedo_color
|
||||
for surface in range(n.mesh.get_surface_count()):
|
||||
var arrays=n.mesh.surface_get_arrays(surface)
|
||||
var verts=arrays[Mesh.ARRAY_VERTEX];var normals=arrays[Mesh.ARRAY_NORMAL];var indices=arrays[Mesh.ARRAY_INDEX]
|
||||
var size=indices.size() if indices!=null and indices.size()>0 else verts.size()
|
||||
for i in range(size):
|
||||
var index=indices[i] if indices!=null and indices.size()>0 else i
|
||||
st.set_color(color.srgb_to_linear())
|
||||
st.set_normal((n.transform.basis.inverse().transposed()*normals[index]).normalized())
|
||||
st.add_vertex(n.transform*verts[index])
|
||||
if sources.is_empty():return
|
||||
st.index();var mesh=MeshInstance3D.new();mesh.mesh=st.commit()
|
||||
var material=StandardMaterial3D.new();material.vertex_color_use_as_albedo=true;material.roughness=.88
|
||||
mesh.material_override=material;root.add_child(mesh)
|
||||
for n in sources:n.free()
|
||||
const SCENE=preload("res://art/imps/swamp_v01/swamp_imp.glb")
|
||||
const JOINTS={
|
||||
"Body":[Vector3(0,.57,-.10),""],"Head":[Vector3(0,.78,.20),""],
|
||||
"LegL":[Vector3(-.24,.43,-.16),""],"KneeL":[Vector3(-.27,.27,-.20),"LegL"],"FootL":[Vector3(-.28,.065,.16),"KneeL"],
|
||||
"LegR":[Vector3(.24,.43,-.16),""],"KneeR":[Vector3(.27,.27,-.20),"LegR"],"FootR":[Vector3(.28,.065,.16),"KneeR"],
|
||||
"ArmL":[Vector3(-.35,.80,-.03),""],"ElbowL":[Vector3(-.46,.45,.12),"ArmL"],"HandL":[Vector3(-.47,.16,.30),"ElbowL"],
|
||||
"ArmR":[Vector3(.35,.80,-.03),""],"ElbowR":[Vector3(.46,.45,.12),"ArmR"],"HandR":[Vector3(.47,.16,.30),"ElbowR"]}
|
||||
func build(_g):
|
||||
var root=Node3D.new();root.name="Imp";root.set_meta("species","imp");root.set_meta("model_revision",3);root.set_meta("model_asset","swamp_v01");root.set_meta("knee_bend",-1.0)
|
||||
var nodes={}
|
||||
for key in JOINTS:
|
||||
var item=JOINTS[key];var node=Node3D.new();nodes[key]=node
|
||||
var parent=root if item[1]=="" else nodes[item[1]]
|
||||
parent.add_child(node)
|
||||
node.name="Knee" if key.begins_with("Knee") else ("Foot" if key.begins_with("Foot") else ("Elbow" if key.begins_with("Elbow") else ("Hand" if key.begins_with("Hand") else key)))
|
||||
node.position=item[0]-(Vector3.ZERO if item[1]=="" else JOINTS[item[1]][0])
|
||||
var visual=SCENE.instantiate();visual.name="SwampVisual";root.add_child(visual)
|
||||
return root
|
||||
|
||||
@@ -45,7 +45,7 @@ func make_props(imp):
|
||||
g.box(props,Vector3(.14,.09,.65),Vector3(.40,.06,.15),Color("595447"))
|
||||
for x in range(9):g.line(props,Vector3(-.04+x*.045,.08,.65),Vector3(-.04+x*.045,.025,.72),.014,Color("8e8a70"))
|
||||
elif imp.activity in ["clean","draw"]:
|
||||
props.reparent(imp.model.get_node("ArmR"),false);props.position=Vector3(.11,-.46,.10)
|
||||
props.reparent(imp.model.get_node("ArmR/Elbow/Hand"),false);props.position=Vector3(0,-.025,.03)
|
||||
if imp.activity=="clean":
|
||||
g.box(props,Vector3(0,0,.06),Vector3(.14,.05,.16),Color("68432d"))
|
||||
for i in range(5):g.line(props,Vector3((i-2)*.025,-.02,.06),Vector3((i-2)*.025,-.08,.09),.008,Color("b9a47a"))
|
||||
|
||||
+31
-6
@@ -3,6 +3,7 @@ var root: Node3D
|
||||
var variation=0.0
|
||||
var model
|
||||
var feet=[]
|
||||
var skin=preload("res://imp_skin.gd").new()
|
||||
var previous=Vector3.ZERO
|
||||
var phase=.1
|
||||
var clock=0.0
|
||||
@@ -15,26 +16,51 @@ const CYCLE_DISTANCE=.48
|
||||
func setup(record):
|
||||
model=record.model;root=record.root;variation=record.phase;previous=root.global_position
|
||||
feet.clear()
|
||||
skin=preload("res://imp_skin.gd").new();skin.setup(model)
|
||||
phase=.1;weight=0;body_height=0;body_rotation=Vector3.ZERO;last_direction=Vector3.ZERO
|
||||
for side in ["L","R"]:
|
||||
var leg=model.get_node("Leg"+side);var knee=leg.get_node("Knee");var foot=knee.get_node("Foot")
|
||||
feet.append({"leg":leg,"knee":knee,"foot":foot,"side":side,"anchor":foot.global_position,"target":foot.global_position,"start":foot.global_position,"landing":foot.global_position,"swing":false,"yaw":root.rotation.y,"last_phase":.1 if side=="L" else .6})
|
||||
feet.append({"width":leg.position.x+knee.position.x+foot.position.x,"forward":leg.position.z+knee.position.z+foot.position.z,"leg":leg,"knee":knee,"foot":foot,"side":side,"anchor":foot.global_position,"target":foot.global_position,"start":foot.global_position,"landing":foot.global_position,"swing":false,"yaw":root.rotation.y,"last_phase":.1 if side=="L" else .6})
|
||||
func reset():
|
||||
previous=root.global_position;weight=0;phase=.1;last_direction=Vector3.ZERO
|
||||
model.position=Vector3.ZERO;body_height=0;body_rotation=Vector3.ZERO;model.rotation=Vector3.ZERO
|
||||
for f in feet:f.leg.rotation=Vector3.ZERO;f.knee.rotation=Vector3.ZERO;f.foot.rotation=Vector3.ZERO
|
||||
for f in feet:
|
||||
f.anchor=f.foot.global_position;f.anchor.y=root.global_position.y+.06;f.target=f.anchor;f.swing=false;f.yaw=root.rotation.y
|
||||
skin.update()
|
||||
func solve(f):
|
||||
var hip=f.leg.global_position;var l1=f.knee.position.length();var l2=f.foot.position.length()
|
||||
var delta=f.target-hip;var distance=clampf(delta.length(),absf(l1-l2)+.001,l1+l2-.001)
|
||||
var direction=delta.normalized();var forward=root.global_basis.z.normalized()
|
||||
var bend=(forward-direction*forward.dot(direction)).normalized()
|
||||
var bend=(forward-direction*forward.dot(direction)).normalized()*float(model.get_meta("knee_bend",1.0))
|
||||
var along=(l1*l1-l2*l2+distance*distance)/(2*distance)
|
||||
var elbow=hip+direction*along+bend*sqrt(maxf(0,l1*l1-along*along))
|
||||
f.leg.quaternion=Quaternion(f.knee.position.normalized(),(f.leg.get_parent().to_local(elbow)-f.leg.position).normalized())
|
||||
f.knee.quaternion=Quaternion(f.foot.position.normalized(),(f.leg.to_local(f.target)-f.knee.position).normalized())
|
||||
f.foot.global_rotation=Vector3(0,f.yaw,0)
|
||||
func pose_work_hands():
|
||||
var activity=root.get_meta("activity","")
|
||||
if activity not in ["clean","mop","draw"]:return
|
||||
var t=clock
|
||||
for side in ["L","R"]:
|
||||
if side=="L" and activity!="mop":continue
|
||||
var arm=model.get_node("Arm"+side);var elbow=arm.get_node("Elbow");var hand=elbow.get_node("Hand")
|
||||
var target=Vector3(.12,.35,.57) if side=="R" else Vector3(-.12,.54,.47)
|
||||
if activity=="mop":target.z+=sin(t*3)*.10
|
||||
elif activity=="clean":target=Vector3(.30+cos(t*6)*.04,.54+sin(t*6)*.035,.54)
|
||||
else:target=Vector3(.26+cos(t*7)*.045,.84+sin(t*7)*.045,.53)
|
||||
target=root.to_global(target)
|
||||
var shoulder=arm.global_position;var l1=elbow.position.length();var l2=hand.position.length()
|
||||
var delta=target-shoulder;var distance=clampf(delta.length(),absf(l1-l2)+.001,l1+l2-.001)
|
||||
var direction=delta.normalized();target=shoulder+direction*distance
|
||||
var outward=root.global_basis.x*(-1 if side=="L" else 1)
|
||||
var bend=(outward-direction*outward.dot(direction)).normalized()
|
||||
var along=(l1*l1-l2*l2+distance*distance)/(2*distance)
|
||||
var joint=shoulder+direction*along+bend*sqrt(maxf(0,l1*l1-along*along))
|
||||
arm.quaternion=Quaternion(elbow.position.normalized(),(arm.get_parent().to_local(joint)-arm.position).normalized())
|
||||
elbow.quaternion=Quaternion(hand.position.normalized(),(arm.to_local(target)-elbow.position).normalized())
|
||||
hand.global_rotation=root.global_rotation
|
||||
arm_pose[0 if side=="L" else 1]=arm.rotation
|
||||
func update(dt,acting=false):
|
||||
dt=minf(dt,.05);clock+=dt
|
||||
var delta=root.global_position-previous;delta.y=0;previous=root.global_position
|
||||
@@ -51,7 +77,7 @@ func update(dt,acting=false):
|
||||
if moving:
|
||||
if p>=.56:
|
||||
if not f.swing:f.start=f.target;f.swing=true
|
||||
f.landing=root.global_position+root.global_basis.x*(-.135 if f.side=="L" else .135)+forward*.08;f.landing.y=ground
|
||||
f.landing=root.global_position+root.global_basis.x*f.width+forward*(f.forward+.08);f.landing.y=ground
|
||||
var t=clampf((p-.56)/.44,0,1);f.target=f.start.lerp(f.landing,smoothstep(0,1,t));f.target.y=ground+sin(t*PI)*.065
|
||||
else:
|
||||
if f.swing:f.anchor=f.landing;f.anchor.y=ground;f.swing=false;f.yaw=root.rotation.y
|
||||
@@ -77,6 +103,5 @@ func update(dt,acting=false):
|
||||
arm_pose[i]=arm_pose[i].lerp(desired,1-exp(-dt*8));arm.rotation=arm_pose[i]
|
||||
arm.get_node("Elbow").rotation.x=-.05-sin(phase*TAU+i*PI)*.045*weight
|
||||
model.get_node("Head").rotation=Vector3(sin(clock*2)*.012, sin(clock*.8+variation)*.025, -sin(phase*TAU)*.018*weight)
|
||||
var blink=absf(sin(clock*.68+variation))
|
||||
for side in ["L","R"]:model.get_node("Head/Eye"+side).scale.y=clampf(blink*24,.10,1)
|
||||
model.get_node("Tail").rotation.y=sin(clock*2.4+variation)*(.12+.08*weight)
|
||||
if acting:pose_work_hands()
|
||||
skin.update()
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
extends RefCounted
|
||||
# Drive the imported skin from the same IK/activity controls used by navigation.
|
||||
var model:Node3D
|
||||
var skeleton:Skeleton3D
|
||||
var bindings=[]
|
||||
func setup(root):
|
||||
model=root;skeleton=find_skeleton(model.get_node("SwampVisual"))
|
||||
assert(skeleton!=null,"Swamp imp must contain its skin skeleton")
|
||||
var controls={"Body":"Body","Head":"Head","LegL":"LegL","KneeL":"LegL/Knee","FootL":"LegL/Knee/Foot","LegR":"LegR","KneeR":"LegR/Knee","FootR":"LegR/Knee/Foot","ArmL":"ArmL","ElbowL":"ArmL/Elbow","HandL":"ArmL/Elbow/Hand","ArmR":"ArmR","ElbowR":"ArmR/Elbow","HandR":"ArmR/Elbow/Hand"}
|
||||
for name in controls:
|
||||
var index=skeleton.find_bone(name);assert(index>=0,"Missing swamp bone: "+name)
|
||||
bindings.append({"index":index,"control":model.get_node(controls[name]),"rest":skeleton.get_bone_global_rest(index)})
|
||||
update()
|
||||
func find_skeleton(node):
|
||||
if node is Skeleton3D:return node
|
||||
for child in node.get_children():
|
||||
var found=find_skeleton(child)
|
||||
if found:return found
|
||||
return null
|
||||
func update():
|
||||
for binding in bindings:
|
||||
var control=model.global_transform.affine_inverse()*binding.control.global_transform
|
||||
var pose=Transform3D(control.basis*binding.rest.basis,control.origin)
|
||||
skeleton.set_bone_global_pose_override(binding.index,skeleton.global_transform.affine_inverse()*model.global_transform*pose,1.0,true)
|
||||
@@ -5,11 +5,38 @@ func check(ok,label):
|
||||
func shot(g,name):
|
||||
await g.get_tree().process_frame;await RenderingServer.frame_post_draw
|
||||
g.get_viewport().get_texture().get_image().save_png("res://captures/imps-v02/"+name+".png")
|
||||
func verify_skin(imp):
|
||||
var skin=imp.gait.skin
|
||||
check(skin.skeleton.get_bone_count()==14,"all fourteen skin joints imported")
|
||||
for binding in skin.bindings:
|
||||
var actual=skin.skeleton.global_transform*skin.skeleton.get_bone_global_pose(binding.index)
|
||||
check(actual.origin.distance_to(binding.control.global_position)<.0001,"skin follows IK control: "+str(binding.index))
|
||||
var meshes=imp.model.get_node("SwampVisual").find_children("*","MeshInstance3D",true,false)
|
||||
check(meshes.size()==1,"single shared textured mesh per imp")
|
||||
for mesh in meshes:
|
||||
check(mesh.skin!=null and mesh.skin.get_bind_count()==14,"mesh is actually skinned")
|
||||
check(mesh.get_active_material(0).albedo_texture!=null,"original colour texture preserved")
|
||||
var arrays=mesh.mesh.surface_get_arrays(0)
|
||||
var vertices=arrays[Mesh.ARRAY_VERTEX];var bones=arrays[Mesh.ARRAY_BONES];var weights=arrays[Mesh.ARRAY_WEIGHTS]
|
||||
var low=Vector3(INF,INF,INF);var high=-low
|
||||
for i in range(vertices.size()):
|
||||
var pos=Vector3.ZERO;var total=0.0
|
||||
for j in range(4):
|
||||
var weight=weights[i*4+j]
|
||||
if weight<=0:continue
|
||||
var bind=bones[i*4+j];var index=skin.skeleton.find_bone(mesh.skin.get_bind_name(bind))
|
||||
if index<0:index=mesh.skin.get_bind_bone(bind)
|
||||
pos+=(skin.skeleton.get_bone_global_pose(index)*mesh.skin.get_bind_pose(bind)*vertices[i])*weight;total+=weight
|
||||
check(pos.is_finite() and absf(total-1)<.001,"finite normalized deformed vertices")
|
||||
low=low.min(pos);high=high.max(pos)
|
||||
check((high-low).length()<2.8,"skin remains bounded without exploding vertices")
|
||||
func run(g):
|
||||
await g.get_tree().create_timer(.3).timeout
|
||||
g.start_game();g.set_process(false);g.reset_shift();g.game_started=true;g.paused=false
|
||||
var imp=g.life.imps[0];var gait=imp.gait
|
||||
check(imp.model.get_meta("model_revision")==2 and imp.model.has_node("LegL/Knee/Foot") and imp.model.has_node("ArmR/Elbow") and imp.model.has_node("Head/EyeL"),"new articulated model")
|
||||
check(imp.model.get_meta("model_revision")==3 and imp.model.has_node("LegL/Knee/Foot") and imp.model.has_node("ArmR/Elbow") and imp.model.has_node("SwampVisual"),"new articulated model")
|
||||
verify_skin(imp)
|
||||
for actor in g.life.imps+g.life.neighbours:check(actor.model.get_meta("model_asset")=="swamp_v01","replacement applied to all 28 imps")
|
||||
for fps in [30,60,144]:
|
||||
for speed in [.5,1.25]:
|
||||
imp.root.position=Vector3(3,0,2);imp.root.rotation=Vector3.ZERO;imp.model.rotation=Vector3.ZERO;imp.model.position=Vector3.ZERO
|
||||
@@ -24,6 +51,7 @@ func run(g):
|
||||
var f=gait.feet[i];max_error=maxf(max_error,f.foot.global_position.distance_to(f.target));min_floor=minf(min_floor,f.foot.global_position.y-.052)
|
||||
if not f.swing and not last[i].swing and f.anchor.is_equal_approx(last[i].anchor):max_slide=maxf(max_slide,f.foot.global_position.distance_to(last[i].at))
|
||||
check(max_error<.006,"foot reach %d %.2f"%[fps,speed]);check(max_slide<.004,"planted hoof slip %d %.2f"%[fps,speed]);check(min_floor>-.005,"hooves stay above floor")
|
||||
verify_skin(imp)
|
||||
var phase=gait.phase
|
||||
for i in range(fps):gait.update(1.0/fps)
|
||||
check(is_equal_approx(gait.phase,phase),"blocked imp does not march in place")
|
||||
@@ -37,10 +65,14 @@ func run(g):
|
||||
g.life.move_imp(imp,Vector3(1,0,0),1.0/60)
|
||||
check(imp.root.position.distance_to(before)<.04,"crowd avoidance has no teleport pushes")
|
||||
check(absf(angle_difference(yaw,imp.root.rotation.y))<=.051,"turn speed bounded")
|
||||
DirAccess.make_dir_recursive_absolute("res://captures/imps-v02")
|
||||
for kind in ["clean","mop","draw","hum"]:
|
||||
if kind=="clean" and g.workshop.stations.is_empty():g.workshop.add_station(0,Vector3(2,0,0));g.workshop.rebuild_nav()
|
||||
g.life.activities.finish(imp);g.life.activities.start(imp,kind);imp.root.position=imp.activity_target;gait.reset()
|
||||
for i in range(50):g.life.activities.update(imp,.02);gait.update(.02,true)
|
||||
verify_skin(imp)
|
||||
g.hud.hide();g.player.hide();g.camera.position=imp.root.position+Vector3(2,1.6,3);g.camera.look_at(imp.root.position+Vector3(0,.65,0));g.camera.size=2.6
|
||||
await shot(g,"activity-"+kind)
|
||||
var arm=imp.model.get_node("ArmR").rotation;g.life.activities.finish(imp);gait.update(.02,false)
|
||||
check(imp.model.get_node("ArmR").rotation.distance_to(arm)<.35,"activity returns smoothly to walking")
|
||||
DirAccess.make_dir_recursive_absolute("res://captures/imps-v02")
|
||||
|
||||
+4
-4
@@ -123,11 +123,11 @@ func move_imp(imp,target,dt):
|
||||
if other.root!=imp.root:actors.append(other.root.position)
|
||||
for position in actors:
|
||||
var delta=imp.root.position-position;delta.y=0
|
||||
if delta.length_squared()<.52*.52:
|
||||
desired_velocity+=(delta.normalized() if delta.length_squared()>.0001 else Vector3.RIGHT)*1.4*(1-delta.length()/.52)
|
||||
if delta.length_squared()<.72*.72:
|
||||
desired_velocity+=(delta.normalized() if delta.length_squared()>.0001 else Vector3.RIGHT)*1.4*(1-delta.length()/.72)
|
||||
imp.velocity=imp.get("velocity",Vector3.ZERO).move_toward(desired_velocity.limit_length(1.35),step_dt*5)
|
||||
var before=imp.root.position;var desired=before+imp.velocity*step_dt
|
||||
w.mesh_walking.move_actor(imp.root,desired-imp.root.position,.20,1.0)
|
||||
w.mesh_walking.move_actor(imp.root,desired-imp.root.position,.34,1.18)
|
||||
imp.root.position.x=clampf(imp.root.position.x,-7.1,w.walk_right());imp.root.position.z=clampf(imp.root.position.z,-4.8,5.6)
|
||||
face_motion(imp,imp.root.position-before,step_dt)
|
||||
if imp.root.position.distance_to(next)<.12 and not imp.path.is_empty():imp.path.remove_at(0)
|
||||
@@ -147,7 +147,7 @@ func move_neighbour(imp,target,dt):
|
||||
var desired=(target-imp.root.position).normalized()*1.15;desired.y=0
|
||||
imp.velocity=imp.velocity.move_toward(desired,dt*4)
|
||||
var before=imp.root.position
|
||||
g.workshop.mesh_walking.move_actor(imp.root,imp.velocity*dt,.20,1.0)
|
||||
g.workshop.mesh_walking.move_actor(imp.root,imp.velocity*dt,.34,1.18)
|
||||
imp.root.position.x=clampf(imp.root.position.x,imp.origin.x-7.1,imp.origin.x+7.1)
|
||||
imp.root.position.z=clampf(imp.root.position.z,imp.origin.z-5.5,imp.origin.z+5.5)
|
||||
face_motion(imp,imp.root.position-before,dt)
|
||||
|
||||
@@ -37,11 +37,11 @@ func run(g):
|
||||
activities.update(imp,.2)
|
||||
check(imp.activity==kind and is_instance_valid(imp.activity_props),"activity starts with real props: "+kind)
|
||||
var before=imp.model.get_node("ArmR").rotation
|
||||
activities.update(imp,.3)
|
||||
activities.update(imp,.3);imp.gait.update(.05,true)
|
||||
check(imp.model.get_node("ArmR").rotation!=before,"activity animates: "+kind)
|
||||
g.camera.position=imp.root.position+Vector3(3,2.4,4);g.camera.look_at(imp.root.position+Vector3(0,.6,0));g.camera.size=3.5
|
||||
if kind=="draw":
|
||||
activities.update(imp,3.5)
|
||||
activities.update(imp,3.5);imp.gait.update(.05,true)
|
||||
check(imp.activity_mark.edges.all(func(edge):return edge.node.visible),"pentagram is drawn in five strokes")
|
||||
for node in g.architecture.walls:node.show()
|
||||
g.camera.position=imp.root.position+Vector3(3,1.5,2);g.camera.look_at(imp.root.position+Vector3(-.3,.7,0))
|
||||
|
||||
@@ -4,7 +4,7 @@ static func resolve(g):
|
||||
for s in g.souls:
|
||||
var radius=1.35 if s.id==g.working and g.development.selected>0 else (0.53 if s.kind in [0,3] else 0.38)
|
||||
actors.append({"node":s.node,"radius":radius,"weight":0.0 if s.entering or s.id==g.working else 0.65})
|
||||
for imp in g.life.imps:actors.append({"node":imp.root,"radius":0.22,"weight":1.0})
|
||||
for imp in g.life.imps:actors.append({"node":imp.root,"radius":0.34,"weight":1.0})
|
||||
for burn in g.life.burns:
|
||||
if is_instance_valid(burn.root):actors.append({"node":burn.root,"radius":0.52,"weight":0.0})
|
||||
for iteration in range(4):
|
||||
|
||||
+42
@@ -249,3 +249,45 @@ Meshy восстановил близкую форму без подставки
|
||||
текущая утверждённая Infernal остаётся активной. Игровые тесты не повторялись:
|
||||
изменений runtime нет. Подробности и локальный путь Meshy-проекта — в README
|
||||
рядом с моделью. Сырые ответы с временными ссылками не публикуются.
|
||||
|
||||
## Болотные демонята — 28 октября 2026
|
||||
|
||||
По запросу пользователя все четыре местных и 24 соседних демонёнка заменены на
|
||||
модель из `Meshy_AI_Swamp_demon_20250714_texture_fbx.zip`. Исходные FBX и PNG
|
||||
сохранены в `tools/model_sources/swamp_demon/`; SHA256 записаны в
|
||||
`Demon_v0.19/art/imps/swamp_v01/manifest.json`. Это пользовательский ассет;
|
||||
лицензия в архиве отсутствует, происхождение или лицензию от себя не назначали.
|
||||
|
||||
Исходный FBX содержит 14 998 вершин / 30 000 треугольников, без скелета и клипов.
|
||||
`tools/build_swamp_imp.py` воспроизводит нормализацию до 1,28 м, скелет из 14
|
||||
костей, веса кожи с разделением близких кистей/стоп и экспорт GLB со встроенной
|
||||
исходной текстурой. Редактируемый `swamp_imp.blend` хранится рядом с исходником,
|
||||
за пределами игровых ресурсов. FBX, BLEND и GLB хранятся в Git LFS.
|
||||
|
||||
`imp_skin.gd` связывает кожу с процедурной походкой и действиями. Ширина шага
|
||||
берётся из новой анатомии, колени сгибаются в направлении исходной стойки.
|
||||
Сохранены IK стоп, повороты, остановки и отсутствие марша при блокировке.
|
||||
Уборка, швабра и рисование используют IK рук; кисти удерживают реквизит,
|
||||
переход к ходьбе сглажен. Напевание, звук, пауза и очистка реквизита сохранены.
|
||||
Капсула местных/соседних демонят увеличена до радиуса 0,34 м и высоты 1,18 м;
|
||||
межперсонажное разделение также учитывает ширину новой модели.
|
||||
|
||||
Проверено на Godot 4.3 / Vulkan, RTX 4070 SUPER:
|
||||
- `--test-imps`: PASS, 30/60/144 fps, две скорости, повороты, остановки,
|
||||
стопы, переходы действий, все 28 экземпляров, 14 костей, реальные skin binds,
|
||||
нормализованные веса и конечные ограниченные координаты всех вершин.
|
||||
- `--test-maintenance`: PASS, четыре действия, реквизит, прерывание, звук,
|
||||
пауза и очистка. Тест теперь обновляет кожу через gait при съёмке действий.
|
||||
- `--test-building`: PASS (24), столкновения, обход, перенос при строительстве.
|
||||
- `--test-sentences`: PASS, составные задания и маршруты помощниц.
|
||||
- `--test-workflow`: PASS (102), очередь, потери, размещение, расширения и посадки.
|
||||
- `--test-intro`: PASS, полная запись, блокировка/возврат управления и пауза.
|
||||
|
||||
Старый `--test-mode` НЕ PASS: существующий `workshop_tests.gd`, проверка #2,
|
||||
требует одну душу сразу после `start_game()` при пустом цехе. Это устаревшее
|
||||
ожидание уже отмечено выше: теперь души появляются после первого орудия.
|
||||
Этот старый сценарий не переписывался в рамках замены модели; актуальный
|
||||
workflow и sentences проходят. Не считать старый общий набор полностью зелёным.
|
||||
|
||||
Просмотрены игровые крупные планы покоя, шага и рабочих действий в
|
||||
`captures/imps-v02/`. Кадры и логи остаются локально. Новый EXE/ZIP не создавался.
|
||||
|
||||
@@ -47,3 +47,10 @@ powershell -ExecutionPolicy Bypass -File tools/build_v19.ps1
|
||||
История работы: `PROJECT_NOTES.md`.
|
||||
Лицензии и авторство ассетов: `Demon_v0.19/MODEL_CREDITS.md`,
|
||||
`Demon_v0.19/AUDIO_CREDITS.md` и файлы лицензий внутри проекта.
|
||||
|
||||
## Модель демонят
|
||||
|
||||
Все демонята используют пользовательскую модель болотного демона Meshy.
|
||||
К ней добавлены скелет, анимация ходьбы с опорой стоп и рабочие действия.
|
||||
Исходники и воспроизводимый импорт: `tools/build_swamp_imp.py`;
|
||||
проверка в Godot: `--test-imps`. Текущий EXE не обновлялся.
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
"""Import the supplied textured FBX, add a game rig, and export a skinned GLB.
|
||||
Run with Blender 5: blender -b --python tools/build_swamp_imp.py
|
||||
"""
|
||||
import bpy, json, hashlib
|
||||
from pathlib import Path
|
||||
from mathutils import Vector
|
||||
ROOT=Path(__file__).resolve().parents[1]
|
||||
SOURCE=next((ROOT/'tools/model_sources/swamp_demon').rglob('*.fbx'))
|
||||
OUT=ROOT/'Demon_v0.19/art/imps/swamp_v01';OUT.mkdir(parents=True,exist_ok=True)
|
||||
bpy.ops.wm.read_factory_settings(use_empty=True)
|
||||
bpy.ops.import_scene.fbx(filepath=str(SOURCE))
|
||||
mesh=next(o for o in bpy.context.scene.objects if o.type=='MESH')
|
||||
bpy.context.view_layer.objects.active=mesh;mesh.select_set(True)
|
||||
bpy.ops.object.transform_apply(location=True,rotation=True,scale=True)
|
||||
coords=[v.co.copy() for v in mesh.data.vertices];lo=min(v.z for v in coords);hi=max(v.z for v in coords)
|
||||
scale=1.28/(hi-lo)
|
||||
for v in mesh.data.vertices:v.co=Vector((v.co.x*scale,v.co.y*scale,(v.co.z-lo)*scale))
|
||||
# Joint positions use Godot's +Z forward and +Y up. Preserve the crouched silhouette.
|
||||
joints={
|
||||
'Body':([0,.57,-.10],None),
|
||||
'Head':([0,.78,.20],'Body'),
|
||||
'LegL':([-.24,.43,-.16],'Body'),'KneeL':([-.27,.27,-.20],'LegL'),'FootL':([-.28,.065,.16],'KneeL'),
|
||||
'LegR':([.24,.43,-.16],'Body'),'KneeR':([.27,.27,-.20],'LegR'),'FootR':([.28,.065,.16],'KneeR'),
|
||||
'ArmL':([-.35,.80,-.03],'Body'),'ElbowL':([-.46,.45,.12],'ArmL'),'HandL':([-.47,.16,.30],'ElbowL'),
|
||||
'ArmR':([.35,.80,-.03],'Body'),'ElbowR':([.46,.45,.12],'ArmR'),'HandR':([.47,.16,.30],'ElbowR')}
|
||||
def bv(p):return Vector((p[0],-p[2],p[1]))
|
||||
tips={'Body':[0,1.02,-.25],'Head':[0,.78,.55]}
|
||||
for side,sign in [('L',-1),('R',1)]:
|
||||
tips['Leg'+side]=joints['Knee'+side][0];tips['Knee'+side]=joints['Foot'+side][0];tips['Foot'+side]=[sign*.28,.065,.39]
|
||||
tips['Arm'+side]=joints['Elbow'+side][0];tips['Elbow'+side]=joints['Hand'+side][0];tips['Hand'+side]=[sign*.47,.06,.40]
|
||||
armdata=bpy.data.armatures.new('SwampRig');arm=bpy.data.objects.new('SwampRig',armdata);bpy.context.collection.objects.link(arm)
|
||||
bpy.context.view_layer.objects.active=arm;mesh.select_set(False);arm.select_set(True);bpy.ops.object.mode_set(mode='EDIT')
|
||||
for name,(head,parent) in joints.items():
|
||||
b=armdata.edit_bones.new(name);b.head=bv(head);b.tail=bv(tips[name]);
|
||||
if parent:b.parent=armdata.edit_bones[parent]
|
||||
bpy.ops.object.mode_set(mode='OBJECT')
|
||||
# Heat weights follow connected anatomy around shoulders, hips and elbows.
|
||||
bpy.ops.object.select_all(action='DESELECT');mesh.select_set(True);arm.select_set(True);bpy.context.view_layer.objects.active=arm
|
||||
bpy.ops.object.parent_set(type='ARMATURE_AUTO')
|
||||
assert any(len(v.groups)>0 for v in mesh.data.vertices),'Automatic weights failed'
|
||||
# The crouched source has hands almost touching feet. Prevent heat bleeding
|
||||
# between those close surfaces while retaining the shoulder/hip heat solution.
|
||||
for v in mesh.data.vertices:
|
||||
x=abs(v.co.x);h=v.co.z;forward=-v.co.y;side='R' if v.co.x>0 else 'L'
|
||||
allowed=None
|
||||
if x<.14 and forward>.32:allowed=['Head']
|
||||
elif h<.50 and x<.37 and x>.13:allowed=['Body','Leg'+side,'Knee'+side,'Foot'+side]
|
||||
elif h>1.03:allowed=['Head'] if forward>.10 else ['Body']
|
||||
elif h>.50 and x<.30 and forward<.05:allowed=['Body']
|
||||
elif h<.48 and x>.40:allowed=['Arm'+side,'Elbow'+side,'Hand'+side]
|
||||
elif h<.53 and x<.30 and forward<.22:allowed=['Body','Leg'+side,'Knee'+side,'Foot'+side]
|
||||
elif x<.14 and forward>.32:allowed=['Head']
|
||||
if allowed is None:continue
|
||||
scores={mesh.vertex_groups[g.group].name:g.weight for g in v.groups if mesh.vertex_groups[g.group].name in allowed}
|
||||
total=sum(scores.values())
|
||||
if total<.00001:
|
||||
def dist(n):
|
||||
a=bv(joints[n][0]);b=bv(tips[n]);d=b-a;t=max(0,min(1,(v.co-a).dot(d)/d.length_squared));return (v.co-a-d*t).length
|
||||
scores={n:1/(.025+dist(n))**5 for n in allowed};total=sum(scores.values())
|
||||
for group in mesh.vertex_groups:group.remove([v.index])
|
||||
for n,w in scores.items():mesh.vertex_groups[n].add([v.index],w/total,'REPLACE')
|
||||
|
||||
# Relax the region boundaries over mesh edges, then keep four normalized
|
||||
# influences explicitly so the exported skin matches the editable source.
|
||||
adj=[set() for _ in mesh.data.vertices]
|
||||
for edge in mesh.data.edges:
|
||||
a,b=edge.vertices;adj[a].add(b);adj[b].add(a)
|
||||
weights=[{g.group:g.weight for g in v.groups} for v in mesh.data.vertices]
|
||||
for _ in range(8):
|
||||
relaxed=[]
|
||||
for i,w in enumerate(weights):
|
||||
mixed={n:v*.65 for n,v in w.items()}
|
||||
for j in adj[i]:
|
||||
for n,v in weights[j].items():mixed[n]=mixed.get(n,0)+v*.35/max(1,len(adj[i]))
|
||||
relaxed.append(mixed)
|
||||
weights=relaxed
|
||||
for v,w in zip(mesh.data.vertices,weights):
|
||||
pairs=sorted(w.items(),key=lambda p:p[1],reverse=True)[:4];total=sum(w for _,w in pairs)
|
||||
assert total>.00001,'Unweighted vertex'
|
||||
for group in mesh.vertex_groups:group.remove([v.index])
|
||||
for n,w in pairs:mesh.vertex_groups[n].add([v.index],w/total,'REPLACE')
|
||||
|
||||
# FBX may use relative image paths; explicitly bind the provided colour texture.
|
||||
tex=next(SOURCE.parent.glob('*.png'));img=bpy.data.images.load(str(tex),check_existing=True)
|
||||
for mat in mesh.data.materials:
|
||||
mat.use_nodes=True;nodes=mat.node_tree.nodes;bs=next(n for n in nodes if n.type=='BSDF_PRINCIPLED')
|
||||
image=next((n for n in nodes if n.type=='TEX_IMAGE'),None) or nodes.new('ShaderNodeTexImage');image.image=img
|
||||
mat.node_tree.links.new(image.outputs['Color'],bs.inputs['Base Color']);bs.inputs['Roughness'].default_value=.86
|
||||
img.pack()
|
||||
mesh.name='SwampDemon';mesh.data.name='SwampDemonMesh'
|
||||
for p in mesh.data.polygons:p.use_smooth=True
|
||||
bpy.ops.wm.save_as_mainfile(filepath=str(ROOT/'tools/model_sources/swamp_demon/swamp_imp.blend'))
|
||||
bpy.ops.export_scene.gltf(filepath=str(OUT/'swamp_imp.glb'),export_format='GLB',export_yup=True,export_animations=False,export_apply=False)
|
||||
manifest={'source_file':SOURCE.name,'source_sha256':hashlib.sha256(SOURCE.read_bytes()).hexdigest(),'texture_sha256':hashlib.sha256(tex.read_bytes()).hexdigest(),'vertices':len(mesh.data.vertices),'triangles':sum(len(p.vertices)-2 for p in mesh.data.polygons),'height':1.28,'joints':{n:{'position':h,'parent':p or ''} for n,(h,p) in joints.items()},'animation':'Runtime imp_gait.gd IK and imp_activities.gd; original FBX has no rig or clips.'}
|
||||
(OUT/'manifest.json').write_text(json.dumps(manifest,ensure_ascii=False,indent=2),encoding='utf-8')
|
||||
print('SWAMP_EXPORT',json.dumps(manifest))
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
|
After Width: | Height: | Size: 3.1 MiB |
Binary file not shown.
Reference in New Issue
Block a user