Jump to content

Imported mesh is not visible


svatopluk
 Share

Recommended Posts

Hello, I have exported a model from blender for babylon.

I'm using this code to position the mesh:

BABYLON.SceneLoader.ImportMesh("tree leaves leaves1", "models/", "tree.babylon", scene, function (ms) { ms[0].position = BABYLON.Vector3.Zero();
});

The problem is that the mesh is imported but is not visible. I'm a basic user in blender and I'm not sure if I have correctly made a model. I will attach log file from export and .babylon file

tree.babylon

tree.log

Link to comment
Share on other sites

Hi,

It'd help a lot if you could reproduce the issue on the playground and post the link here.

http://www.babylonjs-playground.com/

With that said, I didn't take a look at your exported model, but here are some thoughts:

An exported model possibly contains more than one mesh, so setting the position of just the first one can often not result in a visible change.

In your blender file does your model start at (0, 0) or did you position it differently?

Are any errors thrown in the console?

Link to comment
Share on other sites

Hi @svatopluk : welome to the forum :)

Can you post your .blend file ?

There seems to be a camera and a light in your exported .babylon file as well as 3 meshes, but you are using "BABYLON.SceneLoader.ImportMesh" to import just one mesh. Do you have an alternative camera and lights in your loading script?

cheers, gryff :)

Link to comment
Share on other sites

Hi @svatopluk,

I think we need your .blend file as gryff suggested. If I load the mesh "Cube" from your babylon file, it works. 

First I thought it is because of the white spaces in the mesh name - tested it by rename one of mine and it still works. So post your .blend file and we can help ;)

 

edit: Maybe it has something to do with your materials. In the log-file you can see that there are some 'uvs', but no 'uvs2'. Try to delete all materials and test it again. (Warning: can be misinformation, I'm rather a modeler and relatively new to the materials and textures section)

Link to comment
Share on other sites

Well, I will post the blender file.

Use case is this. In the file there is a tree compose of several meshes which I need to use multiple times in my 3D game. I don't know what is the best way to use the tree from the blender file without camera, light or other stuff. I just need 30 instances of the tree to place on the ground.

Also please note that I didn't make that blender tree I downloaded it from some site and import it in blender and added materials.

So, please help.

tree.blend

Link to comment
Share on other sites

@svatopluk : Thanks for the blend file :)

I took a look at the file - that tree is huge. People make smaller skyboxes!! The lamp and camera were inside the tree!!:o

So:

1.) I applied the rotation to the meshes, removed the basic lamp and added a "Hemi" light, and re-positioned the camera so the tree could be viewed properly in the Babylon Sandbox (see image below)

2. I re-scaled the tree to one tenth (1/10) of its original size and applied that scale, and again re-positioned the camera. It worked fine in the Sandbox also.

So here is a zip flie of your tree with a blend file for case 1, and another for case 2 above : new trees

Ohh and use "BABYLON.SceneLoader.Load" functionality not  "BABYLON.SceneLoader.ImportMesh" as this will not import the lights and camera from blender.

Hope that helps.

cheers, gryff :)

tree1.png

Link to comment
Share on other sites

Hi @svatopluk,

It is always good to apply the scale and rotation of your meshes in blender - except if you want a rotated coordinate system (this can sometimes be tricky....).

So the solution of @gryff works of course, but you don't have to use the camera or light of blender.

Just scale the mesh down (I have now dimensions of max 5 units in z-direction), apply the rotations and scale (STRG+A) and move both the leaves and the trunk into an "empty" (a group - see picture).
tree_empty.PNG
Load this empty-mesh called "tree" with the ImportMesh function and everything is fine. Remember you have to set a camera and light in Babylon (use the basic playground demo for example).

In addition, I fixed a bug in your mesh (see picture).
mesherror.PNG

And here is the blend-file:

tree.blend

Link to comment
Share on other sites

That was helpful, thanks... I have managed to place the trees on the terrain.

Thanks all.

 

There is only a problem with bounding boxes when the object is placed on the ground. The bounding box is squashed. When I call mesh.getBoundingInfo().boundingBox.vectorsWorld I get the points in array with same value. I'm not sure how to get past that.

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