Jump to content

Binary format conversion questions


Hagop
 Share

Recommended Posts

Hi

I have a number of questions on binary and incremental conversion

I have a scene with a number of meshes which I exported to a file after serializing.I used the makeincremental tool (after adding Newtonsoft jhost) and converted my scene to incremental. I had a performance gain of 40% which is excellent. My initial questions are

  • my incremental files have extension babylongeometrydata and not babylonmeshdata. What is the difference?
  • the makeincremental command seems to use a [textures] parameter, but I don't see it being used in the .cs source file.

Now I want to convert my original scene to binary format to get even better performance

  • do I need to use the original scene file (ie: somefile.babylon) or do I process the incremental file (ie: somefile.incremental.babylon)?
  • I get the following error when I run converttobinary.exe on either somefile.babylon or somefile.incremental.babylon

Cannot perform runtime binding on a null reference
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Cannot perform runtime bi
nding on a null reference
   at CallSite.Target(Closure , CallSite , Object )
   at ConvertToBinary.Program.Extract(String srcPath, String dstPath, String obj
Name, Object meshObj, Boolean isMesh) in C:\ConvertToBinary\Program.cs:line 191

exp7storey_11r1.babylon

Link to comment
Share on other sites

I think there is a bug in the converter.

The following line causing the null reference  error when meshObj.id is valid and meshObj.name is null

 meshName = meshObj.name.ToString();

 

I fixed it this way

  string meshName = "";
                if(meshObj.name !=null)
                {
                     meshName = meshObj.name.ToString();

                    meshName = meshName.Trim();
                    if (meshName.Length > 40)
                        meshName = meshName.Substring(0, 40);
                }

Link to comment
Share on other sites

  • 3 months later...
On 11/10/2016 at 11:13 PM, Hagop said:

I think there is a bug in the converter.

The following line causing the null reference  error when meshObj.id is valid and meshObj.name is null

 meshName = meshObj.name.ToString();

 

I fixed it this way

  string meshName = "";
                if(meshObj.name !=null)
                {
                     meshName = meshObj.name.ToString();

                    meshName = meshName.Trim();
                    if (meshName.Length > 40)
                        meshName = meshName.Substring(0, 40);
                }

I have got almost the same problem:

Quote

Fatal error encountered:
Cannot perform runtime binding on a null reference

but there is no this string in the source file:  meshName = meshObj.name.ToString();

there is even no meshObj in the file Program.cs

 

Link to comment
Share on other sites

On 08/10/2016 at 5:02 PM, Hagop said:

Hi

I have a number of questions on binary and incremental conversion

I have a scene with a number of meshes which I exported to a file after serializing.I used the makeincremental tool (after adding Newtonsoft jhost) and converted my scene to incremental. I had a performance gain of 40% which is excellent. My initial questions are

  • my incremental files have extension babylongeometrydata and not babylonmeshdata. What is the difference?
  • the makeincremental command seems to use a [textures] parameter, but I don't see it being used in the .cs source file.

Now I want to convert my original scene to binary format to get even better performance

  • do I need to use the original scene file (ie: somefile.babylon) or do I process the incremental file (ie: somefile.incremental.babylon)?
  • I get the following error when I run converttobinary.exe on either somefile.babylon or somefile.incremental.babylon

Cannot perform runtime binding on a null reference
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Cannot perform runtime bi
nding on a null reference
   at CallSite.Target(Closure , CallSite , Object )
   at ConvertToBinary.Program.Extract(String srcPath, String dstPath, String obj
Name, Object meshObj, Boolean isMesh) in C:\ConvertToBinary\Program.cs:line 191

exp7storey_11r1.babylon

@Hagop may be you have an executable file to share with me?

Link to comment
Share on other sites

iTekVr,

OK, so I had a scene with multiple meshes which I serialized and exported as a babylon file

var serializedScene = BABYLON.SceneSerializer.Serialize(scene);
var strScene = JSON.stringify(serializedScene);     
            
           var filename = globalRackExportName;
           saveBlob(filename,strScene);
             
        
 function saveBlob(filename,strScene)
        {
                var blob = new Blob ( [ strScene ], { type : "octet/stream" } );           // turn blob into an object URL; saved as a member, so can be cleaned out later    
                var objectUrl = (window.webkitURL || window.URL).createObjectURL(blob);
                var link = window.document.createElement('a');    
                link.href = objectUrl;    
                link.download = filename;    
                var click = document.createEvent("MouseEvents");    
                click.initEvent("click", true, false);    
                link.dispatchEvent(click);  
                return;
        }

It is important for you to understand at this point is that, since the scene was in the memory of the PC, the exported babylon file contains geometry data (vertex) and not mesh data. The ConvertToBinary & MakeIncremental utilties will treat the input as geometry and not mesh data and export in babylonbinarygeometrydata & babylongeometrydata respectively. However, at the time I was working with BABYLON.JS ver. 2.4, Babylon could not process babylonbinarygeometrydata but ony babylonbinarymeshdata.So I  "tricked " the system, so that the output file name was babylonbinarymeshdata, but I continued using the geometry data in my exported scene file and I had a huge gain in performance. Attached in the cs file you can open in Visual Studio which includes the bug fix mentioned above.Finally be remined that you can use the command

BABYLON.SceneLoader.Append("productshr/", sceneVar, scene, function (newScene) {}  to append the converted files to your existing scene, where sceneVar is the entry point name of your converted file (either incremental or binary).

Hope this helps !

Program.cs

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