-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmorph_by_dp.py
More file actions
36 lines (28 loc) · 961 Bytes
/
Copy pathmorph_by_dp.py
File metadata and controls
36 lines (28 loc) · 961 Bytes
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
import bpy
from mathutils.kdtree import KDTree
from mathutils import Vector
def my_handler(scene):
from_name='tire'
to_name='tire.001'
tgt_name='tire.002'
from_obj=scene.objects[from_name]
to_obj=scene.objects[to_name]
tgt_obj=scene.objects[tgt_name]
from_mesh=from_obj.data
to_mesh=to_obj.data
tgt_mesh=tgt_obj.data
dp = from_mesh.vertex_colors['dp_paintmap'].data
for i in range(len(from_mesh.vertices)):
t = dp[i].color.r
co = from_mesh.vertices[i].co * (1 - t) + \
to_mesh.vertices[i].co * (t)
no = from_mesh.vertices[i].normal * (1 - t) + \
to_mesh.vertices[i].normal * (t)
tgt_mesh.vertices[i].co = co
tgt_mesh.vertices[i].normal = no
scene.update()
def register():
bpy.app.handlers.frame_change_post.append(my_handler)
def unregister():
bpy.app.handlers.frame_change_post.remove(my_handler)
register()