Tryna create planar mapping xy for a sphere. How to change the default mapping? Some tutorial link?
I’ve never heard of any default mapping in Processing, but if you want to convert from 3d coordinates to UV coordinates, here’s how you do it:
float [] xyzToUV(PVector p, PVector center, float r) { //p: point in 3d space, center: center of the sphere, r: radius of the sphere
float [] ret = new int [2]; //u and v coordinates, u = [0, 2[, v = [0, 1[
p.sub(center).div(r); //transforming the point as if it was on a sphere with radius 1 centered at the origin
ret[0] = atan2(p.z, p.x)/PI+2)%2;
ret[1] = asin(p.y)/PI+0.5;
return ret;
}
I hope this helps you
Best, Simon
2 Likes