SceneKit SCNGeometryElement TriangleStrip vs triangles

放肆的年华 提交于 2020-01-05 06:27:36

问题


I have draw a scene which contains a SCNGeometryElement object. (it is a terrain. I have 2 triangles per grid item) In order to optimize, i decided to remplace my triangle primitive by TriangleStrip. But it does not give me the same result

My Vertex array is a succession of 4 points:

C  D
A  B

My indices array contains index of A, C, B and D So when i work with TriangleStrip, scene kit is supposed to draw ACB and CBD triangles. That is what is said in apple documentation.

I am wondering what i should put in primitivecount. I tried several things. It changes the rendering but i can not retrieve the same result i had before with simple triangles...

Any idea ?

Thanks

let element = SCNGeometryElement(data: buffer_indices , primitiveType: .TriangleStrip, primitiveCount: Int(points_count), bytesPerIndex: sizeof(CInt))

回答1:


For a triangle strip the primitiveCount should be equal to indexCount - 2.

Alternatively you can use the Swift-friendly SCNGeometryElement(indices:primitiveType:) (see also this post).



来源:https://stackoverflow.com/questions/41037428/scenekit-scngeometryelement-trianglestrip-vs-triangles

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!