Saito,objloader uv problem

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

Answers

  • edited August 2016

    this are the data that i get from uv

    uv [ 0.699361, 0.37325698, 0.0 ]
    uv [ 0.701246, 0.36307102, 0.0 ]
    uv [ 0.686908, 0.36947602, 0.0 ]
    uv [ 0.699361, 0.37325698, 0.0 ]
    uv [ 0.701246, 0.36307102, 0.0 ]
    uv [ 0.686908, 0.36947602, 0.0 ]
    uv [ 0.699361, 0.37325698, 0.0 ]
    uv [ 0.701246, 0.36307102, 0.0 ]
    uv [ 0.686908, 0.36947602, 0.0 ]
    uv [ 0.699361, 0.37325698, 0.0 ]
    uv [ 0.701246, 0.36307102, 0.0 ]
    uv [ 0.686908, 0.36947602, 0.0 ]
    uv [ 0.699361, 0.37325698, 0.0 ]
    uv [ 0.701246, 0.36307102, 0.0 ]
    uv [ 0.686908, 0.36947602, 0.0 ]
    uv [ 0.699361, 0.37325698, 0.0 ]
    uv [ 0.701246, 0.36307102, 0.0 ]
    uv [ 0.686908, 0.36947602, 0.0 ]
    uv [ 0.699361, 0.37325698, 0.0 ]
    uv [ 0.701246, 0.36307102, 0.0 ]
    uv [ 0.686908, 0.36947602, 0.0 ]
    uv [ 0.699361, 0.37325698, 0.0 ]
    uv [ 0.701246, 0.36307102, 0.0 ]
    uv [ 0.686908, 0.36947602, 0.0 ]
    uv [ 0.699361, 0.37325698, 0.0 ]
    uv [ 0.701246, 0.36307102, 0.0 ]
    uv [ 0.686908, 0.36947602, 0.0 ]
    uv [ 0.699361, 0.37325698, 0.0 ]
    uv [ 0.701246, 0.36307102, 0.0 ]
    uv [ 0.686908, 0.36947602, 0.0 ]
    uv [ 0.699361, 0.37325698, 0.0 ]
    uv [ 0.701246, 0.36307102, 0.0 ]
    uv [ 0.686908, 0.36947602, 0.0 ]
    uv [ 0.699361, 0.37325698, 0.0 ]
    uv [ 0.701246, 0.36307102, 0.0 ]
    uv [ 0.686908, 0.36947602, 0.0 ]
    uv [ 0.699361, 0.37325698, 0.0 ]
    uv [ 0.701246, 0.36307102, 0.0 ]
    uv [ 0.686908, 0.36947602, 0.0 ]
    uv [ 0.699361, 0.37325698, 0.0 ]
    uv [ 0.701246, 0.36307102, 0.0 ]
    uv [ 0.686908, 0.36947602, 0.0 ]
    uv [ 0.699361, 0.37325698, 0.0 ]
    uv [ 0.701246, 0.36307102, 0.0 ]
    uv [ 0.686908, 0.36947602, 0.0 ]
    uv [ 0.699361, 0.37325698, 0.0 ]
    uv [ 0.701246, 0.36307102, 0.0 ]
    uv [ 0.686908, 0.36947602, 0.0 ]
    uv [ 0.699361, 0.37325698, 0.0 ]
    uv [ 0.701246, 0.36307102, 0.0 ]
    uv [ 0.686908, 0.36947602, 0.0 ]
    uv [ 0.699361, 0.37325698, 0.0 ]
    uv [ 0.701246, 0.36307102, 0.0 ]
    uv [ 0.686908, 0.36947602, 0.0 ]
    uv [ 0.699361, 0.37325698, 0.0 ]
    uv [ 0.701246, 0.36307102, 0.0 ]
    uv [ 0.686908, 0.36947602, 0.0 ]
    uv [ 0.699361, 0.37325698, 0.0 ]
    uv [ 0.701246, 0.36307102, 0.0 ]
    uv [ 0.686908, 0.36947602, 0.0 ]
    uv [ 0.699361, 0.37325698, 0.0 ]
    uv [ 0.701246, 0.36307102, 0.0 ]
    uv [ 0.686908, 0.36947602, 0.0 ]
    uv [ 0.699361, 0.37325698, 0.0 ]
    uv [ 0.701246, 0.36307102, 0.0 ]
    uv [ 0.686908, 0.36947602, 0.0 ]
    uv [ 0.699361, 0.37325698, 0.0 ]
    uv [ 0.701246, 0.36307102, 0.0 ]
    uv [ 0.686908, 0.36947602, 0.0 ]
    uv [ 0.699361, 0.37325698, 0.0 ]
    uv [ 0.701246, 0.36307102, 0.0 ]
    uv [ 0.686908, 0.36947602, 0.0 ]
    uv [ 0.699361, 0.37325698, 0.0 ]
    uv [ 0.701246, 0.36307102, 0.0 ]
    uv [ 0.686908, 0.36947602, 0.0 ]
    uv [ 0.699361, 0.37325698, 0.0 ]
    uv [ 0.701246, 0.36307102, 0.0 ]
    uv [ 0.686908, 0.36947602, 0.0 ]
    uv [ 0.699361, 0.37325698, 0.0 ]
    uv [ 0.701246, 0.36307102, 0.0 ]
    uv [ 0.686908, 0.36947602, 0.0 ]
    uv [ 0.699361, 0.37325698, 0.0 ]
    uv [ 0.701246, 0.36307102, 0.0 ]
    uv [ 0.686908, 0.36947602, 0.0 ]
    uv [ 0.699361, 0.37325698, 0.0 ]
    uv [ 0.701246, 0.36307102, 0.0 ]
    uv [ 0.686908, 0.36947602, 0.0 ]
    uv [ 0.699361, 0.37325698, 0.0 ]
    uv [ 0.701246, 0.36307102, 0.0 ]
    uv [ 0.686908, 0.36947602, 0.0 ]
    uv [ 0.699361, 0.37325698, 0.0 ]
    
  • textureMode(NORMAL) ?

    you will only need the first two arguments

  • yeah i know,but the uvs dont correspond to the image.The texture image is a uv unwrap from a model.maybe they correspond to the local transformation each,face, and if you check they are repeating every 3,maybe these are the vertices of the triangle face.Also the orgv.length is 3.

  • I think i have to put i in PVector uv = model.getUV(i);,but when i get a message outofBounException index 2998 size 2998

Sign In or Register to comment.