示例#1
0
osg::Vec3d CameraMath::projectOnScreen( osg::ref_ptr<osg::Camera> camera, osg::Vec3d point )
{
	osg::Matrixd mv = camera->getViewMatrix();
	osg::Matrixd mp = camera->getProjectionMatrix();
	osg::Matrixd mw = camera->getViewport()->computeWindowMatrix();

	osg::Vec3d result = point * mv;
	result = result * mp;
	result = result * mw;

	return result;
}
示例#2
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;
}
示例#3
0
 const osg::Matrix &getProjectionMatrix() const { return mMainPass->getProjectionMatrix(); }
示例#4
0
osg::Matrix getFromScreenMatrix(  osg::ref_ptr< osg::Camera > camera,osg::Vec2 size  )
{
    return osg::Matrix::inverse( camera->getViewMatrix() * camera->getProjectionMatrix() *( osg::Matrix::translate(1.0,1.0,1.0)*osg::Matrix::scale(0.5*size.x(),0.5*size.y(),0.5f)));
}
示例#5
0
osg::Matrix getToScreenMatrix(  osg::ref_ptr< osg::Camera > camera,osg::Vec2 size )
{
    return osg::Matrix( camera->getViewMatrix() * camera->getProjectionMatrix() *( osg::Matrix::translate(1.0,1.0,1.0)*osg::Matrix::scale(0.5*size.x(),0.5*size.y(),0.5f)));//camera->getViewport()->computeWindowMatrix() );
}