Skip to content
Randall C. O'Reilly edited this page Jan 25, 2024 · 1 revision

3D (gi3d) Tips and Tricks.

Color and transparency

Unlike in the 2D framework, transparent colors should not be alpha-premultiplied for 3D use -- this is because the rendering actually converts to alpha-premultiplied values automatically and so if you start with premultiplied values they get double-premultiplied. In effect, think of the A alpha value as a separate opacity value, and the RGB as the "pure" color components. See the Color page for more details.

Shapes

Cylinder, Cone, Pyramid

The Cylinder mesh is particularly flexible in rendering different types of shapes:

  • A cone can be achieved by setting the TopRad to 0 -- a point at the top of a cylinder.

  • A pyramid can be achieved from a cone by setting the RadialSegs to the number of sides for the pyramid -- e.g., 4 = a standard quadrilateral pyramid, 3 = a minimal triangular pyramid, etc.

Lines vs. Line

The Lines Mesh type renders an arbitrary "polyline" of connected line segments, using mitered joint angles. Critically, it is designed to render primarily in the XY "frontal" plane -- to handle other cases, use rotation to reorient.

The AddNewLine method is particularly handy for rendering a single line segment and rotating / positioning it to go exactly between two arbitrary 3D start / end points. Multiple of these could be used if fully arbitrary 3D polylines are needed -- if they are relatively thin, then the mitering issues are not critical. This returns a Solid and uses a shared unit-length line mesh.

The AddNewArrow builds on AddNewLine to add arrow heads on either or both sides of the line.

Clone this wiki locally