1
$\begingroup$

I've been working with bge and specifically the KX_Camera class to check if points are within the viewing frustum, but even when points are clearly in the camera frustum, it returns false. I'm aware of the issue where the projection matrix of the KX_Camera object are not updated on the first logic tick, so I had the associated Script Controller start with a delay of a few ticks. Even then, the points don't get detected correctly. Upon further inspection, the projection matrix doesn't seem to change. I've been beating my head against the wall trying to figure out why, but to no avail.

Here are some more details about what I'm doing to give some more insight:

  • I'm not actually rendering anything with this code, I'm using bge and bpy to do some processing regarding points visible from certain poses in a model
  • As the API states, I'm assuming the provided points are to be in the global coordinate system
  • The delay in the Script Controller corresponds to logic ticks, as I've read from multiple places
  • The camera frustum on the display is the same geometry/orientation/position as the the one on the 3D viewer
  • The point (0,0,0) returns true, even though it is not in the camera frustum. The camera, as it is positioned now, is near the origin, but the frustum does not contain it.

I'd appreciate any help you can give.

$\endgroup$
1
$\begingroup$

I may have fixed the problem. It seems that no matter how long you delay, it doesn't initialize until the first bit of code has been executed. I made a script controller that runs some dummy code to initialize on the first logic tick, and then delayed my main script by a few ticks and things work now.

$\endgroup$
  • $\begingroup$ Glad you solved it. I wonder if you can achieve the same thing by calling pointInsdieFrustum as a scene.post_draw function. This way, the camera should be guaranteed to be setup. $\endgroup$ – Mike Pan Mar 20 '14 at 18:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.