New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposing SV Shape Keys Output Node #1589
Comments
However, suddenly I realize something: However, common Blender workflow maybe nice if Sverchok can modify Shape Keys data, somewhat. |
When manually adjusting Shapekeys apparently we can use "Pin" and edit that Shapekey. |
It seems to me that shape keys only make sense on a static object, an object that has no changes to topology. |
I don't know of any barrier to making a node that operates on a single object and sets its shape keys, but because I have little experience with them I fail to see the usefulness. Show some pics |
Above are the example scenario.
In Sverchok node tree, I think Vector Lerp node can probably simulate Shapekeys, maybe... not sure if that is exactly the same. If we can somewhat have Sverchok node to control the "applied shape key mesh data", then we have some kind of powerful flexibility, creating a "live" shape keys. A Blender artist friend told me that the usual workflow if we want to edit Shape Key is to just Edit Mode the Shape Keys. This is like my question before if we can somewhat pass the data back into the original Mesh Data. Which might cause cycle. But in this case, it will not create cyclic dependency because Sverchok juga goes into the Shapekey data. |
@Kosvor2 this is not working isnt it? |
Wow.. this actually works ... Ok, maybe I will try to further experiment with it. |
it crashes somehow. """
in verts v .=[] n=0
in edges s .=[] n=0
in pols s .=[] n=0
in active s .=0 n=2
in frame s .=1 n=2
"""
import bpy
import bmesh
from mathutils import Vector
#for remove extra brecket
def okok(a):
if a:
return a[0]
verts = okok(verts)
edges = okok(edges)
pols = okok(pols)
# main function
def make():
# find mesh or create
if not 'sv_shape_key' in bpy.data.meshes:
mesh = bpy.data.meshes.new('sv_shape_key')
mesh.from_pydata(verts,edges,pols)
else:
mesh = bpy.data.meshes['sv_shape_key']
# find object or create
if not 'sv_shape_key' in bpy.data.objects:
obj = bpy.data.objects.new("sv_shape_key", mesh)
bpy.context.scene.objects.link(obj)
else:
obj = bpy.data.objects['sv_shape_key']
#bmesh from scene's object
bm = bmesh.new()
bm.from_mesh(obj.data)
bm.verts.ensure_lookup_table()
bm.edges.ensure_lookup_table()
bm.faces.ensure_lookup_table()
# name of new shape from frame number
#i = bpy.context.scene.frame_current
kn = "sverchok %d"%frame
# make shape key basis at first
if 'Basis' not in bm.verts.layers.shape:
sk0 = obj.shape_key_add("Basis")
for i,v in enumerate(verts):
bm.verts[i][sk0] = Vector(v)*(-1)
#print(sk0)
#sk0 = obj.data.shape_keys
#print(sk0)
sk0.use_relative = False # maybe yes
#if len(bm.verts) != len(verts):
# return
if kn not in bm.verts.layers.shape:
#addShapeKey(obj, verts,edges,pols, bpy.context.scene.frame_current)
sl = bm.verts.layers.shape.new(kn)
sk = obj.shape_key_add(kn)
#sl.use_relative = False
#sl = bm.verts.layers.shape.get(kn)
#print(sl, 'also what is it?')
for i,v in enumerate(verts):
bm.verts[i][sl] = Vector(v)
bm.verts.ensure_lookup_table()
bm.to_mesh(obj.data)
if active and verts:
make() |
next will try @enzyme69 approach with this SNL |
ok, will put it now in SNL templates for a while. """
in verts v .=[] n=0
in edges s .=[] n=0
in pols s .=[] n=0
in active s .=0 n=2
in frame s .=1 n=2
"""
import bpy
import bmesh
from mathutils import Vector
#for remove extra brecket
def okok(a):
if a:
return a[0]
verts = okok(verts)
edges = okok(edges)
pols = okok(pols)
# main function
def make():
# find mesh or create
if not 'sv_shape_key' in bpy.data.meshes:
mesh = bpy.data.meshes.new('sv_shape_key')
mesh.from_pydata(verts,edges,pols)
else:
mesh = bpy.data.meshes['sv_shape_key']
# find object or create
if not 'sv_shape_key' in bpy.data.objects:
obj = bpy.data.objects.new("sv_shape_key", mesh)
bpy.context.scene.objects.link(obj)
else:
obj = bpy.data.objects['sv_shape_key']
# shapekeys adding
# make shape key basis at first
if not obj.data.shape_keys:
sk0 = obj.shape_key_add(name='Basis')
key = bpy.data.shape_keys[obj.data.shape_keys.name]
key.use_relative = False
# name of new shape from frame number
kn = "sverchok %d"%frame
# check for equal length of vertices
if len(obj.data.vertices) != len(verts):
return
# current frame to add
if kn not in key.key_blocks:
sk = obj.shape_key_add(kn)
for i,v in enumerate(verts):
key.key_blocks[kn].data[i].co = Vector(v)
if active and verts:
make()
#bpy.data.shape_keys[obj.data.shape_keys.name].key_blocks[kn].data[:].co |
now it only create, not rewrite shapes. But in full-node it will be, i guess. |
Shape Keys can become "intermediate object mesh" if user want to have
object A but want it to be object X. A to X with "join as shapes".
|
in master as snl |
I am not sure how Blender Shape Keys work internally. Or how its Shape Keys data got linked into the original object. My feeling is that Blender Shape Keys object data is "dead" once linked into original object.
In Maya or Houdini, Shape Keys itself is something that is always hooked.
My curiosity is that: can the "dead" Shape Keys data be modified... using Sverchok? Maybe Sverchok can be the "live data" that continuously updating the data in Shape Keys, this way, we can make Sverchok to act more or less like Modifier, if only the mesh data of original object matches the Sverchok data.
What do you all think? Good idea? Yay or Nay?
The text was updated successfully, but these errors were encountered: