.obj and .mtl

99 views
Skip to first unread message

Darshana Umakanth

unread,
Apr 18, 2012, 7:49:42 PM4/18/12
to G3D Users
I have a manually generated OBJ file for a plant that is linked to a
separate MTL file. However, the G3D pixel shader and
Articulated::Model override the materials/colors each time. I have set
stripMaterials to false, and yet it still overrides it.

How do I get the G3D viewer to render the colors/materials without
overriding them?

Thanks!
Darshana

Morgan McGuire

unread,
Apr 18, 2012, 11:53:16 PM4/18/12
to g3d-...@googlegroups.com
G3D will use the materials from the MTL file with an ArticulatedModel (in 9.00), for example, in the viewer.  So it should be doing exactly what you want.  Maybe there is an error in your MTL file.  Can you post your files?

-m

Prof. Morgan McGuire
Computer Science Department
Williams College
http://cs.williams.edu/~morgan

Darshana Umakanth

unread,
Apr 18, 2012, 11:58:56 PM4/18/12
to G3D Users
There doesn't seem to be anything wrong with my MTL file because it
works fine when I use an independent OBJ file viewer...

Here it is:

color.mtl

newmtl brown
Ka 0.545 0.271 0.0745
Kd 0.545 0.271 0.0745
Ks 1 1 1
illum 2

newmtl green
Ka 0 1 0
Kd 0 1 0
Ks 1 1 1
illum 2
Ns 0.0

Thanks.
-Darshana


On Apr 18, 11:53 pm, Morgan McGuire <mor...@cs.williams.edu> wrote:
> G3D will use the materials from the MTL file with an ArticulatedModel (in
> 9.00), for example, in the viewer.  So it should be doing exactly what you
> want.  Maybe there is an error in your MTL file.  Can you post your files?
>
> -m
>
> Prof. Morgan McGuire
> Computer Science Department
> Williams Collegehttp://cs.williams.edu/~morgan

Morgan McGuire

unread,
Apr 19, 2012, 10:11:50 AM4/19/12
to g3d-...@googlegroups.com
I need the OBJ file as well to debug.

-m

Prof. Morgan McGuire
Computer Science Department
Williams College
http://cs.williams.edu/~morgan


Darshana Umakanth

unread,
Apr 19, 2012, 10:18:07 AM4/19/12
to g3d-...@googlegroups.com, Morgan McGuire
It is attached.
 
Thanks.
Darshana
 
Sent from my Windows 8 PC 
tree.obj

Darshana Umakanth

unread,
Apr 19, 2012, 11:16:11 PM4/19/12
to g3d-...@googlegroups.com, Morgan McGuire
This might be better OBJ file. It has leaves AND stems. I've also added my main.cpp to cross reference (from the sample pixelshader project).

Thanks!
tree.obj
main.cpp

Morgan McGuire

unread,
Apr 25, 2012, 10:41:16 AM4/25/12
to g3d-...@googlegroups.com
When I load this, I get a file not found exception for "color.mtl".  Since you don't have a color.mtl, that is exactly the right behavior for the library to produce.

When I remove the line "mtllib color.mtl" from your obj file, it loads without error because the data is then correct.

When I create the file color.mtl with contents:


newmtl brown
Ka  0.545 0.271 0.0745
Kd  0.545 0.271 0.0745
Ks  0 0 0
illum 2

newmtl green
Ka 0 1 0
Kd 0 1 0
Ks 0 0 0
illum 2

newmtl purple
Ka 1 0 1
Kd 1 0 1
Ks 0 0 0
illum 2

the model then loads correctly as well and all colors are right.  So I see no bug in G3D here--it looks like you have bad data or an old or modified library version.  I tested this on builds from 2/15/2012 and 4/6/2012 and saw identical results.

-m

Prof. Morgan McGuire
Computer Science Department
Williams College
http://cs.williams.edu/~morgan
2012-04-25_000_viewer32d.jpg

Darshana Umakanth

unread,
Apr 25, 2012, 11:16:17 AM4/25/12
to g3d-...@googlegroups.com
I had a color.mtl but it was corrupt. I copied the MTL data from the emai and created a new file, and it worked!
 
Thank you for your time.
Best,
Darshana

Reply all
Reply to author
Forward
0 new messages