Skeletal animation for ZGE

Use of external libraries (DLLs) from ZGE.

Moderator: Moderators

User avatar
Rado1
Posts: 770
Joined: Wed May 05, 2010 12:16 pm

Skeletal animation for ZGE

Postby Rado1 » Fri May 02, 2014 8:45 pm

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.
Attachments
scr.jpg
scr.jpg (57.33 KiB) Viewed 4787 times

User avatar
Rado1
Posts: 770
Joined: Wed May 05, 2010 12:16 pm

Postby Rado1 » Sun May 04, 2014 10:30 pm

Today, I added support for multi-textured meshes. The demos and the latest version of the ZgeSkelet DLL can be downloaded here.
Attachments
scr2.jpg
screenshot
scr2.jpg (37.26 KiB) Viewed 4773 times

User avatar
VilleK
Site Admin
Posts: 1896
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Postby VilleK » Mon May 05, 2014 7:28 am

That's very nice! Finally there is an alternative for those who want support for mesh skeletal animations until if/when it gets added as a ZGE built-in feature. Rado1 does it again :)

User avatar
Rado1
Posts: 770
Joined: Wed May 05, 2010 12:16 pm

Postby Rado1 » Mon May 05, 2014 3:33 pm

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.

User avatar
Rado1
Posts: 770
Joined: Wed May 05, 2010 12:16 pm

Postby Rado1 » Tue May 06, 2014 10:34 pm

Added support for loading resources from memory, i.e., the functions:

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) {}

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:

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"));
...

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.
Attachments
scr3.jpg
screenshot from Nexus 7
scr3.jpg (22.67 KiB) Viewed 4737 times

User avatar
VilleK
Site Admin
Posts: 1896
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Postby VilleK » Wed May 07, 2014 7:30 am

Fantastic :). Code looks correct to me. Hope someone will put this to good use! Let me know if you want to upload a video clip of this to ZGE YouTube channel.

User avatar
Rado1
Posts: 770
Joined: Wed May 05, 2010 12:16 pm

Postby Rado1 » Fri May 23, 2014 10:39 am

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

User avatar
Rado1
Posts: 770
Joined: Wed May 05, 2010 12:16 pm

Postby Rado1 » Sun Mar 15, 2015 9:29 am

Source code repository for ZgeSkelet has been moved to GitHub.

User avatar
Barefists
Posts: 17
Joined: Fri Jan 01, 2016 4:25 pm
Location: Singapore

Re: Skeletal animation for ZGE

Postby Barefists » Sun Jan 03, 2016 1:12 pm

I've been at this for a whole day but I can't find a solution for this.
I'm exporting Cal3d assets from 3ds max 2016 using both the Cal3d Exporters found at Vizard and IMVU, but all the exported models give an access violation error in ZGE. :(

Image

Please help.

User avatar
Rado1
Posts: 770
Joined: Wed May 05, 2010 12:16 pm

Re: Skeletal animation for ZGE

Postby Rado1 » Sun Jan 03, 2016 6:58 pm

Hi Barefists,

just send me your assets and the ZGE project file, I can have a look at it and possibly also debug.

Rado1.

User avatar
Barefists
Posts: 17
Joined: Fri Jan 01, 2016 4:25 pm
Location: Singapore

Re: Skeletal animation for ZGE

Postby Barefists » Mon Jan 04, 2016 12:09 am

Hi Rado,

Thanks for your help! :)
The files can be found here.

Regards,
XM

User avatar
Rado1
Posts: 770
Joined: Wed May 05, 2010 12:16 pm

Re: Skeletal animation for ZGE

Postby Rado1 » Mon Jan 04, 2016 10:21 pm

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.
Attachments
scr.png
screenshot
scr.png (8.83 KiB) Viewed 3451 times

User avatar
Barefists
Posts: 17
Joined: Fri Jan 01, 2016 4:25 pm
Location: Singapore

Re: Skeletal animation for ZGE

Postby Barefists » Tue Jan 05, 2016 1:46 am

Hi Rado! Thank you so much for your help! I adjusted the material settings and have it working now! :)
Image

User avatar
Rado1
Posts: 770
Joined: Wed May 05, 2010 12:16 pm

Re: Skeletal animation for ZGE

Postby Rado1 » Tue Jan 05, 2016 7:32 am

It looks nice.

User avatar
Barefists
Posts: 17
Joined: Fri Jan 01, 2016 4:25 pm
Location: Singapore

Re: Skeletal animation for ZGE

Postby Barefists » Wed Jan 06, 2016 12:02 am

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.
Image

Project files here.


Return to “Extensions”

Who is online

Users browsing this forum: No registered users and 1 guest