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 & HelpOther Libraries › OBJ loader: Change Color of the Model!
Page Index Toggle Pages: 1
OBJ loader: Change Color of the Model! (Read 679 times)
OBJ loader: Change Color of the Model!
Mar 9th, 2008, 11:59am
 
Hi,

I am currently experimenting with the .obj loader library since Id like to have a 3D model in an upcoming project.
I simply want to color the model black. So I thought loading it, disabling the texture and turning fill(0,0,0) would do it. Apparently it does not. Does anyone no how to do this? in The example below I added a sphere which gets the correct colours where the model stays kinda gray.

sample code:
import processing.opengl.*;
import saito.objloader.*;

OBJModel model;

void setup(){
 size(600, 600, OPENGL);
 hint(ENABLE_OPENGL_4X_SMOOTH);
 colorMode(RGB);
 frameRate(30);
 model = new OBJModel(this);
 model.load("test.obj");
 model.drawMode(POLYGON);
 model.disableTexture();
 noStroke();
 smooth();
}
void draw(){
 background(255);
 fill(0,0,0);
 pushMatrix();
 translate(width/2, height/2, -width);
 rotateY(map(mouseX, 0, width, -PI, PI));
 //rotateX(PI/4);
 sphere(300);
 scale(1.0);
 model.draw();
 popMatrix();
}
 
Re: OBJ loader: Change Color of the Model!
Reply #1 - Mar 9th, 2008, 10:07pm
 
Okay, I simply wrote a texture .mtl file to color the .obj black. anyways it would be great to simply color it through processing code.
Re: OBJ loader: Change Color of the Model!
Reply #2 - Mar 10th, 2008, 4:49am
 
Hi sorry for the confusion, at the moment there is an "unofficial" version of the objloader living here

http://www.polymonkey.com/2008/page.asp?obj_loader

It supports what you are trying to do. The function you are looking for is disableMaterial() there are a few extra functions in the unofficial version. They are documented on the same page.

Saito and I need to hook up and sync the current version. Work/Teaching/Collada loader is sucking up too much time. But thanks for using the library. Let me know if there is anything that you need it to do.

MattD
Re: OBJ loader: Change Color of the Model!
Reply #3 - Mar 10th, 2008, 4:54am
 
forgot to tick the "notified of replies button"

(hence this post)
Re: OBJ loader: Change Color of the Model!
Reply #4 - Mar 10th, 2008, 8:15am
 
Hi, thank you! I will have a look at that version!
Page Index Toggle Pages: 1