overlapping values with Pvector
in
Contributed Library Questions
•
2 years ago
hi everybody,
i'm looking at a script to long.. it's a simple thing i thought, but it's more complex than i thought.
I have a OBJ file with Pvector cooordinates and i want to overlap them over each other. They are all faces. so what did i do is get the value of the nose, and that is the value i want to use to overlap the faces. First i looped all the values to get the nose value, so i did this:
The values are this:
--- val 0
x 38: y 1 : z 136
----- val 1
x 16: y -1: z 126
----- val 2
x 31: y 15: z 141
after that i did this:
The X Y and Z values i've added should be closer at about: X 30 Y -4 Z -114
i've done this by adjusting by hand.
i'm looking at a script to long.. it's a simple thing i thought, but it's more complex than i thought.
I have a OBJ file with Pvector cooordinates and i want to overlap them over each other. They are all faces. so what did i do is get the value of the nose, and that is the value i want to use to overlap the faces. First i looped all the values to get the nose value, so i did this:
- for (int x = 0; x <model.length-1; x++) {
for(int i = 0; i < model[x].getVertexCount(); i++) {
PVector orgv = model[x].getVertex(i);
if (int(orgv.z) > minVal) {
minVal = int(orgv.z);
minValI = i;
}
}
PVector orgv = model[x].getVertex(minValI);
minValX[x] = int(orgv.x) ;
minValY[x] = int(orgv.y);
minValZ[x] = int(orgv.z);
minVal = 0;
}
The values are this:
--- val 0
x 38: y 1 : z 136
----- val 1
x 16: y -1: z 126
----- val 2
x 31: y 15: z 141
after that i did this:
- if ( i != model[x].getVertexCount()-1) {
PVector orgv2 = model[x].getVertex(i+1);
if (x == 0) {
stroke(125);
line(orgv.x, orgv.y, orgv.z, orgv2.x, orgv2.y, orgv2.z);
model[x].setVertex(i, orgv);
}
if (x==1) {
stroke(#0700FF);
int valXX = minValX[0];
int valYY = minValY[0];
int valZZ = minValZ[0];
line(orgv.x+valXX, orgv.y+valYY, orgv.z+valZZ, orgv2.x+valXX, orgv2.y+valYY, orgv2.z+valZZ);
model[x].setVertex(i, orgv);
}
The X Y and Z values i've added should be closer at about: X 30 Y -4 Z -114
i've done this by adjusting by hand.
1