Sign in to follow this  
DylanD

Blender Babylon Question

Recommended Posts

Hello everyone :D , I'm looking for help with getting a .FBX into my Babylon scene and applying textures to it.  The original model was made by someone else, I am just tasked with putting it into the Babylon scene.  I can not show the actual file either as it is not my property which I am very sorry about, I understand it would help a lot to post it here, that way you could all help me better, but I am not able to.  Again sorry :( .  Hopefully my description will be enough :) .

I dont know very much about blender, so I'm not sure exactly what I am doing wrong.  I have a model in blender, specifically a .FBX, which uses many different materials and pieces.  When I try to export it to a .babylon and then import it into my scene it becomes mis aligned.  As in, instead if all of the pieces being one on top the other and positioned correctly, they seem to be rotated or repositioned.  Not only that but I get many errors that tell me I am missing materials, but when I look at the files directory for those missing materials I cannot find them.  

I am using blender version: Version 2.79b (2.79b 2018-03-22, Blender

The Babylon exporter I am using is version: 4.6.1

The code I use to to import the model is:

BABYLON.SceneLoader.ImportMesh("","models/","Test3.babylon",this.scene,(meshes)=>{
importFunc(meshes);
});

The errors I get are:

BJS - [11:10:38]: Error while trying to load image: models/AlbedoTransparency.png

But 8 of these errors, all with different materials

 

Any ideas what I am doing wrong?

Thanks for reading :) 

Share this post


Link to post
Share on other sites

When I import it with this:

BABYLON.SceneLoader.Append("models/","Test3.babylon",this.scene,(meshes)=>{});

The model seems to stay in the correct position and rotation.

However then I'm not sure how I can access the model to actually use it.  Also I still have all the errors with the materials.

Edit:{ I think I can access by using, 

BABYLON.SceneLoader.Append("models/","Test3.babylon",this.scene,(meshes)=>{
console.log(meshes.meshes);
});

 

This console.log however shows me all of the meshes in my whole scene and not the ones I just added.  How could I access the ones I just added?

}

Edit2:{

So I can use the model with the above function if I do this:

meshes[meshes.length-6].scaling = new BABYLON.Vector3(0.4,0.4,0.4);

Basically this means that I can access it by going to the end of the array and looking for it.  So that part is kind of solved.

}

Still need help with the materials problem :) 

Share this post


Link to post
Share on other sites

Also, unless it is a typo, the exporter version is a 5.6.4.  If that should have been 5.6.1 not 4.6.1, probably not a big deal.

My personal opinion of ImportMesh is quite low.  This forum is littered with mistakes where someone accesses newMeshes[0], and it is not the mesh they think it is.  Append & Load might do the same, but people less often blindly pick [0].  If a .blend has a camera and or lights which are unwanted, temp delete them prior to export to avoid ImportMesh.

I can see you are not doing that, but completely ignoring the callback for accessing can illiminate many problems, & also facilitate multiple Appends which can get ugly using callbacks.  getMeshByName in an ExecuteWhenReady is an answer to your access question.

BABYLON.SceneLoader.Append(url, "myfile1.babylon", scene);
BABYLON.SceneLoader.Append(url, "myfile2.babylon", scene);
scene.executeWhenReady(function () {
    const mesh = scene.getMeshByName("male1");
});

 

Share this post


Link to post
Share on other sites

Also, in 5.6.2, you can specify a subdirectory for the location of textures.  Not sure that is your problem, but reason to ditch 4.6.1. 

Quote

Blender Exporter Version 5.6.2

23 March 2018

The custom property, textureDir, originally for Tower of Babel to indicate the directory to write images, is now joined into the name field of the texture in the .babylon file.

If the field does not end with /, then one will be added between the directory & file name.

The field is relative to the .babylon file. For this to work probably implies that the .babylon is in the same directory as the html file. Still it now allows images to be in a separate directory.

Have not tested where the the .babylon is in a different directory from html file.

 

Share this post


Link to post
Share on other sites
On 9/4/2018 at 12:13 PM, Deltakosh said:

Hello for your material problem you have to check the network profiler to understand which URL the system tries to load. Then we can understand why textures are not found

by network profiler you mean developer tools right? Under the network tab of the developer tools there is 7 missing .png's which are meant for the blender model.  When I go to the URL they show it doesn't exist.  I tried looking for the .png's from blenders perspective to see if I could find them anywhere and I can't, maybe theres a trick to it that I dont know?

 

On 9/4/2018 at 12:32 PM, JCPalmer said:

Also, unless it is a typo, the exporter version is a 5.6.4.  If that should have been 5.6.1 not 4.6.1, probably not a big deal.

My personal opinion of ImportMesh is quite low.  This forum is littered with mistakes where someone accesses newMeshes[0], and it is not the mesh they think it is.  Append & Load might do the same, but people less often blindly pick [0].  If a .blend has a camera and or lights which are unwanted, temp delete them prior to export to avoid ImportMesh.

I can see you are not doing that, but completely ignoring the callback for accessing can illiminate many problems, & also facilitate multiple Appends which can get ugly using callbacks.  getMeshByName in an ExecuteWhenReady is an answer to your access question.


BABYLON.SceneLoader.Append(url, "myfile1.babylon", scene);
BABYLON.SceneLoader.Append(url, "myfile2.babylon", scene);
scene.executeWhenReady(function () {
    const mesh = scene.getMeshByName("male1");
});

 

Yea I'm on version 4.6.1, I will try to update it just in case!

I also switched to append since it works better.  getMeshByName sounds wonderful!

On 9/4/2018 at 12:41 PM, JCPalmer said:

Also, in 5.6.2, you can specify a subdirectory for the location of textures.  Not sure that is your problem, but reason to ditch 4.6.1. 

 

how would I specify the sub directory? er its seems I just need to add it to the name...

 

Thanks guys!

Share this post


Link to post
Share on other sites

So I have the update, I'm not sure it changed anything.

I did however notice that in the network tab that the materials that are not loading properly, are of type "text/html". which is strange to me.  The status for all of the materials is 404 (doesn't find the file).  

I believe when I export to .babylon file its not saving the materials with it.  Just the model, but I'm not really sure.

 

Share this post


Link to post
Share on other sites

First, if you are running from file://, do not use chrome unless you set up a local server.  Firefox & Edge allow from file, as long as it is the form of a relative path.

2nd, normally only the base file name ends up in the .BABYLON file.  The path of source is just that.  That is where .blender gets it from to copy.  Sometimes if the file is embedded in the .blend file, there is no directory.

You add it from the exporter custom properties on the scene tab.

sceneTab.JPG.b6caca2b31a78e6f1ff3a66421f0f6d5.JPG

Share this post


Link to post
Share on other sites
20 hours ago, JCPalmer said:

First, if you are running from file://, do not use chrome unless you set up a local server.  Firefox & Edge allow from file, as long as it is the form of a relative path.

2nd, normally only the base file name ends up in the .BABYLON file.  The path of source is just that.  That is where .blender gets it from to copy.  Sometimes if the file is embedded in the .blend file, there is no directory.

You add it from the exporter custom properties on the scene tab.

sceneTab.JPG.b6caca2b31a78e6f1ff3a66421f0f6d5.JPG

I am running a local server :) 

Also I will try this!

Share this post


Link to post
Share on other sites

I just noticed that all of the missing materials end with  _AlbedoTransparency

I dont think I even need the albedo stuff

not sure if that helps, I still need to try the sub directory thing.  

Share this post


Link to post
Share on other sites

so I have pretty much the whole things working, but I still have the errors, which cause a large lag spike on start, any idea how I could fix that?

 

**im actually not sure if I need the albedo stuff but I dont think BABYLONjs uses albedo anyway...?  It seems to work just fine without it, except the errors ruining startup time **

Share this post


Link to post
Share on other sites
On 9/7/2018 at 6:57 PM, Deltakosh said:

Babylon.js uses albedo for PBR for what it worth :)

hmm if i remember correctly PBR is like the super class of standardMaterial... or something like that...  so i guess the albedo would make a difference?

How would PBR pass albedo, with a png? or would that just automatically be imported when i import the scene that has the model in it, when the model already has the albedo on it... not sure...

23 hours ago, JCPalmer said:

Does not knowing what 'the albedo stuff' is mean that is not your .blend?  Have you looked at your .log file?

good idea i will check.  Ok so the log file also says i cannot find them however a little bit more insight

WARNING: Error encountered processing image file:  , Error:  [Errno 2] No such file or directory: '/Users/dylan/Workspace/unity/game/Assets/Resources/Models/TEXTURES/Green/Big_AlbedoTransparency.png'

That directory doesnt exist that i know of... maybe it wasnt uploaded to the repository or something, could it be hidden even in the repository?

such a mystery.

I guess this is just some file im missing thanks for the help everyone!

Share this post


Link to post
Share on other sites
42 minutes ago, DylanD said:

Is there a way i could just not have the errors pop up?

 

Either:

  1. edit your .blend to delete the textures missing files, or
  2. Go get the textures from where ever you got the .blend file & place them where the log file says they are supposed to be, or
  3. Delete the meshes which use the materials are from.

Share this post


Link to post
Share on other sites
3 minutes ago, JCPalmer said:

Either:

  1. edit your .blend to delete the textures missing files, or
  2. Go get the textures from where ever you got the .blend file & place them where the log file says they are supposed to be, or
  3. Delete the meshes which use the materials are from.

aw i was hoping there was going to be an easier way :D o well i thought these might be the only ways,  thanks!

Share this post


Link to post
Share on other sites
On 9/6/2018 at 11:46 AM, JCPalmer said:

First, if you are running from file://, do not use chrome unless you set up a local server.  Firefox & Edge allow from file, as long as it is the form of a relative path.

2nd, normally only the base file name ends up in the .BABYLON file.  The path of source is just that.  That is where .blender gets it from to copy.  Sometimes if the file is embedded in the .blend file, there is no directory.

You add it from the exporter custom properties on the scene tab.

sceneTab.JPG.b6caca2b31a78e6f1ff3a66421f0f6d5.JPG

Hey, so i never ended up figuring this out, however now i am coming back to this problem.  I was not able to find this screen before however i have found it now.  Now i understand a bit more. I am reading through the exported log file(my newly exported .babylon file) .  I switch the textures folder and from what i understand that sub-directory tells the exporter where to find the textures.  However my problem is that those textures do not seem to exist anywhere.  At least when i look through the log file it tries to go to that subdirectory and look for a folder called green, then the albedo .png.

for example:  sub-directory= textures and models folder has my model in it,  it would look for model/textures/green/albedo.png  ,which does not exist.   

Any ideas what might be happening? 

Share this post


Link to post
Share on other sites
3 minutes ago, JCPalmer said:

Post your log file.  Is this your .blend, or did your download from some where?  If the source file does not exist, then get it in the place  Blender says it should be, or change where the model looks.

I am importing an fbx into blender then exporting it with the babylonjs tower of babylon ( most recent version as i downloaded it today 5.6.4 i believe).

when i export it.  I get two new files created, one is a .babylon the other is just a text file which is detailing the conversion from the blender to babylon.

just thought about it i bet my problem is becuase i open a .fbx file in blender then try to use the blender to babylonjs exporter which is expecting a .blend file not a .fbx file (this is my guess)

this was taken from that text file that was created when i made the .babylon version of the .fbx

I dont know where the .fbx is from, i assume someone else in the company made it or, it was created by an external designer.  I was given it when i started the project.

 

Im not sure i understand what you meant by "If the source file does not exist, then get it in the place  Blender says it should be, or change where the model looks."  you say if the file does not exist then get it in the place, as in make the exporter find the files through the sub directory becuase they do not exist.

From my understanding the source file does not exist anywhere.  Although im not certain about that.  I have tried searching my entire computer however nothing has come up.

Share this post


Link to post
Share on other sites
On 10/30/2018 at 12:53 PM, JCPalmer said:

Find where on the hard drive is a file named AlbedoTransparency.png.  If you do not have one, why do you expect to export it?  If it is not in the models directory, then put it there.

yea i cannot find them on my system. The file i am importing into blender is a .fbx, could it be possible that the albedoTransparency.png's are somehow intrinsic to the .fbx(maybe theyre built in to the fbx and not some external transparency png)?

If so then i would be out of options for a bit...

Share this post


Link to post
Share on other sites

A .fbx is a data & directions file, just like a .babylon or .gltf.  The directions of the .fbx must have said that the texture is in a file named AlbedoTransparency.png.  So, the fbx importer made the appropriate setting in the blender scene / unsaved .blend.  I do not know if a fbx can even have embedded textures inside them.

Go to where or whom you got the .fbx, and get or ask for the file. If they or it do not have it, then this question is probably solved with the answer that you are screwed.

Share this post


Link to post
Share on other sites
6 minutes ago, JCPalmer said:

A .fbx is a data & directions file, just like a .babylon or .gltf.  The directions of the .fbx must have said that the texture is in a file named AlbedoTransparency.png.  So, the fbx importer made the appropriate setting in the blender scene / unsaved .blend.  I do not know if a fbx can even have embedded textures inside them.

Go to where or whom you got the .fbx, and get or ask for the file. If they or it do not have it, then this question is probably solved with the answer that you are screwed.

Yeah that was my next step.  Thanks for the help!

 

P.S i will update this topic once i ask around the office.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.