mout99 Posted June 27, 2017 Share Posted June 27, 2017 Hello, I have an .obj file and .mtl, when I try to run it the texture gets wrong, look at the images var canvas = document.querySelector("#renderCanvas"); // Load the BABYLON 3D engine var engine = new BABYLON.Engine(canvas, true); // ------------------------------------------------------------- // Here begins a function that we will 'call' just after it's built var createScene = function () { var scene = new BABYLON.Scene(engine); //Adding a light var light = new BABYLON.HemisphericLight("light", new BABYLON.Vector3(0, 1, 0), scene); //Adding an Arc Rotate Camera var camera = new BABYLON.ArcRotateCamera("Camera", 0, 0.8, 100, BABYLON.Vector3.Zero(), scene); camera.wheelPrecision = 100.0; camera.attachControl(canvas, false); // The first parameter can be used to specify which mesh to import. Here we import all meshes BABYLON.SceneLoader.ImportMesh("", "js/novo/", "bg4_obj.obj", scene, function (newMeshes) { // Set the target of the camera to the first imported mesh // camera.maxZ = 100; camera.setPosition(new BABYLON.Vector3(30,30,30)); camera.target = newMeshes[0]; camera.wheelPrecision = 30; }); // Move the light with the camera scene.registerBeforeRender(function () { light.position = camera.position; }); return scene; } // ------------------------------------------------------------- // Now, call the createScene function that you just finished creating var scene = createScene(); // Register a render loop to repeatedly render the scene engine.runRenderLoop(function () { scene.render(); }); // Watch for browser/canvas resize events window.addEventListener("resize", function () { engine.resize(); }); bg4_obj.mtl bg4_obj.obj Quote Link to comment Share on other sites More sharing options...
gryff Posted June 27, 2017 Share Posted June 27, 2017 @mout99 : you have issues with the model. Many of the normals seem to be facing inside, some outside In addition there are some odd faces that cause Z-buffer clashing with other faces. cheers, gryff Quote Link to comment Share on other sites More sharing options...
mout99 Posted June 27, 2017 Author Share Posted June 27, 2017 How do I solve this? Quote Link to comment Share on other sites More sharing options...
gryff Posted June 27, 2017 Share Posted June 27, 2017 @mout99 : Well you could get all the materials used and then: aMat.backFaceCulling = false; replacing aMat with all the different materials you have But that still leaves the issue of those odd faces - they should probably removed in some 3D software. BJS can not help you there cheers, gryff GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
mout99 Posted June 28, 2017 Author Share Posted June 28, 2017 Sorry, I do not understand, can you show me in my code how do I do it? Quote Link to comment Share on other sites More sharing options...
mout99 Posted June 28, 2017 Author Share Posted June 28, 2017 please, i need help Quote Link to comment Share on other sites More sharing options...
Borislav Posted June 29, 2017 Share Posted June 29, 2017 9 hours ago, mout99 said: Sorry, I do not understand, can you show me in my code how do I do it? What do you want to do? This? On 28.06.2017 at 1:10 AM, gryff said: @mout99 : Well you could get all the materials used and then: aMat.backFaceCulling = false; replacing aMat with all the different materials you have But that still leaves the issue of those odd faces - they should probably removed in some 3D software. BJS can not help you there cheers, gryff Quote Link to comment Share on other sites More sharing options...
mout99 Posted June 29, 2017 Author Share Posted June 29, 2017 Does my texture look like this? Quote Link to comment Share on other sites More sharing options...
Borislav Posted June 29, 2017 Share Posted June 29, 2017 48 minutes ago, mout99 said: Does my texture look like this? Holy moly, that's very messed.... Maybe the UV Map is incorrect? Quote Link to comment Share on other sites More sharing options...
mout99 Posted June 29, 2017 Author Share Posted June 29, 2017 Only of this problem when you have images with the fil Quote Link to comment Share on other sites More sharing options...
mout99 Posted June 29, 2017 Author Share Posted June 29, 2017 how to fix ?? Quote Link to comment Share on other sites More sharing options...
gryff Posted June 29, 2017 Share Posted June 29, 2017 @mout99 : Are you now trying to apply a texture to the .obj model you linked to in your first post? Looking at your .obj and .mtl files in a text editor, I find: 1. no reference to a texture ( lines like this in the .mtl file "map_Kd E:\downloads\textures\cgtextures\brick\TexturesCom_BrickMessy0186_1_seamless_S.jpg") and 2. no lines that begin with "vt" in the .obj file - the uv texture coordinates. Example: vt 0.250043 0.500000 vt 0.250043 0.749957 vt 0.000087 0.250043 All the two files do is reference materials not textures What is the final model supposed to look like? gryff Quote Link to comment Share on other sites More sharing options...
mout99 Posted June 29, 2017 Author Share Posted June 29, 2017 https://www.turbosquid.com/FullPreview/Index.cfm/ID/310973 It has to look like that. Quote Link to comment Share on other sites More sharing options...
gryff Posted June 29, 2017 Share Posted June 29, 2017 @mout99 ; Well I looked at the page you linked to, and notice a couple of things (see image below) 1. There is no texture with the file - so what texture are you trying to add? 2. The model specifications say that it is "UVMapped" but does not have "unwrapped UVs". No idea what he is trying to claim there - I can see no UVmap in your files The image of the house model you post to is just using materials Quote Link to comment Share on other sites More sharing options...
mout99 Posted June 29, 2017 Author Share Posted June 29, 2017 I just want the object to be right without problems, I do not know how to use babylonjs very well I need help Quote Link to comment Share on other sites More sharing options...
gryff Posted June 29, 2017 Share Posted June 29, 2017 I took your.obj model and imported it into Blender. Then just exported it as a .babylon file. The mesh was not modified but I added an arcRotate camera and a hemiLight. Her is the house loaded with no modifications to meshes/materials in the loading code House Note that some walls are not visible from the outside - normals are pointing inward. Here is the same model, but this time I have set backFaceCulling to false. so both sides show. House1 But if you rotate the model you see flashing - z-buffer fighting. Can't change that in BJS with your model. Also, I get the feeling there are missing faces. Not the best of models. Open web developer console to see the tiny changes I made to the materials using code. //because of mesh normals - change backFaceCulling to false var theMaterials = newScene.materials; console.log(theMaterials.length); for (i=0; i < theMaterials.length; i++){ theMaterials[i].backFaceCulling = false; } Nothing more I can do or say except try a different house cheers, gryff . Quote Link to comment Share on other sites More sharing options...
mout99 Posted June 29, 2017 Author Share Posted June 29, 2017 Is there any tutorial on how to import / export blender to .babylon? @edit Can you show me the complete code for me to understand? 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.