如何设置SCNShape的细节层次/平滑度/细分率?
How to set the level of detail / smoothness / subdivision rate for SCNShape?
我目前正在尝试在 SceneKit 中使用 SCNShapeNode 渲染一个圆。但不幸的是,它呈现的不是正圆而是八边形。
有什么方法可以设置 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];
来自文档:
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.
相反,平坦度值越低,形状越平滑。
Bezier 路径平坦度非常适合此 API,因为它根据 pixels/points 进行测量,默认情况下 "point" 对于 SCNShape
是一个单位场景(或本地节点)space。所以如果你的形状是 10 个场景单位宽,这就像试图在 2D 中渲染 10 个像素的路径......你需要一个 really 低平坦度值才能平滑。
回答你的非答案中的问题:subdivisionLevel
东西和边缘折痕业务并不是真正用于 SCNShape
— 它们用于设计用于subdivision surface渲染。
我目前正在尝试在 SceneKit 中使用 SCNShapeNode 渲染一个圆。但不幸的是,它呈现的不是正圆而是八边形。
有什么方法可以设置 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];
来自文档:
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.
相反,平坦度值越低,形状越平滑。
Bezier 路径平坦度非常适合此 API,因为它根据 pixels/points 进行测量,默认情况下 "point" 对于 SCNShape
是一个单位场景(或本地节点)space。所以如果你的形状是 10 个场景单位宽,这就像试图在 2D 中渲染 10 个像素的路径......你需要一个 really 低平坦度值才能平滑。
回答你的非答案中的问题:subdivisionLevel
东西和边缘折痕业务并不是真正用于 SCNShape
— 它们用于设计用于subdivision surface渲染。