Jump to content

Loading a "complex" Blender Scene


Moon
 Share

Recommended Posts

Hello,

First of all thank you for this wonderful FrameWork, it's just amazing. I discovered it less than one month ago.

 

This is my first post, and here is my problem:

 

I use the latest version of FireFox and the lastest stable version of BABYLON.JS

 

I have a blender scene, which I want to load, but what happens is that either it gives me some errors like "TypeError: vbo is null" and "Unable to compile effect: default" .... or it shows the ground and the box I created with BBJS along with a "map of the town scene that I wanted to load but not the actual buildings...

 

And here is the part of my code that handles the loading:

var moteur = new BABYLON.Engine(jeu, true);//	var scene = new BABYLON.Scene(moteur);        BABYLON.SceneLoader.Load("", "Ville.babylon", moteur, function (scene) {            scene.executeWhenReady(function () {                scene.collisionsEnabled = true;                scene.gravity = new BABYLON.Vector3(0, -9.81, 0);                var joueur = new BABYLON.FreeCamera("Joueur", new BABYLON.Vector3(25, 2, 24), scene);                joueur.applyGravity = true;                joueur.checkCollisions = true;                joueur.speed = 0.3;                joueur.attachControl(jeu);

Is there something that I misunderstood or should know about loading Blender scenes ?

I tested loading a scene containing a simple building (i.e. Just one cube scaled three times vertically, without any texture or material and it worked just fine). 

Link to comment
Share on other sites

Hello there and welcome aboard.

 

Can you please post more code (what's happening in the render loop?).

Btw, you have the "var scene" commented out, it won't work for sure that way. In a first look everything seems ok. Can you jsfiddle?

Link to comment
Share on other sites

Hi, thank you.

Before I go further, I wanted to ask: is there a limit on the number of vertices... the imported scene can have ? I think I have read it somewhere...

 

And by the way, at http://blogs.msdn.com/b/eternalcoding/archive/2013/06/28/babylon-js-how-to-load-a-babylon-file-produced-with-blender.aspx they didn't instanciate the scene before the loading request.

Also, as you can see in the screenshot, the scene does appear (with ground and skybox) but without the imported part from Blender. But sometimes nothing appears and just throws errors...

Link to comment
Share on other sites

It's probably that which causes me problems, because my scene is a monstruous one with hundreds of buildings and tens of cars (the cars are probably the worst part).

 

I will edit it and see how it goes.

Link to comment
Share on other sites

Ah okay, thanks for the info.

 

Anyway, I have edited the scene during the night and reduced the number of cars and buildings.

I tried to load it again but most of the time, the browser didn't render anything and just throwed errors (will past the various errors at the bottom), and sometimes it rendered the BBJS ground and skybox only to crash 2 seconds later. Then I had some chance and it rendered for a little longer (1 minute or so) and I have gladly seen that it managed to load the cars :) but not the buildings :(

 

Here are the errors I have got:

-------------

"Unable to compile effect: default" babylon.js:1
"Defines: #define UV1" babylon.js:1
"Optional defines: " babylon.js:1
------------
"Unable to compile effect: default" babylon.js:1
"Defines: #define REFLECTION
#define LIGHT0
#define POINTDIRLIGHT0
#define UV1" babylon.js:1
"Optional defines: " babylon.js:1
------------
Error: WebGL: drawElements: must have element array buffer binding babylon.js:1
TypeError: vbo is null babylon.js:1
"Unable to compile effect: default" babylon.js:1
"Defines: #define REFLECTION
#define LIGHT0
#define POINTDIRLIGHT0
#define UV1" babylon.js:1
"Optional defines: " babylon.js:1
TypeError: vbo is null babylon.js:1
Link to comment
Share on other sites

Can someone here provide me with .blend and .babylon files (nothing fancy, a box with an image texture will do) along with the used texture, that is working for you, so that I can try to locate the problem, if it's with my code, computer, browser or Blender...

 

That would be highly appreciated. Thank you.

Link to comment
Share on other sites

Can someone here provide me with .blend and .babylon files (nothing fancy, a box with an image texture will do) along with the used texture, that is working for you, so that I can try to locate the problem, if it's with my code, computer, browser or Blender...

 

Here is a zip file containing a babylon file for a textured cube, the texture and a simple html file to load the babylon file. I have also included the cube.blend file so you can check it out. If the car meshes are being seen with no textures - check out the material and texture set up in the .blend file. If you don't set up the textures properly in Blender they wil not show in your scene.

 

cheers, gryff :)

 

cube_babylon.zip

Link to comment
Share on other sites

Your Babylon file works and the one I exported from your Blend file works as well, so this means that the problem is within my Blender file. :(

Can you give me some advice as to how to proceed to have this working ?

In my scene, the buildings have been UV Unwraped and then a material having an image texture has been applied to the faces...

Link to comment
Share on other sites

I could finally reproduce the textured cube you provided me. So now, I'm completely sure that the problem was/is within my original scene. :)

Thank you very much.

 

Now that I have understood the right procedure, I will try to fix my scene. 

If you are still interrested, I can share it with you and you will give it a look to help me fix it.

Link to comment
Share on other sites

I realized a very important thing here... I HAVE TO USE the Blender Render and NOT the Cycles Render.

Maybe you can add/mention it in the artcile talking about Blender, @DeltaKoch.

 

Because, while my scene looks just amazing B)  in Cycles, it's plain white with Blender Render.

Link to comment
Share on other sites

If you are still interrested, I can share it with you and you will give it a look to help me fix it.

 

Sure. I'm willing to help. will need to look at some .blend files though.

 

I HAVE TO USE the Blender Render and NOT the Cycles Render.

 

Does that solve/explain your issues?

 

cheers, gryff :)

Link to comment
Share on other sites

Does that solve/explain your issues?

 

Yes, that was the main reason, I switched to Blender Internal but after some tests, I still had the precedant errors... so I'm re-doing the scene from scratch in Blender Internal and it's much faster and lighter.

 

Also I wanted to ask, which lights settings would you advise me to have a good rendering ? I ask this because I noted that the imported scene is affected only by its lights from Blender and not the one in BabylonJs.

 

Thanks again for the cube file. It really helped me understand the origin of the problem. :)

Link to comment
Share on other sites

I ask this because I noted that the imported scene is affected only by its lights from Blender and not the one in BabylonJs.

 

Moon: when I first started using BJS I was a little diasppointed with the lighting - but that has changed with the more recent versions as the range of the Omni and Spotlight. can now be controlled. Normally, when I am creating stuff in Blender I usually add a camera (FreeCamera) and a Hemi light (basic flat cloudy day lighting)- just so I can visualize a scene without having to add anything. to the script.

 

You can add your lights in the script no need to add them in Blender as well as change the camera type.

 

The only light I have experimented with is the Omni llight - setting range/intensity. Seems to work well.

 

Also, if you want to you can open the .babylon file (I use Notepad++) and change the values of various parameters - cameras and lights are usually right at the top of the file  - I used that to tweak the range and intensity when I was testing the Omni light.

 

It really is a matter of trying various lighting layouts until you get the effect you want.

 

Ohh, and I believe there is a limit of 4 lights that can illuminate a single mesh.

 

cheers, gryff :)

Link to comment
Share on other sites

The limit is per mesh. A mesh cannot have more than 65536 vertices because else you need more than a 16bit index to address it

There is no limit when it comes to the limit of meshes per scene

Technically I do not see that there is a limit, since the python script breaks large blender meshes into multiple babylon meshes with ones after the first forced parented to the first.

 

Noticed side effects of parenting as opposed to s single babylon mesh though.  First is if you move, position, parent mesh in code after all the kids do not move as well.  Also not sure if problems will result from a multi-mesh with armature.

Link to comment
Share on other sites

C'est reparti pour un tour ! :)

 

I finished re-doing the scene and guess what... the errors reappared again and it wouldn't render anything.

 

To give you some details about what I did, here it is: I modeled some basic buildings and then went to the first layer where I generated a town on a subdivided plane (grid) with a particles system where the buildings rise from the vertices of the grid.

 

It gave me the following errors:

"Unable to compile effect: default" babylon.js:1"Defines: #define LIGHT0#define HEMILIGHT0#define UV1" babylon.js:1"Optional defines: " babylon.js:1"Unable to compile effect: default" babylon.js:1"Defines: #define DIFFUSE#define LIGHT0#define HEMILIGHT0#define UV1" babylon.js:1"Optional defines: " babylon.js:1

So I thaught the light was the problem, so I simply deleted it to test it out, then I got the following errors:

"Unable to compile effect: default" babylon.js:1"Defines: #define UV1" babylon.js:1"Optional defines: " babylon.js:1"Unable to compile effect: default" babylon.js:1"Defines: #define DIFFUSE#define UV1" babylon.js:1"Optional defines: " babylon.js:1

Then I tried with the last saved file before I make up the grid and it worked twice out of three (the first and the third time).

 

If you want to give it a try, here is the babylon file (the grid version) attached, just change its extension from .txt back to .babylon

Ville2.txt

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