CGTalk > Software > Maxon Cinema 4D
Login register
Thread Closed share thread « Previous Thread | Next Thread »
 
Thread Tools Search this Thread Display Modes
Old 02-19-2013, 08:09 AM   #1
c4d-jack
Lord of the posts
 
c4d-jack's Avatar
portfolio
Frank Willeke
Senior Developer
Berlin, Germany
 
Join Date: Aug 2004
Posts: 529
Send a message via ICQ to c4d-jack Send a message via AIM to c4d-jack Send a message via Yahoo to c4d-jack
MTL Import

The thing that always bugged me is that, while CINEMA 4D's OBJ importer does a good job reading the geometry data from an .obj file, it ignores the .mtl file, so we have to set all the textures and material properties manually. Takes too much time.

So here's a quick MTL parser, written in Python. Not 100% complete and maybe not the most elegant code. I implemented it using information I found on the Wikipedia article about the Wavefront OBJ format, which seems to be either incomplete or not entirely correct. But it works OK and already saves quite some time The materials have to be finetuned after import, but it's already better than nothing.

It reads and assigns the following from an .mtl file and transfers the values to materials:
  • Ambient color
  • Specular color
  • Specular coefficient
  • Transparency
  • Diffuse map
  • Ambient map
  • Bump map
  • Alpha map (since 1.1)

Shouldn't be too hard for interested people to extend the functionality.

Download from my site:
http://www.c4d-jack.de/site/en/down...import-mtl.html

Crytek Sponza, before:


Crytek Sponza, after:
__________________
FrankWilleke.de

Last edited by c4d-jack : 02-20-2013 at 08:55 AM.
 
Old 02-19-2013, 08:16 AM   #2
E2GO
PRO
portfolio
Egor Gostyshev
CG Artist
Vladivostok, Russia
 
Join Date: Feb 2009
Posts: 165
Send a message via ICQ to E2GO
Great time saver. Nice wok done!
 
Old 02-19-2013, 10:21 AM   #3
c4d-jack
Lord of the posts
 
c4d-jack's Avatar
portfolio
Frank Willeke
Senior Developer
Berlin, Germany
 
Join Date: Aug 2004
Posts: 529
Send a message via ICQ to c4d-jack Send a message via AIM to c4d-jack Send a message via Yahoo to c4d-jack
Just updated it to version 1.1.
It now supports alpha maps (masks), too.

__________________
FrankWilleke.de

Last edited by c4d-jack : 02-19-2013 at 01:44 PM.
 
Old 02-19-2013, 03:18 PM   #4
serge-m
PRO
 
serge-m's Avatar
portfolio
Serge Mustu
Hamburg, Germany
 
Join Date: Jun 2005
Posts: 113
Danke !!!
A very great time saver !
__________________
_________________
serge-mustu.de
 
Old 02-19-2013, 03:32 PM   #5
winh
Veteran
portfolio
W. Huff
Ridgefield, USA
 
Join Date: Sep 2010
Posts: 36
Great work!!!

This is something I have wanted for a long time.

Thank you,
Frank
 
Old 02-19-2013, 07:04 PM   #6
expo1000
simmi
portfolio
Simon Haecker
3D Kram
ART+COM AG
Berlin, Germany
 
Join Date: Nov 2006
Posts: 88
Thank you very much!
highly appreciated.
s
 
Old 02-19-2013, 09:13 PM   #7
Navstar
Expert
 
Navstar's Avatar
N Parker
Mograph Dude
Los%2BAngeles, United%2BStates
 
Join Date: May 2007
Posts: 2,091
Fantastic! C4D has needed this forever! Thanks!
__________________
----end of line
 
Old 02-20-2013, 12:02 AM   #8
rsquires
Expert
 
rsquires's Avatar
portfolio
Richard Squires
designer/director
reg
Melbourne, Australia
 
Join Date: Jul 2004
Posts: 1,557
I have tried it on an OBJ file created in Modo. After running the script everything is transparent which isn't a problem as it's easy to turn off. However the materials aren't there and says they are missing even though they are residing in the same folder. There's a weird path which doesn't correspond to any paths and it doesn't show which texture goes where. I guess it comes down to how the .mtl file was created in the first place. Any thoughts on how I can get over this

all the best

Richard
 
Old 02-20-2013, 08:35 AM   #9
HolgerBiebrach
@Holgerbiebrach
 
HolgerBiebrach's Avatar
portfolio
Holger Biebrach
Animator, TD
Freelancer
Hamburg, Germany
 
Join Date: Jan 2006
Posts: 1,135
Hey Frank, awesome. Vielen Dank!
__________________
____
Cinema 4D Studio MSA, Zbrush, CS6, 3DCoat, Moi
Twitter: @holgerbiebrach
www.c4dStuff.com

HB_ModellingBundle
 
Old 02-20-2013, 08:40 AM   #10
c4d-jack
Lord of the posts
 
c4d-jack's Avatar
portfolio
Frank Willeke
Senior Developer
Berlin, Germany
 
Join Date: Aug 2004
Posts: 529
Send a message via ICQ to c4d-jack Send a message via AIM to c4d-jack Send a message via Yahoo to c4d-jack
Quote:
Originally Posted by rsquires
I have tried it on an OBJ file created in Modo. After running the script everything is transparent which isn't a problem as it's easy to turn off.

I also noticed, that materials from many MTL come out transparent even though it makes no sense. The problem is: That is correct. The MTL file contains a transparency value of 1.0, which (according to the Wikipedia article) means 100% transparent.
I can imagine that some applications mean to interpret that as 100% opaque, but since there is no way to recognize that from the MTL file, I can't help it.

Quote:
Originally Posted by rsquires
However the materials aren't there and says they are missing even though they are residing in the same folder. There's a weird path which doesn't correspond to any paths and it doesn't show which texture goes where.

You mean the textures, right? Well, the path is taken directly from the MTL file, and should be relative to the MTL file. Open the file with a text editor and take a look (the relevant lines start with "map_").
If a program exports MTL files with wrong paths, then I can't help it.

Quote:
Originally Posted by rsquires
I guess it comes down to how the .mtl file was created in the first place. Any thoughts on how I can get over this

MTL is just a very old, rather crappy and definitely outdated format. The script should simply help with getting the basic colors and textures assigned. Don't expect any high-end ready-to-render materials to come out of it.

+ + +

Oh, yeah, and in the meantime it was updated to version 1.1.1, so make sure you are using the latest version (some bugfixes).
__________________
FrankWilleke.de
 
Old 02-20-2013, 09:43 AM   #11
rsquires
Expert
 
rsquires's Avatar
portfolio
Richard Squires
designer/director
reg
Melbourne, Australia
 
Join Date: Jul 2004
Posts: 1,557
Quote:
Originally Posted by c4d-jack
I also noticed, that materials from many MTL come out transparent even though it makes no sense. The problem is: That is correct. The MTL file contains a transparency value of 1.0, which (according to the Wikipedia article) means 100% transparent.
I can imagine that some applications mean to interpret that as 100% opaque, but since there is no way to recognize that from the MTL file, I can't help it.


You mean the textures, right? Well, the path is taken directly from the MTL file, and should be relative to the MTL file. Open the file with a text editor and take a look (the relevant lines start with "map_").
If a program exports MTL files with wrong paths, then I can't help it.


MTL is just a very old, rather crappy and definitely outdated format. The script should simply help with getting the basic colors and textures assigned. Don't expect any high-end ready-to-render materials to come out of it.

+ + +

Oh, yeah, and in the meantime it was updated to version 1.1.1, so make sure you are using the latest version (some bugfixes).


Cheers mate. Thanks for letting it out in the wild
 
Old 02-20-2013, 12:36 PM   #12
ooo
actually my name is odo
 
ooo's Avatar
 
Join Date: May 2003
Posts: 2,729
Thanks a lot! works great.

odo
 
Old 03-01-2013, 09:45 AM   #13
c4d-jack
Lord of the posts
 
c4d-jack's Avatar
portfolio
Frank Willeke
Senior Developer
Berlin, Germany
 
Join Date: Aug 2004
Posts: 529
Send a message via ICQ to c4d-jack Send a message via AIM to c4d-jack Send a message via Yahoo to c4d-jack
I just uploaded a mini update from 1.1.1 to 1.1.2:
Problems with UTF8 encoded filenames have been fixed.

Download, as usual, from my website.
__________________
FrankWilleke.de

Last edited by c4d-jack : 03-01-2013 at 09:48 AM.
 
Old 06-19-2013, 05:57 AM   #14
Singular3D
New Member
portfolio
Walter K.
Austria
 
Join Date: Aug 2008
Posts: 4
Thanks a lot for providing this. Always wanted an importer for C4D that works for my Poser stuff and can be extended one day for Vray for C4D. I have to start programing again...
 
Old 06-19-2013, 01:57 PM   #15
c4d-jack
Lord of the posts
 
c4d-jack's Avatar
portfolio
Frank Willeke
Senior Developer
Berlin, Germany
 
Join Date: Aug 2004
Posts: 529
Send a message via ICQ to c4d-jack Send a message via AIM to c4d-jack Send a message via Yahoo to c4d-jack
You're welcome, I'm glad you can use it.
__________________
FrankWilleke.de
 
Thread Closed share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 04:57 PM.


Powered by vBulletin
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.