svatopluk Posted September 14, 2016 Share Posted September 14, 2016 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 Quote Link to comment Share on other sites More sharing options...
royibernthal Posted September 14, 2016 Share Posted September 14, 2016 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? Quote Link to comment Share on other sites More sharing options...
gryff Posted September 15, 2016 Share Posted September 15, 2016 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 Quote Link to comment Share on other sites More sharing options...
Steffen Posted September 15, 2016 Share Posted September 15, 2016 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) Quote Link to comment Share on other sites More sharing options...
svatopluk Posted September 15, 2016 Author Share Posted September 15, 2016 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 Quote Link to comment Share on other sites More sharing options...
gryff Posted September 15, 2016 Share Posted September 15, 2016 @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!! 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 Steffen 1 Quote Link to comment Share on other sites More sharing options...
svatopluk Posted September 15, 2016 Author Share Posted September 15, 2016 Thanks a lot. I will try this and take a look at the result. Quote Link to comment Share on other sites More sharing options...
Steffen Posted September 16, 2016 Share Posted September 16, 2016 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). 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). And here is the blend-file: tree.blend gryff and svatopluk 2 Quote Link to comment Share on other sites More sharing options...
svatopluk Posted September 16, 2016 Author Share Posted September 16, 2016 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.