Пример #1
0
bool CameraMath::isInFOV( osg::Vec3d point, osg::ref_ptr<osg::Camera> camera )
{
	double left, right, bottom, top, zNear, zFar;
	camera->getProjectionMatrixAsFrustum( left, right, bottom, top, zNear, zFar );

	osg::Matrixd& mv = camera->getViewMatrix();
	osg::Matrixd& mp = camera->getProjectionMatrix();
	osg::Vec3d pView = point * mv * mp;


	if ( pView.z() < 0.0 ) {
		return false;
	}

	return true;
}