yoric Posted August 29, 2015 Share Posted August 29, 2015 Hi everyone, This looks pretty simple to do, but i'm badly stuck. I'd like to apply a texture to a cube imported from Blender.But i get a colored cube without the texture effect. Below is a link to my playground code(1 cube is from Blender, 1 other cube is created with BabylonJS) I can't figure out why the same material doesn't have the same rendering.Are those two cubes different kind of mesh object ? Playground link : http://www.babylonjs-playground.com/#IZR8L#1 Quote Link to comment Share on other sites More sharing options...
yoric Posted August 29, 2015 Author Share Posted August 29, 2015 I've just upgraded to "io_export_babylon.py" version 3.0.4 (was using 1.8.2 until now), using Blender 2.75 The rendering now looks different on the cube imported from Blender (texture still doesn't show up though). Playground update : http://www.babylonjs-playground.com/#IZR8L#2 Cube export log : Exporter version: 3.0.4, Blender version: 2.75 (sub 0)========= Conversion from Blender to Babylon.js ========= Python World class constructor completed processing begun of mesh: Cube processing begun of Standard material: Material num positions : 36 num normals : 36 num uvs : 0 num uvs2 : 0 num colors : 0 num indices : 36 processing begun of camera (FreeCamera): Camera processing begun of light (POINT): Lamp========= Writing of scene file started ================== Writing of scene file completed ================== end of processing =========elapsed time: 0 min, 0.0022 secs Quote Link to comment Share on other sites More sharing options...
gryff Posted August 29, 2015 Share Posted August 29, 2015 Hi yoric. Just a couple of thoughts which may or may not help. I looked at the playground demo - the blender cube is green. If I REM out line 29 of your playground script the Blender cube is grey (Blender standard material?). That suggests that the cube is getting its green colour from the grass texture. However, when I look at your babylon file there are no UVs , and log file you post above has "num uvs : 0" So, I am thinking that the grass texture is just being smeared over the cube. Just my thoughts. cheers, gryff yoric 1 Quote Link to comment Share on other sites More sharing options...
gryff Posted August 29, 2015 Share Posted August 29, 2015 Try this Yoric: 1. In Blender select your cube object -> go into Edit Mode -> Select all the vertices.2. Still in edit mode -> Mesh -> UV Unwrap ->Unwrap.3. Now export your cube as Babylon file. This new .babylon file should now have a line:"uvs":[1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,0,1,1,1,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,1,0,0,1,0,0,0,1]cheers, gryff yoric 1 Quote Link to comment Share on other sites More sharing options...
yoric Posted August 29, 2015 Author Share Posted August 29, 2015 Amazing Gryff ! i couldn't believe it, but it works like a charm http://www.babylonjs-playground.com/#IZR8L#3 Before reading your last answer, i was doing the UV Mapping / Unwrapping from Blender like this : So I was getting the cube textured from within Blender, and i could then open it from BabylonJS, giving this kind of result : http://www.babylonjs-playground.com/#IZR8L#4 But as you guessed, i wanted to apply the texture from BabylonJS, not from Blender. It's getting a bit more clear to me now... I suppose things work like this : With using BabylonJS only :You create a mesh from BabylonJS You apply a material with diffuseTexture() to this meshWith using Blender :You create a mesh from Blender You UV -> Unwrap it from Blender You import it from BabylonJS You now can apply a material with diffuseTexture() and get the same result I thought creating a cube from BabylonJS or creating it from Blender and then importing it from BabylonJS was the same.But obviously, it is not. Maybe it means BabylonJS creates the UV's array under the hood when creating a mesh object. Thank you so much again for your help Gryff ! 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.