saito.objloader and textures (a tomatoes in the jar case...)
in
Contributed Library Questions
•
1 year ago
Hi everyone,
sorry but it seems that displaying textures correctly in a 3D model imported via the
saito.objloader libray, is for me harder than I thought and I really need your expert opinions.
After some trial and error I got some small successes (use of materials and a texture applied to the whole solid), but I'm still quite far from understanding why some of my models don't load correctly.
I might be wrong, but I think the problem arises when the model is made by more than one solid and the texture refers to the material (as defined in the .mtl file) used by only one or few of them.
For example I'd like to render a simple (and ugly ;) ) glass jar I made in 3dsmax where only the cover label actually has a texture and all I get is this...
My testing code looks like this
- import saito.objloader.*;
OBJModel model;
boolean ten = true;
void setup()
{
size(400, 400, P3D);
model = new OBJModel(this, "jarrQuads.obj", OBJModel.RELATIVE, QUADS);
model.scale(7);
model.translateToCenter();
noStroke();
}
void draw()
{
background(128);
lights();
translate(width/2, height/2, 0);
rotateY(radians(frameCount)/2);
rotateX(0.5*PI);
model.draw();
}
the label I want to use, like this... (let's call it 5TOMATES3.jpg)
and my .mtl file (given the problem is there..) looks like this...
- # Max2Mtl Version 4.0 Mar 10th, 2001
#
newmtl 01_-_Default
Ka 0.8 0.9 1.0
Kd 0.8 0.9 1.0
Ks 0.9 0.9 0.9
d 0.2
Ns 3.7
illum 2
#
newmtl 02_-_Default
Ka 0.3 0.3 0.3
Kd 0.3 0.3 0.3
Ks 0.9 0.9 0.9
d 1.0
Ns 0.0
illum 2
#
newmtl 03_-_Default
Ka 0.7 0.3 0.4
Kd 0.7 0.3 0.4
Ks 0.9 0.9 0.9
d 1.0
Ns 0.0
illum 2
#
newmtl 08_-_Default
Ka 0.6 0.6 0.6
Kd 0.6 0.6 0.6
Ks 0.9 0.9 0.9
map_Kd 5TOMATES3.jpg
d 1.0
Ns 0.0
illum 2
#
# EOF
If you'd like to share with me any idea on how to solve this problem, that would be greatly appreciated!
Thanks!
1