@t0neg0d said:
Can you give a tiny bit more info about how you split tiles and how you're applying the texCoords?
Sure, but i don't know if it helps,
I have a 3d grid of nodes.-
The current node in the following function is always
index[0],index[1],index[2]
I get neightbour nodes trough:
[java]
Vector2f t1 = new Vector2f(0, 0);
Vector2f t2 = new Vector2f(0, 1);
Vector2f t3 = new Vector2f(1, 1);
Vector2f t4 = new Vector2f(1, 0);
ElasticSurfaceNode n1 = this.surfaceMap.getElasticSurfaceNode(index[0], index[1], index[2], type);
ElasticSurfaceNode n2 = this.surfaceMap.getElasticSurfaceNode(index[0], index[1], index[2] - 1, type);
ElasticSurfaceNode n3 = this.surfaceMap.getElasticSurfaceNode(index[0] + 1, index[1], index[2] - 1, type);
ElasticSurfaceNode n4 = this.surfaceMap.getElasticSurfaceNode(index[0] + 1, index[1], index[2], type);
[/java]
This would get a horizontal x,z square from which then i can generate two triangles:
I have to check the summed normals for all vertices to know where the outside is.
p1 to p4 are vertices, no1 to no4 are normals, t1 to t4 are the texCoords, n1 to n4 are the actual nodes.
[java]
if (n1 != null && n2 != null && n3 != null && n4 != null) {
Vector3f normal = n1.getNormal().add(n2.getNormal()).add(n3.getNormal()).add(n4.getNormal());
normal.normalizeLocal();
if (normal.y > 0) {
Vector3f p1 = n1.getSmoothed();
Vector3f p2 = n2.getSmoothed();
Vector3f p3 = n3.getSmoothed();
Vector3f p4 = n4.getSmoothed();
Vector3f no1 = n1.getNormal();
Vector3f no2 = n2.getNormal();
Vector3f no3 = n3.getNormal();
Vector3f no4 = n4.getNormal();
info.addPosition(p1);
info.addPosition(p3);
info.addPosition(p2);
info.addPosition(p1);
info.addPosition(p4);
info.addPosition(p3);
info.addNormal(no1);
info.addNormal(no3);
info.addNormal(no2);
info.addNormal(no1);
info.addNormal(no4);
info.addNormal(no3);
info.addTexCoord(1, t1);
info.addTexCoord(1, t3);
info.addTexCoord(1, t2);
info.addTexCoord(1, t1);
info.addTexCoord(1, t4);
info.addTexCoord(1, t3);
} else {
Vector3f p1 = n1.getSmoothed();
Vector3f p2 = n2.getSmoothed();
Vector3f p3 = n3.getSmoothed();
Vector3f p4 = n4.getSmoothed();
Vector3f no1 = n1.getNormal();
Vector3f no2 = n2.getNormal();
Vector3f no3 = n3.getNormal();
Vector3f no4 = n4.getNormal();
info.addPosition(p1);
info.addPosition(p2);
info.addPosition(p3);
info.addPosition(p1);
info.addPosition(p3);
info.addPosition(p4);
info.addNormal(no1);
info.addNormal(no2);
info.addNormal(no3);
info.addNormal(no1);
info.addNormal(no3);
info.addNormal(no4);
info.addTexCoord(1, t1);
info.addTexCoord(1, t2);
info.addTexCoord(1, t3);
info.addTexCoord(1, t1);
info.addTexCoord(1, t3);
info.addTexCoord(1, t4);
}
}
[/java]
Then i repeat that for all tree axiscombinations, x,z = top and bottom, x,y = font and back, y,z = sides..