根據視口獲取平截頭體6面方程
//獲取視口寬高
double dwidth = pcamera->getviewport()->width();
double dheight =pcamera->getviewport()->height();
//平截頭體近裁剪面左上角座標
osg::vec3d windowposleftup1(0.0,dheight, -1.0 );
osg::vec3d wordpleftupnear = osgmathutility::windowpos2worldpos(pcamera, windowposleftup1);
//平截頭體遠裁剪面左上角座標
osg::vec3d windowposleftup2(0.0, dheight, 1.0);
osg::vec3d wordpleftupfar = osgmathutility::windowpos2worldpos(pcamera, windowposleftup2);
平截頭體近裁剪左下角
osg::vec3d windowposleftbottom1(0.0, 0.0, -1.0);
osg::vec3d wordpleftbottomnear = osgmathutility::windowpos2worldpos(pcamera, windowposleftbottom1);
平截頭體遠裁剪左下角
osg::vec3d windowposleftbottom2(0.0,0.0, 1.0);
osg::vec3d wordpleftbottomfar = osgmathutility::windowpos2worldpos(pcamera, windowposleftbottom2);
平截頭體近裁剪右上角
osg::vec3d windowposrightup1(dwidth, dheight, -1.0);
osg::vec3d wordprightupnear = osgmathutility::windowpos2worldpos(pcamera, windowposrightup1);
osg::vec3d windowposrightup2(dwidth, dheight, 1.0);
osg::vec3d wordprightupfar = osgmathutility::windowpos2worldpos(pcamera, windowposrightup2);
平截頭體近裁剪右下角
osg::vec3d windowposrightbottom1(dwidth, 0.0, -1.0);
osg::vec3d wordprightbottomnear = osgmathutility::windowpos2worldpos(pcamera, windowposrightbottom1);
osg::vec3d windowposrightbottom2(dwidth, 0.0, 1.0);
osg::vec3d wordprightbottomfar = osgmathutility::windowpos2worldpos(pcamera, windowposrightbottom2);
///再根據座標轉成向量座標(注:根據右手向量相乘判斷向量方向)
//計算平截頭體遠平面
osgplane* pplanefar1 = new osgplane();
if (pplanefar1)
pplanefar1->redefine(wordprightupfar,wordpleftupfar, wordprightbottomfar );
//計算平截頭體近平面
osgplane* pplanenear1 = new osgplane();
if (pplanenear1)
pplanenear1->redefine(wordprightupnear, wordprightbottomnear, wordpleftupnear);
//計算平截頭體左平面
osgplane* pplaneleft1 = new osgplane();
if (pplaneleft1)
pplaneleft1->redefine(wordpleftupnear, wordpleftbottomnear, wordpleftupfar );
//計算平截頭右平面
osgplane* pplaneright1 = new osgplane();
if (pplaneright1)
pplaneright1->redefine(wordprightupnear, wordprightupfar, wordprightbottomnear);
//計算平截頭上平面
osgplane* pplaneup1 = new osgplane();
if (pplaneup1)
pplaneup1->redefine(wordprightupnear, wordpleftupfar, wordprightupfar);
//計算平截頭下平面
osgplane* pplanebotom1 = new osgplane();
if (pplanebotom1)
pplanebotom1->redefine(wordprightbottomnear, wordprightbottomfar, wordpleftbottomnear);
1、 裁剪矩陣 = 檢視矩陣 × 投影矩陣
2、3d世界上的點p =(x,y,z,1)。還考慮乙個模型檢視矩陣中號和投影矩陣p。使用以下公式,通過矩陣檢視矩陣v和投影矩陣p將點p轉換為剪輯空間中的點pc =(xc,yc,zc,wc):
pc = pvp
點pc是 齊次座標,當歸一化時變為pcn:
pcn = (xc/wc,yc/wc zc/wc) = (x』, y』, z』)
3、在標準化的剪輯空間中,視錐體是以原點為中心的軸對齊框,並由以下平面限定:
左平面:x'= -1
右平面:x'= 1
頂部平面:y'= 1
底部平面:y'= -1
近平面:z'= -1
遠平面:z'= 1
這意味著點pcn =(x』,y』,z』)在視錐體內,如果:
-1< x'<1
-1在非標準化座標中,點pc必須滿足以下條件才能在視錐體內:
-wc基於該資訊,可以在世界座標中提取限制視錐體的六個平面。如果點pc位於左平面的「右」側: -wcgetviewmatrix()*pcamera->getprojectionmatrix();
double xx(0.0),yy(0.0),zz(0.0),dd(0.0);
//計算平截頭左平面
osgplane* pplaneleft = m_mapfrustumplane[frustumplane::plane_left];
if (pplaneleft)
//計算平截頭右平面
osgplane* pplaneright = m_mapfrustumplane[frustumplane::plane_right];
if (pplaneright)
//計算平截頭上平面
osgplane* pplaneup = m_mapfrustumplane[frustumplane::plane_up];
if (pplaneup)
//計算平截頭下平面
osgplane* pplanebotom = m_mapfrustumplane[frustumplane::plane_bottom];
if (pplanebotom)
//計算平截頭體近平面
osgplane* pplanenear = m_mapfrustumplane[frustumplane::plane_near];
if (pplanenear)
//計算平截頭體遠平面
osgplane* pplanefar = m_mapfrustumplane[frustumplane::plane_far];
if (pplanefar)
兩種方法獲取檔案OEP
讀取的字段都是一樣的,只是乙個直接從pe檔案中讀取,乙個對映到記憶體後再讀取 1.檔案直接訪問法 bool readoepbyfile lpctstr szfilename dword dwoep,cbread image dos header dos header sizeof image dos...
兩種方法獲取檔案OEP
讀取的字段都是一樣的,只是乙個直接從pe檔案中讀取,乙個對映到記憶體後再讀取 1.檔案直接訪問法 cpp view plain copy boolreadoepbyfile lpctstrszfilename dworddwoep,cbread image dos header dos header...
Spring獲取bean工廠的兩種方法
具體案例 當我們去例項化beans.xml,該檔案中配置的bean被例項 該bean scope是 singleton 從bean中取出student 如果我們使用beanfactory去獲取bean,當你只是例項化該容器,那麼 容器的bean不被例項化,只有當你去使用getbean某個bean時,...