Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

Saito,objloader uv problem

$
0
0

Hello,i made i model that corresponds to my original model,it was based to the example of the saito library,but i want also to transfer the texture.I can take the uv in 3d space coordinates from the model,but i cannot correspond them to each face.The saito libary give me space coordinates but the processing takes 0,1 or 100,200.Here is the code.Can anyone help?I want this to be part of my degree.

Here is the code

import saito.objloader.*;

OBJModel model ;
OBJModel tmpmodel ;

float rotX, rotY;
float k = 0.0;

void setup()
{
  size(800, 600, P3D);
  frameRate(30);
  model = new OBJModel(this, "Model1.obj", "absolute", TRIANGLES);
  model.enableDebug();

  model.scale(100);
  model.translateToCenter();

  tmpmodel = new OBJModel(this, "Model1.obj", "absolute", TRIANGLES);
  tmpmodel.enableDebug();

  tmpmodel.scale(100);
  tmpmodel.translateToCenter();

  stroke(255);
  noStroke();
}



void draw()
{
  background(129);
  lights();

  pushMatrix();
  translate(width/2, height/2);
  beginShape(TRIANGLES);
  float face = model.getFaceCount();

  for (int i =0; i< face; i++) {

    PVector [] orgv = model.getFaceVertices(i);


    for (int k =0; k< orgv.length; k++) {

      PVector  uv = model.getUV(k);
      PVector m = new PVector();


      println("uv "+uv);
      m = orgv[k];
      //m.x= m.x+noise(100);

      //int g = i/3;

      vertex(orgv[k].x, orgv[k].y, orgv[k].z, uv.x, uv.y);
    }
  }

  endShape();
  popMatrix();

  pushMatrix();
  translate(width/2, height/2, 0);
  rotateX(rotY);
  rotateY(rotX);

  //model.draw();
  //tmpmodel.draw();
  //model.clear();
  popMatrix();
}

Thanks in advance


Viewing all articles
Browse latest Browse all 2896

Trending Articles