Mythros

OBJ file not loading correctly?

Recommended Posts

@RaananW Why is it loading my textures but it's not loading ALL of my textures ON to the tree? It's only loading one. :(

It should be loading a leaf texture with transparent background as well as the bark ON to my tree.

And the background should be transparent, but it will most likely turn out light green because I'm not sure how to alpha out that part of the tree either using the MTL or otherwise.

Share this post


Link to post
Share on other sites

Your MTL file looks like this:

#
# Wavefront material file
# Converted by Meshlab Group
#

newmtl material_0
Ka 0.200000 0.200000 0.200000
Kd 1.000000 1.000000 1.000000
Ks 1.000000 1.000000 1.000000
Tr 1.000000
illum 2
Ns 0.000000

There is no definition of a texture at all. Check your OBJ exporter and see why it doesn't export the materials

Share this post


Link to post
Share on other sites

Hi @Mythros,

I am not sure if we see the same thing. Your MTL file is not 404:

 image.thumb.png.a77794d9b88fc21937878b3d210d09d8.png

Also, when enabling offline support, make sure to set a new version when you upload a new file (in the manifest), otherwise the old file will always be loaded.

 

Your questions are all valid, and we are all happy to help, but have you tried solving the problem yourself? What steps did you take to solve this? did you look in the playground? maybe found something interesting in the doc?

Share this post


Link to post
Share on other sites

It would also be great if you remove the offline support. 

About the current state that I see - you have two meshes in your scene, one for branches, and one for leaves (or at least that'S what their names state). I wouldn't expect the leaves to have a single mesh, but I guess this is your plan.

Both meshes are the same size. The leaf mesh is not visible, but I don't know if it is because the mesh object is empty, or that the offline support prevents the user from downloading the updated OBJ file.

Make sure the OBJ is being exported correctly. Try loading it in a different application and see if it works.

Share this post


Link to post
Share on other sites
2 hours ago, Mythros said:

@Deltakosh @RaananW I spent hours getting this to be as small, efficient & easy as possible.

http://babylontesting.epizy.com/loadentity/

Here's a link to the zip : 

http://babylontesting.epizy.com/loadentity/loadentity.zip

I hope this helps!

A few things I noticed:

   You are creating 2 asset managers.

   You have a loadEntity function that doesn't get used.

   You have 2 render loops.

Share this post


Link to post
Share on other sites

Well I'm not sure how much I can contribute to this thread - but I will try :unsure:

I've been playing with the .glTF format and found that I could load them in the Sandbox - so I thought I would try with @Mythros's .obj files.

But first I imported them into Blender and re-exported as a .babylon file. That .babylon file worked fine in the Sandbox.:)

So now I re-exported them from Blender as an .obj file and loaded the .obj file into the Sandbox and I got the result in image 1 (upper) - just the tree trunk. but the materials were present. So I started to make changes.

First, in the leaf material, I changed the the value labelled as "alpha" from 0 ->1. The result, I could now see the "leaves" but  extraneous stuff filled up all the planes - so no transparency :o

I then scrolled down to the texture that was being used and looked at the "hasAlpha" value - Image 2(upper) which said "false"  and changed that to 1.

Result - tree was showing fine (Image 2 bottom) :)

I went back to the babylon file I had created and look at the material parameters.

{"name":"tree1.Mat17310","id":"tree1.Mat17310","ambient":[0.8,0.8,0.8],"diffuse":[0.64,0.64,0.64],"specular":[0.25,0.25,0.25],"emissive":[0,0,0],"specularPower":50,"alpha":1,
"backFaceCulling":true,"checkReadyOnlyOnce":false,"maxSimultaneousLights":4, 

"diffuseTexture":{"name":"English_Oak_diffuse.png","level":1,"hasAlpha":1,"coordinatesMode":0,"uOffset":0,"vOffset":0,"uScale":1,"vScale":1,"uAng":0,"vAng":0,"wAng":0,"wrapU":1,"wrapV":1,"coordinatesIndex":0}},

 

NOTE the value for"alpha (line1) and  "hasAlpha" (last line).

I also tried to load @Mythros's original files into the Sandbox - they did not work. The leaves mesh was visible - but both the trunk and the leaves meshes both had a standard material. The Sandbox seemed to be ignoring the .mtl file. Examining the original .obj file I found this

mtllib ./models/deciduous/01/deciduous01/deciduous01.mtl

Changing that line to :

mtllib deciduous01.mtl

and it loaded and behaved just like my .obj export from Blender did.

I'm not sure if this helps @RaananW, or @Deltakosh  or @Mythros in figuring out the problem. Or did I just add more confusion?

cheers, gryff :)

 

step1.png

step2.png

Share this post


Link to post
Share on other sites

hi, @gryff @Deltakosh @RaananW I need my tree model to be imported as OBJ in a CORRECT way WITH the transparency on the leaves & the leaves showing up.

i just tried the blender babylon exporter, it froze on me when trying to export.

i'd rather my obj file load correctly with everything intact as one single obj file.

thank you <3

Share this post


Link to post
Share on other sites

The mtl file is still wrong:

newmtl Mat59410
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.250000 0.250000 0.250000
Ke 0.000000 0.000000 0.000000
Ni -1.000000
d 0.000000

As you can see d 0.000000 means alpha will be 0 so fully transparent explaining why you do not see your leaves. Replace it with 1.000000 to ensures only alpha test kicks in.

Also, backface culling is turned on in the leaves but this part of the geometry should probably be visible from both side. You should turn backface culling off after loading on this material.

 

Share this post


Link to post
Share on other sites
Just now, Mythros said:

@Sebavan how do i turn off backface culling?

Interestingly I found the answer by doing a search for backfaceculling in the questions and answers section of this forum and it was in the code of the first post of the following thread which you have posted in

just change the false to true.

Share this post


Link to post
Share on other sites

@Sebavan @JohnK Thank you! I've got 2 more small issues with it not loading correctly, then I will mark this as solved. In the pic I uploaded, my leaf texture is only showing half the side of the leaf on each plane of the tree, how to fix? The texture ITSELF is fine. I have circled the problem in Red. 2ndly, how do I remove the shine? I have circled the problem in black.

Thank you all SO much! <3

texture_problem.png

Source code removed

Thank you again! <3

~Mythros

Share this post


Link to post
Share on other sites

after loading in the callback:

// Decrease specular or what is called shine in the thread: 

scene.getMaterialByName("Mat5944").specularColor = BABYLON.Color3.Black();

// Disable culling or what is called seeing half the leaves in the thread:

scene.getMaterialByName("Mat59410").backFaceCulling = false;

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.