Reputation: 1640
I want to mimic the behaviour of passing a NSBezierPath
to SCNShape
. But instead of using a 2D NSBezierPath, I want to use an array of SCNVector3
, i.e., points in 3D instead of 2D.
In the end, I want to have something like the filled parabola from this answer but with 3D instead of 2D coordinates describing the path.
What would be the best way to accomplish this? Is it possible using only SceneKit without touching "real" OpenGL code.
Upvotes: 1
Views: 1328
Reputation: 6278
No! Is the simple answer to this.
The SCNShape is very strictly 2D. It only becomes 3D when bevelled/extruded, which is not a flexible, 3D deformation or modelling, just a straight extrude with rounded bevels.
3D splines as we know them in 3D modelling apps don't exist in SceneKit, and any attempt to create them is going to be a nightmare before you begin extruding them to get your filled shapes.
3D modelling apps probably don't give you dynamic abilities, but do make it 1000's of times easier to make 3D splines and then model from them.
There are ways to programmatically create your shapes in 3D apps like 3ds Max and Maya if you have data you're looking to represent, then automate export, etc. If that helps.
Upvotes: 3
Reputation: 7646
One way is to drop down into SCNGeometry, and supply your own vertices, triangles/lines/strips, and normals. David Ronnqvist's article and sample project are worth a look:
If what you're building is simple enough, you might be able to construct it with a combination of canned primitives (SCNBox, SCNPyramid, etc).
See also Drawing a 3D arc and helix in SceneKit.
You might also consider using a tool like Blender or MeshLab to preconstruct your objects.
Upvotes: 3