[Bf-committers] Proposal: New Importer for both glTF and COLLADA

Recep Aslantas info at recp.me
Sat May 16 18:44:13 CEST 2020


Hi,

My name is Recep,

I was working on library called AssetKit ( https://github.com/recp/assetkit )
Recently I have implemented importing Morph Targets and Animation from glTF.

AssetKit can import all glTF 2.0 and with "KHR_materials_pbrSpecularGlossiness"
extension. So it can import Metallic Roughness + Specular Glossiness materials.

It also supports COLLADA 1.4 and COLLADA 1.5 (common profile).
It uses single interface for both glTF and COLLADA 1.4/1.5. 

AssetKit comes with lot of options (and utils), a few options are (all are optional):
* Triangulate polygons
* Generate normals
* Compute Bounding Box
* Bugfixes for Transparency
* Compute exact center
* Convert Coordinate System to Another (Any-to-Any)
I'm trying to make it faster and more flexible by time. Recently I have written a json and xml parser 
to parse glTF and COLLADA fast as possible. These new parsers also reduced the binary size and 
make the build time faster and portable. Because these are header-only, see my Github https://github.com/recp?tab=repositories to see them

AssetKit is written in C99 and its size is only ~ 240KB + 50KB stb_image.h == 290KB, and it can import
glTF and COLLADA files and load images. This will reduce Blender size too and increase build time.

The API interface must be very easy to work with. 

AssetKit also tries to make the loading and rendering faster by providing utilities and options.

For instance, after you loaded a file with AssetKit like:

AkDoc *doc;
AkResult ret;

ret = ak_load(&doc, "sample.gltf or .dae", NULL);

you can import morph targets into single buffer with desired inputs with desired order:

void  *morphBuffer;
size_t buffSize, targetByteStride;

static AkInputSemantic desiredInputs[] = {
AK_INPUT_SEMANTIC_POSITION,
AK_INPUT_SEMANTIC_NORMAL,
AK_INPUT_SEMANTIC_TANGENT
};

ak_morphInterleaveInspect(&buffSize, &targetByteStride, morph, desiredInputs, 3);
morphBuffer = malloc(buffSize);
ak_morphInterleave(morphBuffer, morph, desiredInputs, 3);

now you can pass morphBuffer to GPU directly. This is optional step of course.

AssetKit also provides simple and elegant API like Javascript:

object1 = ak_getObjectById(doc, "object-id")
object2 = ak_getObjectByUrl(url)

The memory management in AssetKit is awesome. It provides hierarchical memory allocator,
if you free parent node or document then sub nodes or the whole document will be freed.

I propose to replace OpenCOLLADA and glTF importer with AssetKit. 
AssetKit will also support additional formats without changed the integration if possible
as extension library like AssetKit-Ext.lib

I can help to integrate it with Blender and feedbacks are always welcome. 
You can propose or request some changes before integration if you like it. 

I'll provide CMake build files as soon as possible. The exporter side will be available in the future.

Please take a look at the repo and sources at https://github.com/recp/assetkit 
and ask any questions if you have any. 

You will also get better support for this library than others :) I always respond fast as possible on Github.
Also any contributions/contributors/feedbacks... are always welcome.

Thanks

- Recep


More information about the Bf-committers mailing list