L3D Cube Library
 All Classes Functions Pages
Public Member Functions | Public Attributes | List of all members
Cube Class Reference

An L3D LED cube. More...

#include <L3D.h>

Public Member Functions

 Cube (unsigned int s, unsigned int mb)
 Construct a new cube. More...
 
 Cube (void)
 Construct a new cube with default settings. More...
 
void setVoxel (int x, int y, int z, Color col)
 Set a voxel at a position to a color. More...
 
void setVoxel (Point p, Color col)
 Set a voxel at a position to a color. More...
 
Color getVoxel (int x, int y, int z)
 Get the color of a voxel at a position. More...
 
Color getVoxel (Point p)
 Get the color of a voxel at a position. More...
 
void line (int x1, int y1, int z1, int x2, int y2, int z2, Color col)
 Draw a line in 3D space. More...
 
void line (Point p1, Point p2, Color col)
 Draw a line in 3D space. More...
 
void sphere (int x, int y, int z, int r, Color col)
 Draw a filled sphere. More...
 
void sphere (Point p, int r, Color col)
 Draw a filled sphere. More...
 
void shell (float x, float y, float z, float r, Color col)
 Draw a shell (empty sphere). More...
 
void shell (float x, float y, float z, float r, float thickness, Color col)
 Draw a shell (empty sphere). More...
 
void shell (Point p, float r, Color col)
 Draw a shell (empty sphere). More...
 
void shell (Point p, float r, float thickness, Color col)
 Draw a shell (empty sphere). More...
 
void background (Color col)
 Set the entire cube to one color. More...
 
Color colorMap (float val, float min, float max)
 Map a value into a color. More...
 
Color lerpColor (Color a, Color b, int val, int min, int max)
 Linear interpolation between colors. More...
 
void begin (void)
 Initialization of cube resources and environment. More...
 
void show (void)
 Make changes to the cube visible. More...
 
void listen (void)
 Listen for the start of UDP streaming. More...
 
void initCloudButton (void)
 Initialize cloud switch hardware. More...
 
void checkCloudButton (void)
 Check cloud switch hardware. More...
 
void updateNetworkInfo (void)
 Update the cube's knowledge of its own network address. More...
 
int setPort (String port)
 Function to be called via Spark API for updating the streaming port number. More...
 

Public Attributes

int size
 
int maxBrightness
 

Detailed Description

An L3D LED cube.

Provides methods for drawing in 3D. Controls the LED hardware.

Constructor & Destructor Documentation

Cube::Cube ( unsigned int  s,
unsigned int  mb 
)

Construct a new cube.

Parameters
sSize of one side of the cube in number of LEDs.
mbMaximum brightness value. Used to prevent the LEDs from drawing too much current (which causes the colors to distort).
Returns
A new Cube object.
Cube::Cube ( void  )

Construct a new cube with default settings.

Parameters
sSize of one side of the cube in number of LEDs.
mbMaximum brightness value. Used to prevent the LEDs from drawing too much current (which causes the colors to distort).
Returns
A new Cube object.

Member Function Documentation

void Cube::background ( Color  col)

Set the entire cube to one color.

Parameters
colThe color to set all LEDs in the cube to.
void Cube::begin ( void  )

Initialization of cube resources and environment.

void Cube::checkCloudButton ( void  )

Check cloud switch hardware.

Color Cube::colorMap ( float  val,
float  min,
float  max 
)

Map a value into a color.

The set of colors fades from blue to green to red and back again.

Parameters
valValue to map into a color.
minMinimum value that val will take.
maxMaximum value that val will take.
Returns
Color from value.
Color Cube::getVoxel ( int  x,
int  y,
int  z 
)

Get the color of a voxel at a position.

Parameters
x,y,zCoordinate of the LED to get the color from.
Color Cube::getVoxel ( Point  p)

Get the color of a voxel at a position.

Parameters
pCoordinate of the LED to get the color from.
void Cube::initCloudButton ( void  )

Initialize cloud switch hardware.

Color Cube::lerpColor ( Color  a,
Color  b,
int  val,
int  min,
int  max 
)

Linear interpolation between colors.

Parameters
a,bThe colors to interpolate between.
valPosition on the line between color a and color b. When equal to min the output is color a, and when equal to max the output is color b.
minMinimum value that val will take.
maxMaximum value that val will take.
Returns
Color between colors a and b.
void Cube::line ( int  x1,
int  y1,
int  z1,
int  x2,
int  y2,
int  z2,
Color  col 
)

Draw a line in 3D space.

Uses the 3D form of Bresenham's algorithm.

Parameters
x1,y1,z1Coordinate of start of line.
x2,y2,z2Coordinate of end of line.
colColor of the line.
void Cube::line ( Point  p1,
Point  p2,
Color  col 
)

Draw a line in 3D space.

Uses the 3D form of Bresenham's algorithm.

Parameters
p1Coordinate of start of line.
p2Coordinate of end of line.
colColor of the line.
void Cube::listen ( void  )

Listen for the start of UDP streaming.

int Cube::setPort ( String  _port)

Function to be called via Spark API for updating the streaming port number.

Resets the UDP connection with the new port.

Parameters
_portA decimal number in a String, corresponding to the desired port number.
void Cube::setVoxel ( int  x,
int  y,
int  z,
Color  col 
)

Set a voxel at a position to a color.

Parameters
x,y,zCoordinate of the LED to set.
colColor to set the LED to.
void Cube::setVoxel ( Point  p,
Color  col 
)

Set a voxel at a position to a color.

Parameters
pCoordinate of the LED to set.
colColor to set the LED to.
void Cube::shell ( float  x,
float  y,
float  z,
float  r,
Color  col 
)

Draw a shell (empty sphere).

Parameters
xPosition of the center of the shell.
yPosition of the center of the shell.
zPosition of the center of the shell.
rRadius of the shell.
colColor of the shell.
void Cube::shell ( float  x,
float  y,
float  z,
float  r,
float  thickness,
Color  col 
)

Draw a shell (empty sphere).

Parameters
xPosition of the center of the shell.
yPosition of the center of the shell.
zPosition of the center of the shell.
rRadius of the shell.
thicknessThickness of the shell.
colColor of the shell.
void Cube::shell ( Point  p,
float  r,
Color  col 
)

Draw a shell (empty sphere).

Parameters
pPosition of the center of the shell.
rRadius of the shell.
colColor of the shell.
void Cube::shell ( Point  p,
float  r,
float  thickness,
Color  col 
)

Draw a shell (empty sphere).

Parameters
pPosition of the center of the shell.
rRadius of the shell.
thicknessThickness of the shell
colColor of the shell.
void Cube::show ( void  )

Make changes to the cube visible.

Causes pixel data to be written to the LED strips.

void Cube::sphere ( int  x,
int  y,
int  z,
int  r,
Color  col 
)

Draw a filled sphere.

Parameters
x,y,zPosition of the center of the sphere.
rRadius of the sphere.
colColor of the sphere.
void Cube::sphere ( Point  p,
int  r,
Color  col 
)

Draw a filled sphere.

Parameters
pPosition of the center of the sphere.
rRadius of the sphere.
colColor of the sphere.
void Cube::updateNetworkInfo ( void  )

Update the cube's knowledge of its own network address.


The documentation for this class was generated from the following files: