OSG閃存

《osg程序設計教程》
第四章
1.模型node與幾何圖元geode
2.geometry組成
2.1頂點Vertex,Vec3Array,setVertexArray(v.get);
2.2顏色color,Vec4Array,setColorArray(c.get);
2.3關聯方式,geom.addPrimitiveSet(
new osg::DrawArrays(osg::PrimitiveSet::QUADS,0,4));
2.4法線normal,Vec3Array,setNormalArray(n.get);
setNormalBinding(::BIND_OVERALL);
n.push_back(osg::Vec3(0.f,-1.f,0.f);
3.geode.addDrawable(geom.get);
--------------------
1.狀態屬性類LineWidth
lineWidth.setWidth(10.0);
geom.getOrCreateStateSet().
setAttributeAndModes(lineWidth.get,
osg::StateAttribute::ON);
2.內置幾何類型osg::Shape
3.附錄..asGeometry();
第五章
1.viewer.getSceneData();得到數據。
2.鍵盤響應得到viewer
addEventHandler(osgGA::GUIEventHandler);
可以控制事件的攔截,由幾個函數處理。
要不要繼續向下傳遞。
3.重寫handle();把參數轉換爲viewer
判斷事件類型GUIEventAdapter::KEYDOWN:
viewer.getSceneData.asGroup.getChild.setNodeMask;
4.拾取pick
判斷射線與viewer中的物體相交
判斷相交結點爲我們需要的。
5.x,y座標通過handle參數得到
射線
osgUtil::LineSegmentIntersector::Intersections
viewer.computeIntersections(x,y,intersection)
遍歷Intersections
可能通過setName();getName();篩選結點
第六章
1.osg自帶Trackball
2.osgGA::MatrixManipulator專門響應控制viewer
3.碰撞檢查
LineSegment,osgUtil::IntersectVisitor
iv.addLineSegment(line.get);
node.accept(iv);
iv::HitList hlist;
4.製作路徑漫遊
時間,位置,旋轉角度。
5.mfc中osg
去掉OnNewDocument();
重載OnOpenDocument();
CCoreOSG(HWND hWnd);
initOSG();
initManipulators(void);
initSceneGraph(void);
initCameraConfig(void);
setupWindow(void);
preFrameUpdate();
postFrameUpdate();
6.CView::OnEraseBkgnd(pDC);
第七章
1.回調:某件事情發生時執行一個函數。
2.按S顯示幀速。
3.fountain.osg再看。
4.自定義回調
繼承NodeCallback
重寫operator();
更新矩陣setMatrix(Matrix::translate);
traverse(node,nv);貫穿
5.定義矩陣節點MatrixTransform
.setUpdateCallback(new MyCallBack);
6.節點訪問器,參看osgCallBack案例
構造函數(::TRAVERSE_ALL_CHILDREN);
apply(osg::Geode)
geode.getNumDrawables();
geom=dyn_cast(geode.getDrawable(i));
geom.getVertexArray();
vArr.insert(end,begin,end);
遍歷得到的結果可以放在類成員變量裏。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章