EDIT This is the WebGL code for initializing the tetrahedron points. You may want to skip to the second code block, because you may be able to answer without this.
//Making a tetrahedron with equal sides
//Using rotation matrices to determine the points
//-120 degrees
var q = -Math.PI/2.0 * 4.0/3.0;
//Transformation matrix for X-axis rotation
var rotationArrayX = [
1.0, 0.0, 0.0, 0.0,
0.0, Math.cos(q), Math.sin(q), 0.0,
0.0, -Math.sin(q), Math.cos(q), 0.0,
0.0, 0.0, 0.0, 1.0
];
var rotationMatrixX = mat4.create(rotationArrayX);
var d = vec3.create(new Array(0.0, 1.0, 0.0)); //Topmost point
var a = vec3.create();
mat4.multiplyVec3(rotationMatrixX, d, a);
//Now we have the top most point and the first point of the base
//After rotating the vector A with 120 degrees two times, we have the 3 base points
//120 degrees
q = -q;
//Transformation matrix for Y-axis rotation
var rotationArrayY = [
Math.cos(q), 0.0, -Math.sin(q), 0.0,
0.0, 1.0, 0.0, 0.0,
Math.sin(q), 0.0, Math.cos(q), 0.0,
0.0, 0.0, 0.0, 1.0
];
var rotationMatrixY = mat4.create(rotationArrayY);
//Calculating points B and C
var b = vec3.create();
mat4.multiplyVec3(rotationMatrixY, a, b);
var c = vec3.create();
mat4.multiplyVec3(rotationMatrixY, b, c);
//The remaining point is the top point
var vertices = new Array();
//bottom
vertices.push(a); vertices.push(b); vertices.push(c);
//front
vertices.push(b); vertices.push(c); vertices.push(d);
//right
vertices.push(c); vertices.push(a); vertices.push(d);
//left
vertices.push(a); vertices.push(b); vertices.push(d);
How should I imagine texturing these triangles? Is this a valid set of texture coordinates?
var textureCoords = [
//bottom
0.5, 1.0,
0.0, 0.0,
1.0, 0.0,
//front
0.5, 1.0,
0.0, 0.0,
1.0, 0.0,
//right
0.5, 1.0,
0.0, 0.0,
1.0, 0.0,
//left
0.5, 1.0,
0.0, 0.0,
1.0, 0.0,
];
I based this on http://www.codeguru.com/forum/showpost.php?p=1542703&postcount=2:
-------(0.5,1)-------
| |
| Texture |
| Image |
| |
| |
(0,0)---------------(1,0)
Thanks in advance!