//イベントのクリックイベント仮想関数呼び出しをクリックします
PointSelect無効(* osgViewer ::ビューアビューア、CONST&GUIEventAdapterのosgGA :: EA)
{
osgGroupPtrのdynamic_cast = <::グループOSG *>(viewer-> getSceneData())の根;
IF(root.get()== NULL)
のリターン;
//オブジェクト選択
osgNodePtrノード;
osgGroupPtr親;
//線分交差検出機能を作成
osgUtil :: :: LineSegmentIntersector交差点の交差点;
IF(viewer-> computeIntersections(EA、交差点))
{
osgUtil CONST :: ::交差点&LineSegmentIntersector = HIT
* intersections.begin();
constの&NodePath NodePath OSG :: = hit.nodePath。
//選択したオブジェクトを取得
ノード=(nodePath.sizeを()> = 1。)NodePath [nodePath.size() - 1]:0;?
はdynamic_cast <OSG ::グループの親=(nodePath.size()> = 2)? *>(nodePath [nodePath.size() - 2):0。
もし(picktype == PickGeometry)
{
//选择Drawableの
場合(node.get()&& hit.drawable.get())
{
親= dynamic_castを<OSG ::グループ*>(node.get());
ノード= hit.drawable。
}
}
}
}
//测标点框选EX、EY为屏幕坐标
ブールRectSearch(フロートEX、フロートEY、osgViewer ::ビューアー* pViewer)
{
ダブルMX =元;
私= EYを倍増。
ダブルW = MAX(dExpendX、1.0F)。
ダブルH = MAX(dExpendY、1.0F)。
osgUtil :: PolytopeIntersector *ピッカー=
新しいosgUtil :: PolytopeIntersector(osgUtil ::セクタ間:: WINDOW、MX-W、MY-H、MX +私+ H、W);
osgUtil :: IntersectionVisitorのIV(ピッカー)。
pViewer-> getCamera() - >(IV)を受け入れます。
IF(picker-> containsIntersections())
{
osgUtil :: PolytopeIntersector ::交差点セクション= picker-> getIntersections();
std ::セット<osgUtil :: PolytopeIntersector ::交差点> ::イテレータは()をsections.begin =。
以下のための(それ;!それ= sections.end();それ++)
{
osgUtil :: PolytopeIntersector ::交差点&ヒット= *それ。
//得到选中对象
ノード=(nodePath.size()> = 1)?nodePath [nodePath.size() - 1]:0。
親=(nodePath.size()> = 2)?dynamic_castを<OSG ::グループ*>(nodePath [nodePath.size() - 2]):0;
//如果需要选择描画領域
{
IF(node.get()&& hit.drawable。
親= dynamic_castを<OSG ::グループ*>(node.get());
ノード= hit.drawable。
}
}
}
}
もし(vFeature.empty())
戻り偽。
trueを返します。
}