Now it is blatantly obvious that I messed up somewhere and pretty badly because I managed to turn perfect piece of code into huge pile of crap.
When I’m at the position 0,0,1 facing towards up vector 0,1,0 it works ok, except that it can’t render some of the balls that go beside it.
Now the biggest problem is that it doesn’t work as it is supposed to and I can’t figure out what the hell is wrong with the planes.
I’ve re-written them about 1000 000^7 times, but they still keep messing up. This is grabbed directly from gametutorials com. At first I thought they worked, but I had the camera positioned wrong and no mouse move. But when the mousemove is included it craps up. Hence there must be something wrong with the panes.
Now I beg you, please can you check the pane code that it is at least seemingly right?
I’m thinking about turning the frustum into one single array instead of logical array, but that is not supposed to be the matter since it works like that in gametuts examples, unless there is some major difference between c++ and java arrays that I’m unaware of.
Matrix4f.mul(modl, proj, clip);
// This will extract the RIGHT side of the frustum
m_Frustum[RIGHT][A] = clip.m30 - clip.m00;
m_Frustum[RIGHT][B] = clip.m31 - clip.m01;
m_Frustum[RIGHT][C] = clip.m32 - clip.m02;
m_Frustum[RIGHT][D] = clip.m33 - clip.m03;
// Now that we have a normal (A,B,C) and a distance (D) to the plane,
// we want to normalize that normal and distance.
// Normalize the RIGHT side
normalizePlane(m_Frustum, RIGHT);
// This will extract the LEFT side of the frustum
m_Frustum[LEFT][A] = clip.m30 + clip.m00;
m_Frustum[LEFT][B] = clip.m31 + clip.m01;
m_Frustum[LEFT][C] = clip.m32 + clip.m02;
m_Frustum[LEFT][D] = clip.m33 + clip.m03;
// Normalize the LEFT side
normalizePlane(m_Frustum, LEFT);
// This will extract the BOTTOM side of the frustum
m_Frustum[BOTTOM][A] = clip.m30 + clip.m10;
m_Frustum[BOTTOM][B] = clip.m31 + clip.m11;
m_Frustum[BOTTOM][C] = clip.m32 + clip.m12;
m_Frustum[BOTTOM][D] = clip.m33 + clip.m13;
// Normalize the BOTTOM side
normalizePlane(m_Frustum, BOTTOM);
// This will extract the TOP side of the frustum
m_Frustum[TOP][A] = clip.m30 - clip.m10;
m_Frustum[TOP][B] = clip.m31 - clip.m11;
m_Frustum[TOP][C] = clip.m32 - clip.m12;
m_Frustum[TOP][D] = clip.m33 - clip.m13;
// Normalize the TOP side
normalizePlane(m_Frustum, TOP);
// This will extract the BACK side of the frustum
m_Frustum[BACK][A] = clip.m30 - clip.m20;
m_Frustum[BACK][B] = clip.m31 - clip.m21;
m_Frustum[BACK][C] = clip.m32 - clip.m22;
m_Frustum[BACK][D] = clip.m33 - clip.m23;
// Normalize the BACK side
normalizePlane(m_Frustum, BACK);
// This will extract the FRONT side of the frustum
m_Frustum[FRONT][A] = clip.m30 + clip.m20;
m_Frustum[FRONT][B] = clip.m31 + clip.m21;
m_Frustum[FRONT][C] = clip.m32 + clip.m22;
m_Frustum[FRONT][D] = clip.m33 + clip.m23;
// Normalize the FRONT side
normalizePlane(m_Frustum, FRONT);