Hi @mala,
It’s not quite clear how complex your project is, since you haven’t posted any code, but if you’re free to choose a different dev environment for your project, I’d recommend doing that.
Imagine for a moment that Processing could parse the hypothetical car .obj file into appropriate pieces (four wheels, chassi, etc.). It’d still take less hassle to coordinate and animate those pieces in a program like Unity, Blender or – take your pick – than it would in Processing.
Another possibility would be to research Processing libraries, which would involve looking through their documentation and/or examples.
The source code for getTessellation is here. The simplified code (no .mtl file) below seems to retain UVs post-tessellation.
PShapeOpenGL shape;
PImage txtr;
void setup() {
size(256, 256, P3D);
textureWrap(REPEAT);
txtr = rgb(256, 256);
shape = (PShapeOpenGL)loadShape("cube.obj");
shape = (PShapeOpenGL)shape.getTessellation();
shape.setTextureMode(NORMAL);
shape.setTexture(txtr);
}
void draw() {
background(#fff7d5);
directionalLight(255, 245, 215, 0.0, 0.6, -0.8);
camera(
0.0, 0.0, height * 0.86602,
0.0, 0.0, 0.0,
0.0, 1.0, 0.0);
rotate(frameCount * 0.01, 0.0, 0.6, 0.8);
scale(128);
shape(shape);
}
PImage rgb(int w, int h) {
PImage result = createImage(w, h, ARGB);
result.loadPixels();
for (int i = 0, y = h - 1; y > -1; --y) {
float gr = y * 255.0 / (h - 1);
for (int x = 0; x < w; ++x, ++i) {
float re = x * 255.0 / (w - 1);
result.pixels[i] = color(
re, gr, 127.0, 255.0);
}
}
result.updatePixels();
return result;
}
The .obj file is as follows:
o Cube
v -0.353553 -0.353553 -0.353553
v -0.353553 -0.353553 0.353553
v -0.353553 0.353553 -0.353553
v -0.353553 0.353553 0.353553
v 0.353553 -0.353553 -0.353553
v 0.353553 -0.353553 0.353553
v 0.353553 0.353553 -0.353553
v 0.353553 0.353553 0.353553
vt 0.000000 0.000000
vt 0.000000 1.000000
vt 1.000000 1.000000
vt 1.000000 0.000000
vn 1.000000 0.000000 0.000000
vn 0.000000 0.000000 1.000000
vn 0.000000 0.000000 -1.000000
vn 0.000000 -1.000000 0.000000
vn -1.000000 0.000000 0.000000
vn 0.000000 1.000000 0.000000
f 1/3/5 2/4/5 4/1/5 3/2/5
f 3/3/6 4/4/6 8/1/6 7/2/6
f 7/3/1 8/4/1 6/1/1 5/2/1
f 5/3/4 6/4/4 2/1/4 1/2/4
f 3/2/3 7/3/3 5/4/3 1/1/3
f 8/2/2 4/3/2 2/4/2 6/1/2
Best,
Jeremy