extent
: the three dimensional width, height and depth.
segments
: is a uint2 where x is the number of segments around the cylinder, and y is the number of segments vertically.
inwardNormals
: do the normals face inwards (true or false).
topCap
: Add a cap (extra triangles) to the top of the cylinder.
bottomCap
: Add a cap to the bottom of the cylinder.
Rendered cylinders from left to right, with the color showing the normals:
-
extent: [1, 5, 1]
segments: [10, 10]
inwardNormals: false
topCap: true
bottomCap: false
-
extent: [1, 1, 1]
segments: [3, 2]
inwardNormals: false
topCap: false
bottomCap: false
-
extent: [1, 5, 1]
segments: [5, 5]
inwardNormals: false
topCap: true
bottomCap: false
-
extent: [1, 5, 1]
segments: [5, 5]
inwardNormals: true
topCap: true
bottomCap: false
I’ve rendered these with backface culling, so that you can see that cylinder 2 doesn’t have a top cap. (The wireframe render has no culling.)
Cylinder 4 has inward facing normals. I rescaled the normals from (-1 to 1) to (0 to 1) so that you can visualise the normal as a color. (-1 would just show black). You can see that on the first three, the normals are facing outwards, and +x is more red, +y is green. On cylinder 4, the normals are facing inwards, and so are reversed. Red is showing on -x. The top cap’s normal is black (0, 0, 0) rather than (0, 1, 0).
Notice the origin. It appears that the origin (0, 0, 0) of the cylinder is in the middle. Cylinder 2 is located halfway up the others, and I only changed the x positions.
If you want to use radius, there is another way of creating a cylinder:
https://developer.apple.com/documentation/modelio/mdlmesh/1391807-newcylinder