So how I'm doing this is a little sketchy but I plan on changing it to either AABBs or spheres once I get it working. So the problem I'm having right now is that the frustum culling I've implemented is only working at certain angles and is not even close to accurate, personally I believe that the problem is at a calculation level. I am fairly new to 3D game development so I just whipped up this class fairly quickly based on some thread I read. My ViewFrustum class can be found here: https://www.dropbox.com/s/3b97bgcwoyh2oq8/ViewFrustum.java?dl=0
So all I'm doing outside this class is calling the update method from my renderer class and I have an ungodly amount of if statements checking if an entity's xyz is within the min and max xyz of the frustum (This is temporary).
So my main question is, am I calculating the frustum right or did I make any mistakes?
Values (when game starts, rotation matrix is a identity matrix) :
- centerNear: [134.49167, 7.3502045, -271.4365]
- centerFar : [134.49167, 7.3502045, -1170.7365]
- points[0-7] :
- [0] 2607.2214 1714.3507 -621.8992 1.0
- [1] -2338.238 1714.3507 -621.8992 1.0
- [2] 2607.2214 -899.70605 -1573.3379 1.0
- [3] -2338.238 -899.70605 -1573.3379 1.0
- [4] 136.4149 100.760254 -252.18294 1.0
- [5] 132.56844 100.760254 -252.18294 1.0
- [6] 136.4149 98.727104 -252.92294 1.0
- [7] 132.56844 98.727104 -252.92294 1.0
ViewFrustum
class, out of context, and simply "plug it in" to a compatible engine we happen to have handy. Would you please distill your dropbox entry into: "Here's example input: X. Here's the output: Y." We can easily "plug" the camera parameters into a couple of matrices and use a known-good frustum creation method to verify whether the frustums you create are correct or not. Then again, so could you. \$\endgroup\$calculateFrustumVertices
, using Identity rotation, please add to your question, the values of:centerNear
,centerFar
, andpoints[0-7]
\$\endgroup\$