コード例 #1
0
ファイル: CameraMath.cpp プロジェクト: kapecp/3dsoftviz
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
ファイル: CameraMath.cpp プロジェクト: kapecp/3dsoftviz
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
ファイル: imageNode.cpp プロジェクト: SorinS/structured
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)));
}
コード例 #4
0
ファイル: imageNode.cpp プロジェクト: SorinS/structured
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() );
}