-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlibrary_items.py
More file actions
69 lines (57 loc) · 1.85 KB
/
Copy pathlibrary_items.py
File metadata and controls
69 lines (57 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
"""
Library items for the Humanoid plugin.
Registers the humanoid model as a library item that can be
dragged into the scene from the Library panel.
"""
from pathlib import Path
from witwin_server import Library, SceneObject
# Get the path to the model file (relative to this plugin)
PLUGIN_DIR = Path(__file__).parent
MODEL_PATH = PLUGIN_DIR / "models" / "humanbody.glb"
_CATEGORY = "basic"
def _make_smpl_body(ctx):
from witwin_server.core.components import PlatformGeometryComponent
from .components.smpl import SMPLBodyComponent
obj = SceneObject(name=ctx.name, mesh_type="Empty")
body = SMPLBodyComponent()
geom = PlatformGeometryComponent()
geom.kind = "smpl"
obj.add_component(body)
obj.add_component(geom)
body.sync_platform_geometry()
obj.get_component("Transform").position = list(ctx.position)
return obj
def _make_smpl_motion(ctx):
from .components.smpl import SMPLMotionComponent
obj = SceneObject(name=ctx.name, mesh_type="Empty")
obj.add_component(SMPLMotionComponent())
obj.get_component("Transform").position = list(ctx.position)
return obj
# Register the humanoid prefab in the basic category
Library.register_item(
id="humanoid",
name="Humanoid",
category=_CATEGORY,
icon="person-standing",
description="A rigged humanoid model with skeleton",
model_path=str(MODEL_PATH),
object_type="mesh"
)
Library.register_item(
id="smpl_body",
name="SMPL Body",
category=_CATEGORY,
icon="person-standing",
description="SMPL body parameters owned by wt_humanoid",
object_type="empty",
factory=_make_smpl_body,
)
Library.register_item(
id="smpl_motion",
name="SMPL Motion",
category=_CATEGORY,
icon="activity",
description="AMASS/SMPL .npz motion source that drives an SMPL Body",
object_type="empty",
factory=_make_smpl_motion,
)