Here you can find light-weight code releases that contain C++ classes for computer graphics use. The code releases only include header files, so no pre-compilation is needed. They only use standard C++ libraries, so there are no external dependancies, unless otherwise noted.

Instead of providing a complete library that includes all of these classes, I keep code releases separate for each component, so that you can just download the parts that you need. I believe this approach makes it easier for you to use them. I try to keep code releases as simple and as small as possible, therefore some of the code releases may need some previous code releases to compile. Please check the requirements list of the code release that you are interested in. If you have any problems with the code, documentation or usability, please let me know.

Dependencies

Code releases are provided in C++ header form. They only use standard C++ libraries and they do NOT have any external dependencies, unless otherwise specified. Some code releases depend on other code releases, as indicated.

License

All source code in cyCodeBase is released under the simple and permissive MIT license, which allows code modifications and commercial use.

Naming Convention

All file names begin with "cy" prefix. All classes and structs are defined in namespace cy. Most classes and structs are also defined outside of the namespace cy with an additional "cy" prefix. All constants begin with "CY_", and all internal constants begin with "_CY_". All functions and class methods begin with an upper-case letter. All variable names begin with a lower-case letter. If the function or variable name is made up of more than one word, each secondary word begins with an upper case letter, and the rest of the function and variable names use lower-case letters.

GIT Repository

All source files are on a GIT repository for easy access and updates. They can be accessed on github.

cyCore

Core Functions and Macros

cyCore.h

This release includes a core header file that defines templated functions for common math operations and common macros used by some of the code releases.

files

cyCore.h

dependencies

none

cyPoint

2D, 3D, 4D, and N-Dimensional point (vector) classes

cyPoint.h

These classes are the basic classes of computer graphics for 2D, 3D, 4D, and ND vectors. They are implemented as template classes, so that you could use both single precision and double precision floating point numbers. They provide almost all operations that you would need.

files

cyPoint.h

templates

Point, Point2, Point3, Point4

typedefs


Using <float>: Point2f, Point3f, Point4f
Using <double>: Point2d, Point3d, Point4d

dependencies

cyCore

cyIPoint

2D, 3D, and N-Dimensional integer point classes

cyIPoint.h

These classes are the basic classes of computer graphics for 2D, 3D, and ND integer points. They are implemented as template classes, so that you could use any integer type with any length, as well as other classes and types you like (provided that they overload the necessary operators). Unlike the classes in the cyPoint release, these classes overload bitwise operations. These classes can be converted to and from the classes in the cyPoint release.

files

cyIPoint.h

templates

IPoint, IPoint2, IPoint3, IPoint4,

typedefs


Using <int8_t>: IPoint2b, IPoint3b, IPoint4b,
Using <uint8_t>: IPoint2ub, IPoint3ub, IPoint4ub,
Using <int16_t>: IPoint2s, IPoint3s, IPoint4s,
Using <uint16_t>: IPoint2us, IPoint3us, IPoint4us,
Using <int32_t>: IPoint2i, IPoint3i, IPoint4i,
Using <uint32_t>: IPoint2ui, IPoint3ui, IPoint4ui,
Using <int64_t>: IPoint2l, IPoint3l, IPoint4l,
Using <uint64_t>: IPoint2ul, IPoint3ul, IPoint4ul,

dependencies

cyCore

cyMatrix

2x2, 3x3, 3x4, and 4x4 matrix classes

cyMatrix.h

This code release has four template matrix classes for 2x2, 3x3, 3x4, and 4x4 matrices, which work with 2D, 3D and 4D points (vectors).

files

cyMatrix.h,

templates

Matrix2, Matrix3, Matrix34, Matrix4

typedefs


Using <float>: Matrix2f, Matrix3f, Matrix34f, Matrix4f
Using <double>: Matrix2d, Matrix3d, Matrix34d, Matrix4d

dependencies

cyCore, cyPoint

cyColor

Color classes with 3/4 8-bit/32-bit components

cyColor.h

This release includes four color classes. Two of them keep single precision float values per channel and store either 3 or 4 color components. The remaining two keep 8-bit color values and again they store either 3 or 4 color components. They include methods for converting between them and almost all the operations that you would need.

files

cyColor.h

classes

Color, ColorA, Color24, Color32

dependencies

none

cyTriMesh

Triangular mesh class

cyTriMesh.h

This release includes a triangular mesh class. This class can keep texture coordinates and surface normals, such that each vertex can have multiple normals associated with each one of the faces using the vertex. Since this is a triangular mesh class, all faces are triangles. It includes a function that can parse OBJ files, which automatically triangulates non-triangular faces.

files

cyTriMesh.h

classes

TriMesh

dependencies

cyCore, cyPoint

cyBVH

Bounding Volume Hierarchy

cyBVH.h

This release includes a general purpose Bounding Volume Hierarchy (BVH) class and a BVH class for triangular meshes. The BVH structure is extremely useful in quickly searching the space and it is one of the commonly used data structures for accelerating ray tracing.

files

cyBVH.h

classes

BVH, BVHTriMesh

dependencies

none, but can also be used with cyTriMesh

cyQuat

Quaternion class for 3D vectors

cyQuat.h

The quaternion class is designed for rotation operations of unit quaternions on 3D vectors. 3x3 and 4x4 matrix conversions are also supported.

files

cyQuat.h

classes

Quat

typedefs


Using <float>: Quatf,
Using <double>: Quatd,

dependencies

cyCore, cyPoint, cyMatrix

cyPointCloud

Points in k-d trees

cyPointCloud.h

2D, 3D, 4D, and N-D point clouds stored as k-d trees for quick nearest-neighbor searchers.

files

cyPointCloud.h

classes

PointCloud

typedefs


Generic PointCloud2, PointCloud3, PointCloud4, PointCloudN,
Using <float>: PointCloud2f, PointCloud3f, PointCloud4f, PointCloudNf,
Using <double>: PointCloud2d, PointCloud3d, PointCloud4d, PointCloudNd,

dependencies

none, but can also be used with cyPoint

cyHeap

Heap structure with random access

cyHeap.h

A general-purpose heap class that permits random access and updates. Heaps are efficient structures for retrieving the element with the maximum value from a collection of elements without sorting them. This implementation allows accessing any element using its ID or heap order.

files

cyHeap.h

classes

Heap

dependencies

none

cySampleElimination

Weighted Sample Elimination

cySampleElim.h

An implementation of the weighted sample elimination algorithm for generating Poisson Disk sample sets in any dimensions.

files

cySampleElim.h

classes

WeightedSampleElimination

dependencies

cyPointCloud, cyHeap

cyLightingGrid

Lighting Grid Hierarchy

cyLightingGrid.h

An implementation of the Lighting Grid Hierarchy method for efficiently handling many lights.

files

cyLightingGrid.h

classes

LightingGridHierarchy

dependencies

cyPoint, cyIPoint, cyColor, cyPointCloud

cySpatial

Spatial vector algebra classes

cySpatial.h

This code release has spatial vector algebra classes intended for the implementation of Featherstone's articulated rigid body dynamics method. Spatial vector algebra uses 6D vectors that keep 3D linear and 3D angular information together. This compact form simplifies certain mathematical operations for rigid-body dynamics. For more information about spatial vector algebra, please visit Roy Featherstone's Spatial Vector Algebra page.

files

cySpatial.h

templates

SpatialVector6, SpatialTrans6, SpatialMatrix6

typedefs


Using <float>: SpatialVector6f, SpatialTrans6f, SpatialMatrix6f
Using <double>: SpatialVector6d, SpatialTrans6d, SpatialMatrix6d

dependencies

cyCore, cyPoint, cyMatrix

cyTimer

Timer classes for Windows

cyTimer.h

This code release has timer classes that you can use to measure the performance of your code. See Easy Performance Analysis in the solutions section for an example use of this code release.

files

cyTimer.h

classes

Timer, TimerStats

dependencies

none

cyString

String class for char arrays

cyString.h

Who needs a general purpose string class? Well, back in the day I thought I needed one, so I wrote one. It's still here, but I haven't used it for a long time, and I'm not sure how much longer I will keep it here. This is a general purpose string class, which supports many useful string operations. It has methods for numeric conversions, character and string search, formating, editing, and file operations.

files

cyString.h

classes

String

dependencies

none

cyHairFile

Load and save HAIR model files

cyHairFile.h

A HAIR files is a binary file that keeps hair model data (see HAIR file description for more information). This code release includes a class to handle HAIR files for loading and saving hair model data. See Using HAIR Files in the solutions section for an example use of this code release.

files

cyHairFile.h

classes

HairFile

dependencies

none

cyGL

OpenGL helper classes

cyGL.h

The classes in this release are designed to provide convenient interfaces for some OpenGL features. They are not intended to provide the full flexibility of the underlying OpenGL functions, but they greatly simplify the implementation of some general OpenGL operations.

files

cyGL.h

classes

GL, GLDebugCallback, GLTexture, GLTexture1, GLTexture2, GLTexture3, GLTextureCubeMap, GLRenderBuffer, GLRenderTexture, GLRenderDepth, GLSLShader, GLSLProgram

typedefs

GLTexture1D, GLTexture2D, GLTexture3D, GLTexture1DArray, GLTexture2DArray, GLTextureBuffer, GLTextureRect, GLRenderTexture2D, GLRenderTextureRect, GLRenderDepth2D, GLRenderDepthRect,

dependencies

none, but can also be used with cyPoint, cyMatrix, and cyIPoint.