Jump to content

Export Blender to Babylon.js


jdnichollsc
 Share

Recommended Posts

Hi friends!  :D

I try to export a .obj from Blender to Babylon.js but I'm detecting an error.

 

.obj file => http://www.nicholls.co/canvas/threejs/TommyEnsayoTexturas.OBJ

 

Blender demo => http://www.nicholls.co/canvas/babylon/

 

PD: With Three.js it works well => http://www.nicholls.co/canvas/threejs/

 

 

Any help will be much appreciated and Sorry for my bad english  :P

 

Thanks in advance, Nicholls

Link to comment
Share on other sites

Hi Nicholls, welcome to the forum :)

 

I tried the demo, and it does look odd. So I downloaded your.obj file and imported it into Blender, exported it as a .babylon file, then tested it in the Babylon sandbox - worked fine (see attached image)

 

Now the file I imported just has a default material, and in your demo it seems to have multiple materials, so it would be useful if I could have a look at your .blend file to make sure you have not altered the file in some way that is producing the odd result.

 

Ohh and as a comment, do you really need a little figure that has 365,000+ triangles ?

 

cheers, gryff :)

post-7026-0-09021400-1420073937.png

Link to comment
Share on other sites

Hi Gryff, Thanks for the welcome and for your quickly response! :D

 

I tested also in the Babylon sandbox, but... http://screencast.com/t/Bxho0FoXvjq

 

.babylon file expoted from Blender 2.72b => http://www.nicholls.co/canvas/babylon/demo.babylon

 

Can you tell me please the steps you followed to export the file to .babylon?  :)

 

Thanks again!

Link to comment
Share on other sites

Can you tell me please the steps you followed to export the file to .babylon?

 

Nothing special Nicholls - just imported the object file then exported as a .babylon file. The imported object just has a default white material.

 

Now the demo you posted has multiple materials (and textures?), so I would like to have a look at your .blend file - see what you did to add those materials.

 

If you could post the .blend file somewhere it would help.

 

cheers, gryff :)

Link to comment
Share on other sites

Nicholls - this is what you are looking for (takes a few seconds to load):

 

Nick's Creature

 

So a couple of questions for you:

 

1. What version of Blender are you using?

2. What version of the Babylon exporter are you using? (In Blender, go to File->User Preferences->Addons, then type "babylon" into the search box, then click on the little arrow at the left of results you get - you should see the author and version)

 

I will delete the link after a week as the file is huge (and I changed the .bmp texture to a .png to reduce the overhead - by 30!)

 

cheers, gryff :)

Link to comment
Share on other sites

Wowww, haha excellent Gryff!  :o

 

Regarding your questions

 

1. Blender 2.72b (64 bits)

 

Blender%20version.png

 

2. Version 1.3.1 (https://github.com/BabylonJS/Babylon.js/tree/master/Exporters/Blender)

 

blender%20export%20version.png

 

PD: Would you explain me how to install the addon to see if I'm doing wrong? (I give install from the file and select io_export_babylon.py)

 

Thanks for your help and happy new year my friend!  :)

Link to comment
Share on other sites

TY for the version info Juan :)

 

My version setup in image below.

 

This is from my 32 bit Windows XP machine. Blender is only supported to v2.71 on XP. I will try the whole process on Windows 7  with Blender 2.72 later today (not sure when exactly as my daughter is visiting today).

 

As you can see, my version of the exporter is v1.4.

 

Would you explain me how to install the addon to see if I'm doing wrong? (I give install from the file and select io_export_babylon.py)

 

That is exactly how I do it. But I think we are getting closer to an answer.

 

cheers, gryff :)

 

 

post-7026-0-62491000-1420211153.png

Link to comment
Share on other sites

The version 1.4 was the very last one committed with the original code base.  (I have put aside a copy of this on my system).  When David switched to the Tower of Babel code base, he probably should have set the version to 1.5, but left it at TOB's 1.1.  Nicholls has the current repository version.

 

The new code base produces a log file, which the old one did not.  It is usually very small.  Please post it, as it is much better for diagnostics, than just looking at the output.

 

Also, I have experience strange things with materials.  Usually when multiple exports occur in the same session.  Textures get duplicated.  This happened with both code bases.  Please try doing all your importing from whatever .obj is, then save to .blend.  Exit Blender, restart & export from a clean instance of Blender.

 

In my recent examination of the MHX2 scripts, I see they are doing this reload every run.  May need to look into this.  In any case post your log file.  This is why .log files are so important.  I probably would never have noticed this without it.

Link to comment
Share on other sites

Hi Jeff, here is the log file:

 

    Babylon.js Exporter version: 1.3.1, Blender version: 2.72 (sub 0)
========= Conversion from Blender to Babylon.js =========
    Python World class constructor completed
    processing begun of material:  demo_w7.defaultMat.001
    Diffuse texture found
    processing begun of light (HEMI):  Hemi
    processing begun of mesh:  Group6846
        num positions      :  65533
        num normals        :  65533
        num uvs            :  131066
        num uvs2           :  0
        num colors         :  0
        num indices        :  193479
    WARNING: The following mesh has exceeded the maximum # of vertex elements & will be broken into multiple Babylon meshes: Group6846
    processing begun of mesh:  Group68461
        num positions      :  65534
        num normals        :  65534
        num uvs            :  131068
        num uvs2           :  0
        num colors         :  0
        num indices        :  190104
    processing begun of mesh:  Group68462
        num positions      :  65534
        num normals        :  65534
        num uvs            :  131068
        num uvs2           :  0
        num colors         :  0
        num indices        :  193266
    processing begun of mesh:  Group68463
        num positions      :  65534
        num normals        :  65534
        num uvs            :  131068
        num uvs2           :  0
        num colors         :  0
        num indices        :  192588
    processing begun of mesh:  Group68464
        num positions      :  65535
        num normals        :  65535
        num uvs            :  131070
        num uvs2           :  0
        num colors         :  0
        num indices        :  191580
    processing begun of mesh:  Group68465
        num positions      :  45692
        num normals        :  45692
        num uvs            :  91384
        num uvs2           :  0
        num colors         :  0
        num indices        :  134919
    processing begun of light (POINT):  Lamp
    processing begun of camera (FreeCamera):  Camera
========= Writing of scene file started =========
========= Writing of scene file completed =========
========= end of processing =========

 

I suspect this is the issue:

 

WARNING: The following mesh has exceeded the maximum # of vertex elements & will be broken into multiple Babylon meshes: Group6846

 

Juan's model has a lot of verts 360,000+ ( see my link above the fps and verts count are displayed on screen).

 

What I find curious is that I removed v1.3.1 of the exporter and installed v1.4 for my Blender v2.72 (Windows 7) . No warnings, and the creature displays fine on my local server. The old exporter works fine - or appears to - that I don't understand

 

As I said Juan, we are getting closer.

 

cheers, gryff :)

Link to comment
Share on other sites

Gryff,  Thanks.  The TOB code base is the future as it is far more modular / object oriented.  That said, uncommon conditions that I did not have a .blend to test with (you actually built most of the base case .blends) would have to just be discovered as reported.  Never had a .blend that triggered this.  Have downloaded the .blend from above.  Will attempt to get new code base to work, & commit with a 1.5 version #.

 

Nicholls, would you mind donating the .blend to the set of base base, test, .blends (published in the Extension repository)?

 

If you wish to use last version of the old code base(1.4) while you wait, select the text from here & paste into a file. https://github.com/BabylonJS/Babylon.js/blob/afb1811033b00d39a5ab4592c7ddce9a559e0b8b/Exporters/Blender/io_export_babylon.py

Link to comment
Share on other sites

Well Jeff, as you put it

 

That said, uncommon conditions that I did not have a .blend to test with (you actually built most of the base case .blends) would have to just be discovered as reported.

 

and 360,000+ verts is a very "uncommon condition" for a little character like that. I would normally think of 10-30,000 verts - and perhaps even lower. That kind of vertex number I've only ever seen for still renders.

 

cheers, gryff :)

Link to comment
Share on other sites

Gryff,  The reason the 1.4 version did not show any warnings is because that version never showed any warnings, or a log file.  It is the exporter itself which produces the message that warnings were generated.  The old code base usually produced the same sub-optimal output as the new, but did so completely silently.  This silence can things very opaque.

Link to comment
Share on other sites

Well had my first go at producing output (.js , will get .babylon format to work later), BUT output was so massive that it crashed every editor trying to view it.

 

This was going to be a real pain to test, but I remembered that the value for the test for "too many vertices" had been turned into a constant.  I might not have to test that the real, 65K, max works all the way to the browser, just that splitting a mesh works.

 

Temporarily dropped down the limit to 1000, and ran with a .blend that would produce multiple meshes parented together:

MAX_VERTEX_ELEMENTS = 1000 #65535

Did not get the same result, but the shadow is messed up. 

post-8492-0-49361500-1420222401.png

If I can use this test, then will not need to put .blend in repository, but thanks for offering.  Will do a final check with your .blend

 

Link to comment
Share on other sites

I try to export with 1.4 version and it works well

 

Great Juan! Just remember that JCP will likely have a solution very soon. Then, all the "extras" will be available. And of course think about characters with fewer polys :o

 

Jeff, I ran across this a couple of days ago:

 

To Add-on developers: Some changes were made to the Python API, make sure to check them out and update your Add-ons if necessary!

 

That is comment about addons for Blender 2.73 - currently in "Release Candidate" status. No idea how it will impact the exporter.

 

Release Notes 2.73 (Scroll down to addons.)

 

You maybe want to keep an eye on it.

 

cheers, gryff :)

Link to comment
Share on other sites

The shadow casting of split meshes was a new bug.  The original bug was that the code for generating instances got confused when the mesh was split.  The javascript output does not support instances, so it not show the same problem.

 

Both fixed, & in a pull request for .babylon output.  Have not committed & pushed up a new version of TOB (.js / .ts format) to Extensions yet.

 

EDIT:  Gryff, I have not done anything with 2.73.  I expect if there is an issue, someone will report it.  Not looking at pre-production Blender.  MHx 2, maybe, but not Blender.

Link to comment
Share on other sites

Juan, Jeff has updated the BJS github page and  has posted a new version of the Blender exporter (v1.5.0). I tested it with Blender 2.72 and your little character. I still get the warning about splitting meshes - but it works fine. The little dude is there in all his glory.

 

You may want to update your exporter.

 

Nice turnaround Jeff :)

 

cheers, gryff :)

Link to comment
Share on other sites

  • 2 weeks later...

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