Skeletal animation for ZGE
Moderator: Moderators
Skeletal animation for ZGE
Hi all,
after one afternoon of learning, implementation and testing I finally added skeletal animation to ZGE. The provided external library ZgeSkelet is build as a wrapper to skeletal-based 3D character animation library Cal3D, which is very easy to understand, build and integrate. (That's the reason why all of this has taken such a short time.) In addition, ZgeSkelet provides also a helper for rendering animated meshes directly by VBOs. For now, I have the 1st experimental version of the library for Windows, but I hope it can easily be compiled also for Android.
The demo project can be downloaded from this link. To change cyclic animations, press keys 1 - 5; to activate action animations press 6 or 7. Action animations have higher priority than cyclic animations, but they both run at the same time (animations can overlap). The demo contains the ZGE project, ZgeSkelet.dll, and animation resource files. The resource files are taken from Cal3D examples, but you can create your own with Blender + Cal3D exporting plugin; or with 3D Max if you have it.
You can learn more about Cal3D from this page. It will give you hints how to use ZgeSkelet external library.
The library is still not complete. As next, I plan to improve management of materials and their usage for sub-meshes, because now all meshes of the animated model can have only one material. Also, loading of animation resources from memory will further be explored. Later it will appear on Google Code, so you can check also its implementation and compile it by yourself.
Any comments are welcome. Thanks.
Rado1.
after one afternoon of learning, implementation and testing I finally added skeletal animation to ZGE. The provided external library ZgeSkelet is build as a wrapper to skeletal-based 3D character animation library Cal3D, which is very easy to understand, build and integrate. (That's the reason why all of this has taken such a short time.) In addition, ZgeSkelet provides also a helper for rendering animated meshes directly by VBOs. For now, I have the 1st experimental version of the library for Windows, but I hope it can easily be compiled also for Android.
The demo project can be downloaded from this link. To change cyclic animations, press keys 1 - 5; to activate action animations press 6 or 7. Action animations have higher priority than cyclic animations, but they both run at the same time (animations can overlap). The demo contains the ZGE project, ZgeSkelet.dll, and animation resource files. The resource files are taken from Cal3D examples, but you can create your own with Blender + Cal3D exporting plugin; or with 3D Max if you have it.
You can learn more about Cal3D from this page. It will give you hints how to use ZgeSkelet external library.
The library is still not complete. As next, I plan to improve management of materials and their usage for sub-meshes, because now all meshes of the animated model can have only one material. Also, loading of animation resources from memory will further be explored. Later it will appear on Google Code, so you can check also its implementation and compile it by yourself.
Any comments are welcome. Thanks.
Rado1.
- Attachments
-
- scr.jpg (57.33 KiB) Viewed 28319 times
A small update: loaded materials can be identified by user IDs and these material IDs can be retrieved by zsk_GetSubmeshUserMaterialId() function. This mechanism can be used during rendering to switch among different materials used for rendering sub-meshes. This is more effective than switching materials by texture file names as used up to now.
The ZgeSkeletDemo2 has been updated accordingly. Demos can be downloaded from this link.
The ZgeSkeletDemo2 has been updated accordingly. Demos can be downloaded from this link.
Added support for loading resources from memory, i.e., the functions:
All these functions require an byte[] array with the content of animation resource file. Thanks to "power" of ZGE scripting language, it was possible to write quite a nice code which can load files by ZGE and then to pass them to ZgeSkelet library. I mean the following:
Nice, isn't it? (Ville, Kjell is it correct?) Thanks to this feature, I was also able to port the ZgeSkelet library to Android, because it was not possible to use the functions which load animation resources directly from files (zsk_Load*()) - they are working only on Windows. Since ZGE is able to load files from Windows and also from Android seamlessly, the current solution is portable and very elegant. Originally I started to implement loading files for Android by NDK, by it required some dirty and non-flexible JNI programming.
The previously mentioned download link contains now updated DLL, the Android shared library compiled for armeabi-v7a, and updated demo projects. The demo project #1 can be compiled also for Android - just copy the libZgeSkelet.so to the libs/armeabi folder and copy the skeleton folder with animation resources to the assets folder; then recompile Android apk again and install on device. If you do not want to compile by yourself, use the included Skelet Demo 1-debug.apk.
Code: Select all
int zsk_LoadSkeletonBuffer(int coreModel, xptr buffer) {}
int zsk_LoadAnimationBuffer(int coreModel, xptr buffer) {}
int zsk_LoadMeshBuffer(int coreModel, xptr buffer) {}
int zsk_LoadMaterialBuffer(int coreModel, int userId, xptr buffer) {}
Code: Select all
const string RESDIR = ANDROID ? "/assets/skeleton/" : "skeleton\\";
byte[] fileBuffer;
/ load file and store it in a buffer which is then returned
byte[] load(string filename){
@FileAction(File:
@File(FileName: RESDIR + filename, Encoding: 1, TargetArray: fileBuffer),
Action : 0);
return fileBuffer;
}
// load skeleton
zsk_LoadSkeletonBuffer(SkeletonCoreModel, load("skeleton.csf"));
...
The previously mentioned download link contains now updated DLL, the Android shared library compiled for armeabi-v7a, and updated demo projects. The demo project #1 can be compiled also for Android - just copy the libZgeSkelet.so to the libs/armeabi folder and copy the skeleton folder with animation resources to the assets folder; then recompile Android apk again and install on device. If you do not want to compile by yourself, use the included Skelet Demo 1-debug.apk.
- Attachments
-
- screenshot from Nexus 7
- scr3.jpg (22.67 KiB) Viewed 28269 times
ZgeSkelet project has been added to Google code: http://code.google.com/p/zgeskelet/
Among source code, compilation instructions and version history, the project contains also the description how to use skeletal animation in ZGE projects, including Android apps: http://code.google.com/p/zgeskelet/wiki/HowTo
Among source code, compilation instructions and version history, the project contains also the description how to use skeletal animation in ZGE projects, including Android apps: http://code.google.com/p/zgeskelet/wiki/HowTo
Re: Skeletal animation for ZGE
Hi Barefists,
just send me your assets and the ZGE project file, I can have a look at it and possibly also debug.
Rado1.
just send me your assets and the ZGE project file, I can have a look at it and possibly also debug.
Rado1.
Re: Skeletal animation for ZGE
Hi, I observed that the crash happens at calling zsk_GetSubmeshUserMaterialId() function in initialization of model. The problem is that submeshes do not define their materials. In blondie_mesh.xmf MATERIAL="-1" which is not probably correct value.
I fixed the project and set camera and light to render mesh properly, download it from here. However, check your material, shader and texture coordinates for submeshes, because textures are not rendered correctly. BTW the textures are unnecessarily large ...
BTW updated version of ZgeSkelet DLL (also for 64bit) can be found here.
I fixed the project and set camera and light to render mesh properly, download it from here. However, check your material, shader and texture coordinates for submeshes, because textures are not rendered correctly. BTW the textures are unnecessarily large ...
BTW updated version of ZgeSkelet DLL (also for 64bit) can be found here.
- Attachments
-
- screenshot
- scr.png (8.81 KiB) Viewed 26983 times
Re: Skeletal animation for ZGE
Hi Rado! Thank you so much for your help! I adjusted the material settings and have it working now!
Re: Skeletal animation for ZGE
It looks nice.
Re: Skeletal animation for ZGE
Thanks! I can't take credit for the model though - it's generated using Mixamo Fuse and animated in their autorigger (all free with an Adobe ID at http://www.mixamo.com).
I've been trying to get StevenM's extra lights dll to work with this, but it seems the Cal3D model only accepts lighting from one source. Not sure where the problem lies, here's a screenshot of it - the sphere beside the model (on the same z-plane) catches the red light, but not the model.
Project files here.
I've been trying to get StevenM's extra lights dll to work with this, but it seems the Cal3D model only accepts lighting from one source. Not sure where the problem lies, here's a screenshot of it - the sphere beside the model (on the same z-plane) catches the red light, but not the model.
Project files here.