Hello everyone, im currently (trying) to create a character for a project, but im already having a little problem.
Im trying to render each bodypart stand-alone for maximum customizability, but now i need to find out how to “join” these parts.
Example (joint on leg / torso):
Is there any method / algorithm created to remove these seams of separate objects?
Im thinking about cutting off both objects, and add vertrices at these joining points, but i have no idea how to find out what faces are intersecting and where to add vertrices.
*note: these models are generated by code in a loop like this:
private void renderLeg(float x, float y){
float xpos = x;
float ypos = y;
float step = SimpleMath.PI2f / 16;
float currentw = 0, textw = 0, texth = 0;
float[] sidearray = new float[] { 0, 8, 14, 16, 17, 16, 10, 10, 11, 10, 6, 0 };
float[] heightarray = new float[] { 2, 2, 8, 8, 8, 35, 8, 8, 8, 2, 2, 0 };
Vector3f v1, v2, v3, v4;
for(int h = 0; h < sidearray.length-1; h++){
for(float r = 0; r <= SimpleMath.PI2f; r += step){
float bx = xpos + SimpleMath.sinf(r) * sidearray[h+1];
float tx = xpos + SimpleMath.sinf(r) * sidearray[h];
float tz = SimpleMath.cosf(r) * sidearray[h];
float bz = SimpleMath.cosf(r) * sidearray[h+1];
float tx2 = xpos + SimpleMath.sinf(r+step) * sidearray[h];
float bx2 = xpos + SimpleMath.sinf(r+step) * sidearray[h+1];
float tz2 = SimpleMath.cosf(r+step) * sidearray[h];
float bz2 = SimpleMath.cosf(r+step) * sidearray[h+1];
v1 = new Vector3f(tx2, ypos,tz2);
v2 = new Vector3f(bx2, ypos+heightarray[h],bz2);
v3 = new Vector3f(bx, ypos+heightarray[h],bz);
v4 = new Vector3f(tx,ypos,tz);
TrianglePoint_Tree tp1 = new TrianglePoint_Tree(v1, new Vector2f(currentw+textw, texth), 0, 0f);
TrianglePoint_Tree tp2 = new TrianglePoint_Tree(v2, new Vector2f(currentw+textw, 0), 0, 0f);
TrianglePoint_Tree tp3 = new TrianglePoint_Tree(v3, new Vector2f(currentw, 0), 0, 0f);
TrianglePoint_Tree tp4 = new TrianglePoint_Tree(v4, new Vector2f(currentw, texth), 0, 0f);
vbo.addTriangle(tp1, tp2, tp3);
vbo.addTriangle(tp3, tp4, tp1);
}
ypos += heightarray[h];
}
}