Jump to content

Tower of Babel 2.0 released


JCPalmer
 Share

Recommended Posts

Tower of Babel is a Blender exporter that generates Typescript / Javascript source code.  This is an alternative to converting the contents of a .blend into data that needs to be loaded by JSON & constructed into Meshes / Cameras / Lights.  This has the following implications:

  • Inline source code loads very fast.
  • Permits object oriented programming through subclassing.
  • Source code is better handled in a repository than a .babylon.

TOB 2.0 is now a top level directory of the Extensions repository https://github.com/BabylonJS/Extensions/tree/master/TowerOfBabel. This has taken a while actually making into the public repository.  Being in the same repository as Dialog, it was held back till that was committed.

 

The major new feature is taking advantage of the changes to cloning in BJS 2.0.  This allowed subclasses of BABYLON.Mesh to also be cloned.  This permitted a mesh factory concept, where you just ask for an instance of a mesh, using the same name as it was in Blender. 

var factory = new BlenderFileModule.MeshFactory(scene);var instance1 = factory.instance("blenderMeshName");var clone1    = factory.instance("blenderMeshName");var clone2    = factory.instance("blenderMeshName");

The factory returns one, possibly a clone, if you have already asked for it before.  This is turned on using a new checkbox shown when performing the export.

post-8492-0-55784900-1430425788.png

If you have multiple mesh factories you can request your meshes also specifying the module name as parameter.  (Include the very small TOB-runtime.js ).  Here is how Font modules are initialized / called in Dialog:

public static loadStockTypefaces(scene : BABYLON.Scene){    if (typeof (Font3D) !== 'undefined'){        TOWER_OF_BABEL.MeshFactory.MODULES.push(new Font3D.MeshFactory(scene));        Label.DEFAULT_FONT_MODULE = 'Font3D';         BABYLON.Tools.Log('Font3D loaded');    }    if (typeof (Font2D) !== 'undefined'){        TOWER_OF_BABEL.MeshFactory.MODULES.push(new Font2D.MeshFactory(scene));       Label.DEFAULT_FONT_MODULE = 'Font2D';        BABYLON.Tools.Log('Font2D loaded');    }                // see if an extensions is found    if (typeof (Font3D_EXT) !== 'undefined'){        TOWER_OF_BABEL.MeshFactory.MODULES.push(new Font3D_EXT.MeshFactory(scene));        BABYLON.Tools.Log('Font3D_EXT loaded');    }    if (typeof (Font2D_EXT) !== 'undefined'){        TOWER_OF_BABEL.MeshFactory.MODULES.push(new Font2D_EXT.MeshFactory(scene));       BABYLON.Tools.Log('Font2D_EXT loaded');    }}...var letter_g = TOWER_OF_BABEL.MeshFactory.instance("Font2D", "g");

Each Blender un-parented mesh is generated as a subclass.  Another new feature is being able to specify a base class to inherit from other than the BABYLON.Mesh default.  What is great about this is you can use Blender to design & maintain your geometry, while seamlessly generating JS or TS source as a subclass of your own writing. (Sooner or later it has to inherit from BABYLON.Mesh, of course).  This is specified in the custom data properties:

post-8492-0-60286500-1430426823.png

With source code generated, you simply get an instance: (meshes in a .blend are generated as a module with name matching exported file)

var myMesh = new BlenderFileModule.BlenderMesh(scene);
Link to comment
Share on other sites

Wow, that's allot to take in.  I'm revisiting our entire pipeline for future projects, and it appears that the release of BJS 2.0 and TOB 2.0 is perfect timing for us to take a diffrent approach to working with meshes.  Thank you for all of your work.  I can't believe how quicky this framework is evolving and advancing.  I hope developers who might be questioning whether the BJS framework is where they should be working, can look at this and other recent developments and see the advantages of BJS and this community over other development platforms.

 

Thanks again. :)

Link to comment
Share on other sites

Dbawel,

I really would skip 2.0, and go with 2.1.  That version is in Beta, whatever that means, is much faster with "free lunch optimizations":

  1. SIMD integration.  I am just starting to work with the Morph extension in this regard too.
  2. Freezing the computing of the world matrix of meshes you know as the developer do not move / scale / rotate very often, or ever.  2.0 did checking to avoid the recompute, but the checking itself was acting as a tax, limiting scalability.
  3. disabling frustrum clipping for stuff the game developer knows will always be seen.
  4. disabling meshes completely that you do not want to be seen, but  don't want to get rid of yet, now has nearly 0 overhead cpu.
  5. computeNormals, if you call it, is much faster.

By free lunch, i mean, there is no cost to be absorbed.  Earlier optimizations like mesh simplification lost detail.  Octrees needed like over a hundred meshes, I think, before it paid for its overhead.  This stuff just eliminates cpu cost either by special cpu instructions, developer knowledge, or have just been profiled & improved.  Also saw today, that textures are reload, when they should be being shared by different meshes in 2.0.

 

Jeff

Link to comment
Share on other sites

Hi Jeff,

 

Those are huge improvements, and I haven't found the BJS beta of previous versions buggy - at least since I've been using.  Thanks for the advisement, as I haven't looked at the features in 2.1 at all yet.  Things are moving so quickly, it seems like we just moved into using 2.0.  In reviewing the updates that you listed here, I expect a noticable increase in performance of the type of scenes we're building - which are mesh and texture heavy, and am eager to test if there is a recordable improvement.

 

Thanks again for all of your contributions to this quickly evolving framework.

 

Cheers,

 

DB

Link to comment
Share on other sites

Well, I am starting to actually think about my game again.  The textures specifically.  My philosophy is not "Simple yet powerful", like BabylonJS.  I am more "execution at any cost".

 

This does not mean that I tolerate over complexity.  I have a tendency to avoid that by writing programs that write programs (technically complex, but the final code is dead simple).  This is effective at annihilating design time, fixed data, while being punishingly fast.  Am sort of thinking out loud, but for TOB 2.1 I am considering in-lining textures directly into source code.

 

There is a static function in babylon.texture.ts, called CreateFromBase64String.  DK, what if the data arg was actually the contents of a compressed nature, a jpg or jpeg2?  Does the data have to be expanded, which would kill this?

 

Did not want to do a lot with Python trying to write base64, when it forced the expansion first.

Link to comment
Share on other sites

  • 2 years later...

Yep, that's where it went.  You can use ToB without the QI animation system.  It writes Blender actions to BJS AnimationRanges, similar to the the JSON exporter.

Also, it does not write Typescript modules since this was published, only Javascript modules.  The minor differences in code generation made the python code more complicated than it needed to be.  Instead it just writes a d.ts file of the couple of external entry points.  Works just as well.

Link to comment
Share on other sites

Hero @JCPalmer. Thank you. :) 

1) afalcon interested in formatted big arrays of numbers in objects/modules. :)

2) Thank you for non-type-safeness. JavaScript module patterns vastly preferred.

     There are reasons for not wrapping everyone in safety blankets. 

3) Animation Ranges... and QI Animation System... +Like! 

Deep-dive pending...(Feb) .babylon current.

Docs look fantastic... +1.

Found the QI animation...

<jokes-removed/>

Link to comment
Share on other sites

Actually, not es6 modules, but what Typescript generates for pre-es6.  Have thought about it, es6, but not yet.  Soon ie11 is just going to have to pound salt.

I have a site of all my test scenes, but was referencing cdn.babylon.com.  Have not got around to testing for 3.1.  I know I have a problem with how pre-compiling materials was changed, so some scenes do not work.  This is not going to get done prior to my Kinect integration work for Blender.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...