问题
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