Reputation: 2749
I am currently trying to render a circle with SCNShapeNode in SceneKit. But unfortunately it does not render a perfect circle but an octagon.
Is there any way to set the render detail for SCNShape?
UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter: CGPointMake(0, 0) radius: 2 startAngle: 0.0 endAngle: M_PI * 2.0f clockwise: NO];
SCNShape *shape = [SCNShape shapeWithPath:path extrusionDepth: 1.0];
shape.firstMaterial.diffuse.contents = [UIColor colorWithRed: 1.0 green:0.0 blue:0.0 alpha:1.0];
SCNNode *shapeNode = [SCNNode nodeWithGeometry: shape];
[scene.rootNode addChildNode: shapeNode];
Upvotes: 3
Views: 1260
Reputation: 126107
From the docs:
The path’s flatness (see setFlatness: in NSBezierPath Class Reference) determines the level of detail SceneKit uses in building a three-dimensional shape from the path—a larger flatness value results in fewer polygons to render, increasing performance.
Conversely, a lower flatness value results in a smoother shape.
Bezier path flatness is an odd fit for this API because it measures in terms of pixels/points, and by default a "point" for an SCNShape
is one unit of scene (or local node) space. So if your shape is 10 scene units wide, it's like trying to render a path in 10 pixels in 2D... You need a really low flatness value for it to be smooth.
To answer the question in your non-answer: the subdivisionLevel
stuff and edge creases business aren't really for use with SCNShape
— they're for custom geometry that's designed for use with subdivision surface rendering.
Upvotes: 6