OpenInventor开发笔记:解决FaceSet的填充问题
生活随笔
收集整理的這篇文章主要介紹了
OpenInventor开发笔记:解决FaceSet的填充问题
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
在OpenInventor里畫一個多邊形時,遇到了奇怪的填充問題,多邊形的第一個頂點竟然與其中的某一個頂點相連,在wireframe模式下顯示一切正常,在填充模式中就顯示不正常。
初始代碼是這樣的:
float[,] vertices2 = new float[8, 3] {{ -5.0f, 0.0f, 0.0f}, { 5.0f, 0.0f, 0.0f}, { 4.0f, 2.0f, 0.0f}, { 3.0f, 2.0f, 0.0f},{ 2.0f, 4.0f, 0.0f}, { -2.0f, 4.0f, 0.0f}, { -3.0f, 2.0f, 0.0f}, { -4.0f, 2.0f, 0.0f}};SoSeparator MakeFaceSet(){SoSeparator face = new SoSeparator();SoVertexProperty myVertexProperty = new SoVertexProperty();myVertexProperty.orderedRGBA.SetValue(new SbColor(0.4f, 0.4f, 0.4f).GetPackedValue());// Define coordinates for verticesmyVertexProperty.vertex.SetValues(0, 8, vertices2);SoFaceSet myFaceSet = new SoFaceSet();myFaceSet.numVertices.SetValue(8);myFaceSet.vertexProperty.SetValue(myVertexProperty);face.AddChild(myFaceSet);return face;} ?經過一陣子檢查,發現是應該用ShpaeHints類,默認的FaceSet是把多邊形當作凸多邊形來處理的,在渲染時可能是提高效率,所以上面這個圖形繪制就出現問題了,在myFaceSet結點前加上SoShapeHints結點,問題解決。
? SoShapeHints hints = new SoShapeHints(); hints.faceType.Value = SoShapeHints.FaceTypes.UNKNOWN_FACE_TYPE;face.AddChild(hints);正確的顯示效果見下圖:
總結
以上是生活随笔為你收集整理的OpenInventor开发笔记:解决FaceSet的填充问题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: VS2010强大的一塌糊涂
- 下一篇: iphone NSArray 数组越界