Hi All...
I am new to processing...I succeed to load an OBJModel by the saito OBJLoader library but..the The total Texture is not correctly mapped on the OBJModel. I have already add all .jpg files and .mtl file. But the OBJModel's Texture is not showing correctly..
Please help me...
This is my code..
Please , Let me knoe if m missing something...
import codeanticode.glgraphics.*;import processing.opengl.*;import javax.media.opengl.*;import saito.objloader.*;
// declare that we need a OBJModel and we'll be calling it "model"OBJModel model;GLModel glModel;float rotX;float rotY;
void setup(){size(1000, 700,GLConstants.GLGRAPHICS);
// making an object called "model" that is a new instance of OBJModelmodel = new OBJModel(this, "male01.obj", "relative", TRIANGLES);glModel=new GLModel(this,model.getFaceCount()*3,TRIANGLES,GLModel.STATIC);glModel.beginUpdateVertices();int i = 0;for (int f = 0; f < model.getFaceCount(); f++) {PVector[] fverts = model.getFaceVertices(f);for (int v = 0; v < fverts.length; v++) {glModel.updateVertex(i++, fverts[v].x, fverts[v].y, fverts[v].z);}}glModel.endUpdateVertices();
// Enabling colors.glModel.initColors();glModel.beginUpdateColors();for (int c = 0; c < model.getFaceCount() * 3; c++) {glModel.updateColor(c, 255, 255, 225, 255);}glModel.endUpdateColors();
//********************UPDATE NORMALS//************************************************glModel.initNormals();glModel.beginUpdateNormals();int index = 0;for (int s = 0; s < model.getSegmentCount(); s++) {Segment segment = model.getSegment(s);Face[] faces = segment.getFaces();for (int nn = 0; nn < faces.length; nn++) {PVector[] vs = faces[nn].getVertices();PVector[] ns = faces[nn].getNormals();for (int k = 0; k < vs.length; k++) {glModel.updateNormal(index++, ns[k].x, ns[k].y, ns[k].z);}}}glModel.endUpdateNormals();*///Enabling the use of texturingint index=0;glModel.initTextures(1);img=new GLTexture(this,"male01_1.jpg");glModel.beginUpdateTexCoords(0);for(int s = 0; s < model.getSegmentCount(); s++) {Segment segment = model.getSegment(s);Face[] faces = segment.getFaces();for (int u = 0; u < faces.length; u++) {PVector[] vs = faces[u].getVertices();PVector[] ns = faces[u].getUvs();for (int k = 0; k < vs.length; k++) {glModel.updateTexCoord(index, ns[k].x, ns[k].y);}}}glModel.endUpdateTexCoords();
// turning on the debug output (it's all the stuff that spews out in the black box down the bottom)model.enableDebug();model.printModelInfo();model.translateToCenter();model.scale(3);
noStroke();}
void draw(){background(255);lights();
pushMatrix();translate(width/2, height/2, 0);rotateX(rotY);rotateY(rotX);model.enableTexture();model.enableMaterial();model.draw();popMatrix();}
void mouseDragged(){rotX += (mouseX - pmouseX) * 0.01;rotY -= (mouseY - pmouseY) * 0.01;}
Regards...
1