@Raph was asking for help with getting the script running.
Hi, what kind of error(s) are you getting? How far in the process did you get?
Fast 2D mesh animation
Re: Fast 2D mesh animation
Hello, I keep getting this error when I try to export a mesh. I don't know if the script is causing the error or I'm doing something wrong.
Edit: Is it also possible to get the script working on newer Blender versions?
Edit: Is it also possible to get the script working on newer Blender versions?
Re: Fast 2D mesh animation
Hi Raph, thanks for the info.
That error is from the script trying to do things that only work on 2.79, so for it to work on Blender 2.8x or 3.x it'd need to be ported.
Are you in any hurry? I think I can do this over this week.
That error is from the script trying to do things that only work on 2.79, so for it to work on Blender 2.8x or 3.x it'd need to be ported.
Are you in any hurry? I think I can do this over this week.
Re: Fast 2D mesh animation
Hello, Nope I'm not in a hurry. Thank you so much for the help!
Re: Fast 2D mesh animation
Re: Fast 2D mesh animation
@darkfrei hi, that's a different one, it exports the scene to the glTF format and is very complete (supports many node types).
The script we're talking about (that I'll update to the latest Blender) exports a mesh and skeleton to a .lua file to be loaded with love.filesystem.load(), with the data described in Lua tables. This way we just use the built-in parser for Lua files, heh.
Those data tables are then used in the modelLib.loadModel() function to prepare data that the rest of the demo uses: https://github.com/RNavega/2DMeshAnimat ... a#L10-L116
Ideally you'd adapt the animation code to animate a model created from glTF or FBX files so you can use the official Blender exporters (and maybe ship your game with some efficient compressed model data instead of these interchange fornats).
The purpose of the demo is to show how to animate it as fast as Löve and Lua allows. This makes me think I posted this in the wrong forum section, it should've been Libraries & Tools.
The script we're talking about (that I'll update to the latest Blender) exports a mesh and skeleton to a .lua file to be loaded with love.filesystem.load(), with the data described in Lua tables. This way we just use the built-in parser for Lua files, heh.
Those data tables are then used in the modelLib.loadModel() function to prepare data that the rest of the demo uses: https://github.com/RNavega/2DMeshAnimat ... a#L10-L116
Ideally you'd adapt the animation code to animate a model created from glTF or FBX files so you can use the official Blender exporters (and maybe ship your game with some efficient compressed model data instead of these interchange fornats).
The purpose of the demo is to show how to animate it as fast as Löve and Lua allows. This makes me think I posted this in the wrong forum section, it should've been Libraries & Tools.
Re: Fast 2D mesh animation
@Raph I've update io_scene_lua.py for Blender, it's in here: https://github.com/RNavega/2DMeshAnimat ... r%20Add-on
I used a technique from my other add-ons, branching the code depending on the Blender version. This means that this single script works on all major Blender versions, from 2.79 and up including 3.X.
-----
I've also updated the demo code. After profiling a lot (a lot), I noticed that if I replaced a pairs() call in the middle of the speed-critical code by the equivalent using a numerical index, it became much faster -- I'm thinking because the LuaJIT optimizations were finally able to kick in, whereas they couldn't do that with that pair() call in there.
After more profiling and using the mesh:setVertices() overload that takes in a Data object for the vertex attributes (instead of a Lua table of tables), the overall speed improvement is about 4x. Pretty cool.
Other things:
• The exporter now produces a different file structure that supports multiple UV sets and vertex color sets, as well as multiple objects in the same scene (the previous version tried to merge them all as one huge mesh and one huge armature).
• All bones are exported as parentless floating objects, having world-space coordinates. If you want bone parenting then you'd have to implement a bone hierarchy (making transforms be relative to each other). This would let you do things like real-time IK chains, ragdoll physics and such. Both the exporter and the Lua demo code would have to be modified to support this.
• Because of the speed improvements to the CPU skinning method I removed references to the GPU skinning method. The file is still in the repo for reference, it's just not used because it'd have to be updated to use the new model format and that is homework for whoever is interested in that (like using data textures and vertex-texture-fetching in the vertex shader for having access to lots of shape keys and bones). The CPU skinning method is enough for my needs.
I noticed that LÖVE 12.X will introduce a new vertex buffer API but it will still be compatible with this code. I think it'll involve setting up the buffer and replacing mesh:setVertices() with the new vertex buffer call.
I used a technique from my other add-ons, branching the code depending on the Blender version. This means that this single script works on all major Blender versions, from 2.79 and up including 3.X.
-----
I've also updated the demo code. After profiling a lot (a lot), I noticed that if I replaced a pairs() call in the middle of the speed-critical code by the equivalent using a numerical index, it became much faster -- I'm thinking because the LuaJIT optimizations were finally able to kick in, whereas they couldn't do that with that pair() call in there.
After more profiling and using the mesh:setVertices() overload that takes in a Data object for the vertex attributes (instead of a Lua table of tables), the overall speed improvement is about 4x. Pretty cool.
Other things:
• The exporter now produces a different file structure that supports multiple UV sets and vertex color sets, as well as multiple objects in the same scene (the previous version tried to merge them all as one huge mesh and one huge armature).
• All bones are exported as parentless floating objects, having world-space coordinates. If you want bone parenting then you'd have to implement a bone hierarchy (making transforms be relative to each other). This would let you do things like real-time IK chains, ragdoll physics and such. Both the exporter and the Lua demo code would have to be modified to support this.
• Because of the speed improvements to the CPU skinning method I removed references to the GPU skinning method. The file is still in the repo for reference, it's just not used because it'd have to be updated to use the new model format and that is homework for whoever is interested in that (like using data textures and vertex-texture-fetching in the vertex shader for having access to lots of shape keys and bones). The CPU skinning method is enough for my needs.
I noticed that LÖVE 12.X will introduce a new vertex buffer API but it will still be compatible with this code. I think it'll involve setting up the buffer and replacing mesh:setVertices() with the new vertex buffer call.
Who is online
Users browsing this forum: Google [Bot] and 5 guests