Making a Capsule Mesh via Script in Five 3D Environments

Unity, Processing, Godot, Blender, Three.js

Image for post
Image for post
A particle system emits capsules in Blender.

Conceptual Planning

Image for post
Image for post
A Mollweide projection map of the Earth. Source: https://commons.wikimedia.org/wiki/File:Mollweide_projection_SW.jpg

Regions & Faces

Vertices

Image for post
Image for post
Cylindrical to Cartesian conversion.
Image for post
Image for post
Two variants on spherical to Cartesian conversion.
Image for post
Image for post
Phase shifting.
Image for post
Image for post
Calculate a triangle’s vertex normals from its coordinates.
Image for post
Image for post
Clockwise vertex winding (left) vs. Counter-clockwise vertex winding (right).
Image for post
Image for post
Coordinate systems for Blender (left) and Unity (right).
The first 16 nonuniform entries of a capsule’s coordinates, texture coordinates and vertex indices.
The first 16 uniform entries of a capsule’s coordinates, texture coordinates and vertex indices.

UV Profile

Image for post
Image for post
Three UV profiles for an 8 x 6 x 3 capsule: aspect (left), fixed (middle), uniform (right).

Other Possibilities

Image for post
Image for post
A capsule based on a cube-sphere, left, and on an icosphere, right.
Image for post
Image for post
Triangular, left, vs. quadrilateral polar caps, middle. The septagonal capsule, right, shows why an even number of longitudes is needed.
Image for post
Image for post

Implementation

Unity

Image for post
Image for post
A custom capsule (left) and Unity capsule (right). A 32 x 16 x 0 capsule has 592 vertices and 1024 triangles.
Image for post
Image for post
Flat shading is assigned to a mesh via a context menu.

Processing

Image for post
Image for post
Sketch screen capture for textured and stroked solid capsule.

Godot

Image for post
Image for post
Exposed variables in the Godot editor.

Blender

Image for post
Image for post
Image for post
Image for post
Interface for creating a capsule.

Three.js

Conclusion

Creative coder from Wisconsin, USA.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store