We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › Saito OBJLoader - texturing
Page Index Toggle Pages: 1
Saito OBJLoader - texturing? (Read 954 times)
Saito OBJLoader - texturing?
Mar 2nd, 2010, 2:55pm
 
I can't get a simple texured object to render correctly with OBJloader in OpenGL mode.   My OBJ file doesn't specify a MTL (for using procedural textures) and I'm sure the file has Vt, Vn, etc.  The result is a correctly shaped object, with with no texture at all.

Any idea what I'm overlooking?

Code:
import processing.opengl.*;

import saito.objtools.*;
import saito.objloader.*;

OBJModel model;
PImage tex;

void setup()
{
 
 
 size(400,400,OPENGL);
 colorMode(RGB,1,1,1,1);

 model=new OBJModel(this);
 model.disableMaterial(); //Tried all combos of these methods
 model.enableTexture();  // ""
 model.debugMode();    

 model.load("model.obj");
 tex=loadImage("env1.jpg");
 model.setTexture(tex);  // PImage is definitely loading OK (1024x1024 jpg)
 model.setupOPENGL();
 model.drawMode(TRIANGLES);
   
}

void draw()
{
 
 background(.5);
 camera(0,0,500,0,0,0,0,1,0);
 rotateX(mouseY/100.);
 rotateY(mouseX/100.);


 scale(100);
 
 model.drawOPENGL(); //Draws proper mesh, untextured
 
}
Re: Saito OBJLoader - texturing?
Reply #1 - Mar 2nd, 2010, 3:47pm
 
OK.. So I whipped together an MTL file of my own, and eventually got the texturing working.  

So unless I'm mistaken, the only way to get a PImage as a texture map is to FIRST load an MTL with JPG reference, THEN replace the map with setTexture()..  Is that correct?

Page Index Toggle Pages: 1