Scenekit: Dynamic Modification of Geometries

69 Views Asked by At

For my 3D game about a spaceship flying in a cave, I need to modify the geometries that the cave is built from. As stated in earlier posts, the cave is constructed from circular shapes by putting one shape behind another to create a tube-like surrounding, in which the ship is maneuvering. The shapes are tilted in small angles so the tube is curved. However, the tilting of the shapes creates overlapping parts that disturb the tube's appearance. Thus, the geometries of the shapes need to be adjusted - shorter in the inside of the curves and longer on the outside.

At first I thought that a 'vertex shader' could be the solution, but I learnt from a previous post that this describes something else: an algorithm modifying the visual appearance of the shape, but not creating a modified geometry that could be used i.e. as a physicsBody (which is required for correct collision detection). So now I am seeking help in the dynamic modification of SCNgeometries. At this point in time, I have never programmed anything alike, but if I understand correctly, I need to read and modify the vertices of the geometry.

2 rings each containing 12 rectangles - to be modified

There is one more thing to mention: the rings themselves are not a one-piece, but made from a number of plane segments, so the routine would need to (internally) create the higher-order structure (the ring) first, before it is applied on the same. On the attached picture, you can see the 2 rings (from outside). Can anyone share an (as simple as possible) description or a link, where I could find the information I am looking for?

(I positioned the rings for better clarity - they are not in the correct position for simple merging)

0

There are 0 best solutions below