Jump to content

Change the color of an imported obj


legallon
 Share

Recommended Posts

Hi everybody ! 

I'm importing .obj files in my application, and I want to change their color. However, the color seems to be changed when the page is loading, but when it's finally loaded the mesh still has its basic grey material (so while the whole scene is loading we can see the mesh being pink for half a second and then takes back its basic color/texture/material).  

I've seen something about UV maps etc.. but I checked it in Blender and it is activated when I import into obj. 

 

Here's a pg trying to reproduce my problem ( first you will need to help me importing my object into the pg because it doesn't seem to be working, I can't see it on scene); I added a skull.babylon to show that the code I provide is supposed to work : https://www.babylonjs-playground.com/#V9KE7I#7

 

Thanks for your time ! :)

Link to comment
Share on other sites

Hi Legallon !

Concerning the import from you git repo to the playground, I think that is only a CORS problem.

Concerning the wrong material, I think the problem is that your .OBJ says which material to use (line 3 : mtllib camion.mtl). Just remove the link of .mtl when you export from Blender (or directly remove this line from your .OBJ) to make sure the material used will be the one you define with babylon. This should fix your problem.

Hope it helps

Link to comment
Share on other sites

5 minutes ago, Amarth2Estel said:

Hi Legallon !

Concerning the import from you git repo to the playground, I think that is only a CORS problem.

Concerning the wrong material, I think the problem is that your .OBJ says which material to use (line 3 : mtllib camion.mtl). Just remove the link of .mtl when you export from Blender (or directly remove this line from your .OBJ) to make sure the material used will be the one you define with babylon. This should fix your problem.

Hope it helps

Hey man , 

Thanks for the suggestion concerning the material !  I comentend the line 3 and it works. I didn't really think it was about the mtl file because I thought I was forced to import it with my object ( now I can see that I'm not).

Thanks again , it helped a lot ;)

Link to comment
Share on other sites

33 minutes ago, V!nc3r said:

When data is on github, you have to use the raw link. And I also use scene.append:

https://www.babylonjs-playground.com/#V9KE7I#9

But I was unable to get your already existing material, don't know why ?

Hey @V!nc3r,

Thanks for your answer, I didn't know about the raw link !  No worries for the material, @Amarth2Estel  helped me for this.

Thanks for the help mate ! :)

 

Link to comment
Share on other sites

Montpellier, France?  Cooool.

https://www.huffingtonpost.com/entry/destination-spotlight-montpellier-france_us_5a42adb5e4b0d86c803c73a3

Look at that pretty sphere!  A "3D - aware" city, for sure.  :)

Here in the USA, we use high-tech plastics and monomers to create copies of that "french curvy architecture".

There, you got the REAL stuff.  (drooooool).  C'mon, who is rich and wants to send me on a free Tour-de-France?

Just rent me a motor home and pack it with french toast, and I'll return it in a month.  I got a lot of forum friends in France... that I want to shake hands with.

I'll even make a "BabylonJS Tour de Francais Polygons" - the movie!  I'll sing and play guitar for the whole soundtrack... I'm pretty darned good at that stuff, ya know.  Clint Black + Randy Travis + Jon Anderson, and I can tear-up a guitar pretty thoroughly.  C'mon!  :)

I suppose we would need a corporate sponsor, and that's where it all goes to hell, eh?  :) 

Oh well, I wish I could spend a week in Mont-p... it looks pretty cool.  Ok, back on topic...

  - BJS .obj file loader... pulls .mtl files... if reffed within .obj file?

  - BJS .mtl file loader... pulls texture file(s)... if reffed within .mtl file?

  - Texture files... they just get loaded.  Been there.  ;)

Link to comment
Share on other sites

@Wingnut  Yes, and I would even say a "3D-aware " country : if I'm not mistaking, the great @Deltakosh himself is French !  

 What a nice idea ! I'm pretty sure that every French member of this forum would love to have you and your guitar  with us in France :) 

Coming back to the topic, yes the problem was a mtl file call within the obj file, sneaky peeky stuff ahah hard to find ! 

Link to comment
Share on other sites

30 minutes ago, legallon said:

if I'm not mistaken, the great @Deltakosh himself is French !  

Yeah he is... and a bunch of other BJS founding fathers and early trailblazers, too.

Genuine "french fries"... crispy on the outside, tender on the inside.  We love 'em!

And I think the French... invented/mastered that pastry thing... where they smash the dough micro-thin, then layer it MANY times into a stack, with butter between each layer.  After baking... it's "mouth heaven."  Professional dough-wranglers, for sure.  Professional JS wranglers, too... good coders... good artists.

But... I don't know if France has anyone that can ramble-on aimlessly and hijack someone's solved thread... as well as us constantly-talk-about-ourselves Americans.

Know what the #1 most-discussed subject in America, is?  The weather.  #2 - Where are we going to eat-out for the next meal. 

We certainly are a nation of "deep thinkers", eh?  heh.

Link to comment
Share on other sites

@Wingnut aha I enjoyed this hijacking a lot, allowed me to think of something else than my code for a few minutes !                                                                                                         At least there are people like you to enhance the "deep thinking" level !

Link to comment
Share on other sites

Do we have a flag in the Mesh importers for ignoring materials? If not we should add that.  I know you could just not include a mtl file with obj's but there are other file types that it would be cool to be able to strip all mat's quick and just apply default stuff on the import.

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