Hello,
I am attempting to use a 4x4 matrix to “switch” coordinates of a vertex that has been passed to the vertex shader (ex. (256,0,256) -> (256,256,0) ). All the vertices I am sending to the vertex shader are in the form (x,0,z). Yet instead of seeing the result I expected (a cube) I see this:
Just random rays. Not even triangles as that is in wireframe.
I have no idea what I am doing wrong. Even when I create the matrix in the shader the same thing happens. Here is the code that creates the matrix:
[java]
Matrix4f rotMat = new Matrix4f();
int t = 0;
if(q.face.equals(QuadMesh.faces.TOP.toString()) || q.face.equals(QuadMesh.faces.BOTTOM.toString())){
t = 1;
rotMat.m00 = 1;
rotMat.m01 = 0;
rotMat.m02 = 0;
rotMat.m03 = 0;
rotMat.m10 = 0;
rotMat.m11 = 0;
rotMat.m12 = 0;
rotMat.m13 = 0;
rotMat.m20 = 1;
rotMat.m21 = 0;
rotMat.m22 = 0;
rotMat.m23 = 0;
rotMat.m30 = 0;
rotMat.m31 = 0;
rotMat.m32 = 0;
rotMat.m33 = 1;
}
if(q.face.equals(QuadMesh.faces.FRONT.toString()) || q.face.equals(QuadMesh.faces.BACK.toString())){
t = 2;
rotMat.m00 = 1;
rotMat.m01 = 0;
rotMat.m02 = 0;
rotMat.m03 = 0;
rotMat.m10 = 1;
rotMat.m11 = 0;
rotMat.m12 = 0;
rotMat.m13 = 0;
rotMat.m20 = 0;
rotMat.m21 = 0;
rotMat.m22 = 0;
rotMat.m23 = 0;
rotMat.m30 = 0;
rotMat.m31 = 0;
rotMat.m32 = 0;
rotMat.m33 = 1;
}
if(q.face.equals(QuadMesh.faces.RIGHT.toString()) || q.face.equals(QuadMesh.faces.LEFT.toString())){
t = 3;
rotMat.m00 = 0f;
rotMat.m01 = 0f;
rotMat.m02 = 0f;
rotMat.m03 = 0;
rotMat.m10 = 1f;
rotMat.m11 = 0f;
rotMat.m12 = 0f;
rotMat.m13 = 0;
rotMat.m20 = 1f;
rotMat.m21 = 0f;
rotMat.m22 = 0f;
rotMat.m23 = 0;
rotMat.m30 = 0f;
rotMat.m31 = 0f;
rotMat.m32 = 0f;
rotMat.m33 = 1f;
}
[/java]
The matrix is declared like so in the material file:
[java]
Matrix4 cubeMatrix
[/java]
I then utilize it in the shader:
[java]
vec4 rotatedPos = m_cubeMatrix * inPosition;
vec3 truePosition = (rotatedPos.xyz + m_faceOffset + m_meshOffset ) * m_scale;
[/java]
m_faceOffset just offsets the vertex so it is centered around the origin, m_meshOffset offsets the quad in question from the origin…scale scales the quad to it’s size.
I am at a loss for what is happening here.
Any and all help is extremely appreciated. Thanks.