pablodp606 / keymesh-addon Goto Github PK
View Code? Open in Web Editor NEWLicense: GNU General Public License v3.0
License: GNU General Public License v3.0
Hi there, also ccing in @AldrinMathew, this is not an issue so much as a question. I've been writing an exporter for keymesh for use in Unity, and I've stumbled into a problem where I'm trying to get the list of materials names used each keyframe. The problem seems to be that this list isn't updated with all the materials when I iterate across it in the exporter. I'm not entirely sure how to solve this or even why it's happenening. The output is also currently dependent on what frame is selected in the scrubber.
Below is some of my exporter code:
class KeyframeMeshObjExport(bpy.types.Operator, ExportHelper):
bl_idname = "object.keyframe_mesh_obj"
bl_label = "Export Obj Sequence"
bl_options = {'REGISTER'}
filename_ext = ".obj"
@classmethod
def poll(cls, context):
# It's a Keymesh scene
for o in bpy.context.selected_objects:
if "km_datablock" and "km_id" in o:
return True
return False
def execute(self, context):
frame_end = -99999
frame_start = 99999
current_frame = bpy.context.scene.frame_current
obs = list(bpy.context.selected_objects)
objects = []
framerate = 11
# Get length of the current action
for o in obs:
framerate = o.users_scene[0].render.fps
this_end = o.users_scene[0].frame_end
this_start = o.users_scene[0].frame_start
if(this_end > frame_end):
frame_end = this_end
if(this_start < frame_start):
frame_start = this_start
file_path = Path(self.filepath)
folder_path = file_path.parent
materials = {}
bpy.ops.object.select_all(action='DESELECT')
for o in obs:
keyframes=[]
o.select_set(True)
object_material_slots={}
for i in range(frame_start, frame_end + 1):
bpy.context.scene.frame_current = i
km_frame_handler(0)
updateKeymesh(bpy.context.scene)
dirty = False
fcurves = o.animation_data.action.fcurves
for fcurve in fcurves:
if fcurve.data_path != '["km_datablock"]':
continue
for keyframe in fcurve.keyframe_points:
if i == int(keyframe.co.x):
dirty = True
break
if dirty:
frame_materials=[]
# The line in question that doesn't seem to be updating:
for mat in o.material_slots:
materials[mat.name] = True
object_material_slots[mat.name] = True
frame_materials.append(mat.name)
keyframes.append({"frame":i, "materials": list(frame_materials) })
filename = str(Path(str(folder_path.absolute()) +"/" + re.sub(r'\.obj$',"_",file_path.name) + o.name + "_" + str(i) + ".obj").absolute())
bpy.ops.export_scene.obj(filepath=filename, use_materials=True, use_selection=True, use_blen_objects=True, group_by_object=True)
o.select_set(False)
objects.append({
"name": o.name,
"keyframes": list(keyframes),
"materials": list(object_material_slots.keys())
})
json_data_filename = str(Path(str(folder_path.absolute()) +"/" + file_path.name + ".objseq").absolute())
with open(json_data_filename, 'w') as outfile:
json.dump({
"materials": list(materials.keys()),
"frame_start": frame_start,
"frame_end": frame_end,
"frame_rate": framerate,
"objects": list(objects)
}, outfile)
bpy.context.scene.frame_current = current_frame
km_frame_handler(0)
return {'FINISHED'}
This is the output of this script in an example project I'm working on. There should be five materials in frame 63, but only three show up. The actual exported obj has space for 5 materials:
{
"materials": [
"EggMaterial",
"GooMaterial",
"PlantMaterial"
],
"frame_start": 1,
"frame_end": 80,
"frame_rate": 24,
"objects": [
{
"name": "Sphere",
"keyframes": [
{
"frame": 1,
"materials": [
"EggMaterial"
]
},
{
"frame": 3,
"materials": [
"EggMaterial"
]
},
{
"frame": 5,
"materials": [
"EggMaterial"
]
},
{
"frame": 7,
"materials": [
"EggMaterial"
]
},
{
"frame": 9,
"materials": [
"EggMaterial"
]
},
{
"frame": 11,
"materials": [
"EggMaterial",
"GooMaterial"
]
},
{
"frame": 13,
"materials": [
"EggMaterial",
"GooMaterial"
]
},
{
"frame": 15,
"materials": [
"EggMaterial",
"GooMaterial"
]
},
{
"frame": 17,
"materials": [
"EggMaterial",
"GooMaterial"
]
},
{
"frame": 19,
"materials": [
"EggMaterial",
"GooMaterial"
]
},
{
"frame": 21,
"materials": [
"EggMaterial",
"GooMaterial"
]
},
{
"frame": 23,
"materials": [
"EggMaterial",
"GooMaterial"
]
},
{
"frame": 25,
"materials": [
"EggMaterial",
"GooMaterial"
]
},
{
"frame": 27,
"materials": [
"EggMaterial",
"GooMaterial"
]
},
{
"frame": 29,
"materials": [
"EggMaterial",
"GooMaterial"
]
},
{
"frame": 31,
"materials": [
"EggMaterial",
"GooMaterial"
]
},
{
"frame": 51,
"materials": [
"EggMaterial",
"GooMaterial"
]
},
{
"frame": 53,
"materials": [
"EggMaterial",
"GooMaterial"
]
},
{
"frame": 55,
"materials": [
"EggMaterial",
"GooMaterial",
"PlantMaterial"
]
},
{
"frame": 57,
"materials": [
"EggMaterial",
"GooMaterial",
"PlantMaterial"
]
},
{
"frame": 59,
"materials": [
"EggMaterial",
"GooMaterial",
"PlantMaterial"
]
},
{
"frame": 61,
"materials": [
"EggMaterial",
"GooMaterial",
"PlantMaterial"
]
},
{
"frame": 63,
"materials": [
"EggMaterial",
"GooMaterial",
"PlantMaterial"
]
}
],
"materials": [
"EggMaterial",
"GooMaterial",
"PlantMaterial"
]
}
]
}
Would good to see this addon work with curves
Hi there
I'm extremely excited for this add on as I've been independently working on a game that utilizes sequences of meshes for character animation. Keymesh adds some really nice workflow improvements however I cannot use it yet as the animations don't yet allow export to a format usable by my game engine (Unity).
For me the natural way to use keymesh is mixing it with shapekeys to achieve smooth transitions and reduce work with simple inbetweens.
But I`ve encountered issue, when I was making my first keymesh project
Here is videolog and explanation
In short: at 1st frame of shapekey, where animation key is 0, it jumps to 1 instead, and on the previous frame keymesh frame do not appear (previous state instead).
You can launch animation from this file or render it to frames.
keymesh-shapekey mix.zip
Here is my render result (2nd and 3rd are wrong, compare with viewport manual frame switching):
FramesRendered.zip
Currently, exporting a keymeshed mesh results in a static alembic mesh. This is important to be able to export the animation out of Blender.
Creating a key frame on a mesh with a blendshape will remove the blendshape.
This occured after opening an already working animation:
"Initialize Frame Handler" does not solve issue
Blender Version 2.93
Keymesh Version 0.1.2
I found this while testing. This is a serious bug that prevents the Addon from functioning properly.
The sculpt settings reset every time the Keyframe Mesh operator is used.
This is a superset of #2.
I spent about 3 hours on this.
The addon will not install for me on osx with the zip file.
Finally I just loaded keymesh-addon-main.py in my addons folder, and installed in blender
navigating straight to that .py file.
Something about the structure of the .zip file is not allowing it to show up in 'addons' in blender user prefs.
I dont know the reason why it is not working. as i click on Keymesh button it just add key but don't make key slider forward. also, still if i manually forwarded the slider and insert another key it just again add the key but as i play animation nothing happens.
Using blender -b file.blend -a
doesn't render out animation as expected the animation just stay still.
https://docs.blender.org/manual/en/latest/advanced/command_line/render.html
Github now allows users to "watch" for updates solely on updates and its really useful to get updates on Blender addons when they're updated.
A friend of mine was using this on Mac, and encountered problems with using it. He made a recording showing his use, and the different results coming from different modes.
https://www.dropbox.com/s/5is0vw47a1i00eg/keymesh_bug.mov?dl=0
I don't know personally if this is a Keymesh issue or something with Blender itself. It is a possibility a fix can't be found from this side. If a fix can't be found within Keymesh, I'll ask on the Blender page.
Thank you guys for your time and for this plugin.
Hello, first of all big tnx for this plugin.
Blender 2.93.5, mac os big sur, eevee render/workbench render
Problem: Keymesh datablocks couldn't refresh while render export. It's works good in viewport while timeline play. But it doesn't render any datablocs change while final export animation.
see sample
test_keymesh.blend.zip
I thought this might help with simple animations of, say, mouths. So, I added Suzanne to see what could be achieved.
If keying a timeline, it appears fine. But to lip sync a whole sequence, that would be messy. So I thought maybe individual mesh key frames, for each mouth shape, captured as individual actions. I am hoping then to set up to animate through action selections.
Therefore, I am trying to save actions comprising individual mesh sculpts (assigned to AI, E, etc, FV, L, BMP, yadda),
I am essentially creating a new action for each sculpted mesh, with a single key frame. Furthermore, I have the frame set to "1" for each key frame capture.
I find, all actions end up with the same mesh layout?
That is, for example, I'll sculpt a "rest"mesh for the resting mouth, then save that as an action called "rest", I then sculpt an "AI" mesh, save that as an action "AI". If I then reassign "rest" the "AI" sculpt remains. If I then sculpt an "E" mesh, "rest" and "AI" mesh actions present as "E" mesh.
I assume this has something to do with the internals of the key frame and the way it's captured? It isn't intuitive?
Am I barking up the wrong tree trying to use the add-in this way?
.
Using the "Keymesh Addon" with "Anim All Addon" causes a crash.
The idea was to use curves with grease pencil line art modifier to create a 2D character.
A very specific example would be creating different mouth shapes and being able to switch them out using key mesh.
"Anim All Addon" comes into play when tweening from one mouth shapes to the next.
Lets say mouth shape A (4 points) is on frame 10, and uses the "Anim All Addon" to tween to Frame 20, mouth shape B. Easy enough.
Now if we want frame 20 to use 3 times the amount of points ideally we would be able to cheat it using the "Keymesh Addon" using the animation principle cut on the action.
At the moment both addons are storing the information in 2 very different ways.
Combining these addons means tweening curves and meshes and the ability to "switch and tween" on breakdown keys for seamless tweening. This would make curves more robust and reliable than Grease Pencils and offer more functionality taking advantage of Grease Pencil, EEVEE, and Geometry Nodes with minimal code to maintain.
Happy to get online and talk to you more about this showing animation examples and how the UI might be able to be improved for animators if Blender if is capable of doing it.
Hi there, this add-on is lovely 💜, is there a chance you could implement a shortcut for Keyframe Mesh
? If this is the case can it be mapped by the user? This would be super appreciated for speeding up workflow! 🤓✨
when i keyframe mesh i'm getting inconsistent behavior. sometimes the keyframe appears, but it doesn't actually save the mesh vertex positions. I also tried making a keyframe mesh every 10 frames and which positions were saved for each keyframe kept flipping around and weren't what i set it as...
seems like a really cool add-on. If you end up fixing this it would be much appreciated.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.