Jump to content

Babylon file standard


Nico
 Share

Recommended Posts

Hi guys,

 

Do you know if there is a standard or something like that for the babylon 3D files? Because I have to parse them to get some informations inside, and if I can't be sure that the structure won't change, it could be dangerous... 

 

So I have make some tests, and I found some things:

  • Parents are always printed before their children (nice for parsing!)
  • It is written by branch (a top level node and all its children and its children's children... is a branch), so when I parse a new mesh with no parent I know that previous parsed mesh was the last of its branch, and I can drop all temp datas related to this branch.

Could tell me if I am right, and is it possible if it doesn't exist yet to create a kind of standard for this files? 

Link to comment
Share on other sites

Yes this link is useful but some things are missing. For example, it's not explicit that a parent appears before its children. I guess Nico had to read the babylon format parser to get this rule. Unfortunately nothing guarentee you that it will always be the case.

Link to comment
Share on other sites

@SideraX: Thanks for helping, but Gwena is right, I found some things by reading code and .babylon files, but I can't know if files will always printed like this, that is why it would be great to have standard ;)

Link to comment
Share on other sites

I think you are better off loading the .babylon file, then interogate the scene.meshes array or any other member with a  javascript. Each  Mesh object has a parent member (actually from super class Node).  You can order your output in any heirarchy you want.  This order you observe may is not manditory as far as I can tell.  Coming from blender the meshes are written in the order the Blender python API lists them.  I think Blender lists things in order of creation.

Link to comment
Share on other sites

No problem with that, but could you confirm that when I read a child mesh, its parent mesh will always be printed before?

And when I read a mesh without parent previous mesh was the last mesh of its branch? ( = When you read a node, you read all nodes that are under it before reading its neighbor?)

Link to comment
Share on other sites

Hi everyone.  This is an excellent topic. (And welcome to the forum, JC... good to have you with us!)  To expand on JC's thoughts... back in 'the old days' when a browser could load ANY text file from any local folder (without using a filepicker)... I would parse source code and MS Train Sim files... into drillable html 'trees'... so I could 'visualize' the contents of the files easier.  IDE's do this too... able to see the functions and list them in drillable treeviews and listviews.

 

To get to the point, being able to parse .babylon files and then 'visualize' them in many formats (such as HTML)... would be excellent.  We could NICELY see what our exporter is doing, and users could easily find unexpected things that happened during an export.

 

So, I urge that anyone building stand-alone .babylon file parsers... PLEASE donate your code to the team.  And please seperate the parsers... from any visualizers... and donate any visualizer code as well.  In other words, a real nice stand-alone parser for .babylon files would be great... in any programming languages.  (JSON parsers?)  I'm kind of new at exporting.  :)  But then... one could visualize/view/show that data... in MANY forms... treeview, listview, 2D SVG heirarchy, HTML, on and on... and the more ways to visualize it, the better.  .babylon file analyzing...  I love it... and it would be super helpful for many, especially for those who maintain our exporter.  Thanks for letting me interrupt.  Continue, and know I am excited about this.  :)  (SO WHAT, Wingnut?)  :)

Link to comment
Share on other sites

No problem with that, but could you confirm that when I read a child mesh, its parent mesh will always be printed before?

And when I read a mesh without parent previous mesh was the last mesh of its branch? ( = When you read a node, you read all nodes that are under it before reading its neighbor?)

If you referring to me, the quick answer to your question is: absolutely unknown.   I am saying you control the output, forget about the order of the input.  For depth first output you probably want have a script like: (did not test, if JS does not support recursion never mind)

 

     function printMeshTree(parentMesh, allMeshes){

          // do whatever to produce output for parent mesh

          for (var i = 0; i < allMeshes.length; i++) {

               if (allMeshes.parent == parentMesh){

                   printMeshTree(allMeshes, allMeshes);

               }

           }

        }

     

       function main(){

          var nMeshes = scene.meshes.length;

          for (var i = 0; i < nMeshes; i++) {

               if (scene.meshes.parent == null){

                   printMeshTree(scene.meshes, scene.meshes);

               }

           }

        }

 

edit: forgot method was printMeshTree, not printMesh when calling

Link to comment
Share on other sites

Thank you Deltakosh, I will update the wiki as soon as possible.

Thank you for helping JCPalmer too, but I really need to read .babylon without loading them into a babylon scene  ;)

Link to comment
Share on other sites

Indeed that would be nice to have somewhere rules that exporters must respect to write babylon files. Thus, parsers/importers know exactly what they have as input and don't have to assume things such as the parent is always printed before its children. Without such explicit rules, we could get undesired/not handled cases while parsing babylon files. Yes a babylon file could be imported in Blender if someone writes the importer :)

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