Package pixelTeleporter.library
Class PixelTeleporter
- java.lang.Object
-
- pixelTeleporter.library.PixelTeleporter
-
- All Implemented Interfaces:
PConstants
public class PixelTeleporter extends Object implements PConstants
Manages communication with the PixelTeleporter server device and provides a framework for object rendering and basic user camera control.To use, create a PixelTeleporter object in your sketch and call its start() method to begin listening for pixel data on the network.
-
-
Field Summary
Fields Modifier and Type Field Description int[]pixelBufferstatic StringVERSION-
Fields inherited from interface processing.core.PConstants
ADD, ALPHA, ALT, AMBIENT, ARC, ARGB, ARROW, BACKSPACE, BASELINE, BEVEL, BEZIER_VERTEX, BLEND, BLUR, BOTTOM, BOX, BREAK, BURN, CENTER, CHATTER, CHORD, CLAMP, CLOSE, CODED, COMPLAINT, CONTROL, CORNER, CORNERS, CROSS, CURVE_VERTEX, CUSTOM, DARKEST, DEG_TO_RAD, DELETE, DIAMETER, DIFFERENCE, DILATE, DIRECTIONAL, DISABLE_ASYNC_SAVEFRAME, DISABLE_BUFFER_READING, DISABLE_DEPTH_MASK, DISABLE_DEPTH_SORT, DISABLE_DEPTH_TEST, DISABLE_KEY_REPEAT, DISABLE_NATIVE_FONTS, DISABLE_OPENGL_ERRORS, DISABLE_OPTIMIZED_STROKE, DISABLE_STROKE_PERSPECTIVE, DISABLE_STROKE_PURE, DISABLE_TEXTURE_MIPMAPS, DODGE, DOWN, DXF, ELLIPSE, ENABLE_ASYNC_SAVEFRAME, ENABLE_BUFFER_READING, ENABLE_DEPTH_MASK, ENABLE_DEPTH_SORT, ENABLE_DEPTH_TEST, ENABLE_KEY_REPEAT, ENABLE_NATIVE_FONTS, ENABLE_OPENGL_ERRORS, ENABLE_OPTIMIZED_STROKE, ENABLE_STROKE_PERSPECTIVE, ENABLE_STROKE_PURE, ENABLE_TEXTURE_MIPMAPS, ENTER, EPSILON, ERODE, ESC, EXCLUSION, FX2D, GIF, GRAY, GROUP, HALF_PI, HAND, HARD_LIGHT, HINT_COUNT, HSB, IMAGE, INVERT, JAVA2D, JPEG, LANDSCAPE, LEFT, LIGHTEST, LINE, LINE_LOOP, LINE_STRIP, LINES, LINUX, MACOSX, MAX_FLOAT, MAX_INT, MIN_FLOAT, MIN_INT, MITER, MODEL, MODELVIEW, MOVE, MULTIPLY, NORMAL, OPAQUE, OPEN, OPENGL, ORTHOGRAPHIC, OTHER, OVERLAY, P2D, P3D, PATH, PDF, PERSPECTIVE, PI, PIE, platformNames, POINT, POINTS, POLYGON, PORTRAIT, POSTERIZE, PROBLEM, PROJECT, PROJECTION, QUAD, QUAD_BEZIER_VERTEX, QUAD_STRIP, QUADRATIC_VERTEX, QUADS, QUARTER_PI, RAD_TO_DEG, RADIUS, RECT, REPEAT, REPLACE, RETURN, RGB, RIGHT, ROUND, SCREEN, SHAPE, SHIFT, SOFT_LIGHT, SPAN, SPHERE, SPOT, SQUARE, SUBTRACT, SVG, TAB, TARGA, TAU, TEXT, THIRD_PI, THRESHOLD, TIFF, TOP, TRIANGLE, TRIANGLE_FAN, TRIANGLE_STRIP, TRIANGLES, TWO_PI, UP, VERTEX, WAIT, WHITESPACE, WINDOWS, X, Y, Z
-
-
Constructor Summary
Constructors Constructor Description PixelTeleporter(PApplet pApp, String ipAddr)Creates and initializes a PixelTeleporter object using default server/client UDP ports (8081,8082)PixelTeleporter(PApplet pApp, String ipAddr, int clientPort)Creates and initializes a PixelTeleporter object.PixelTeleporter(PApplet pApp, String ipAddr, int serverPort, int clientPort)Creates and initializes a PixelTeleporter object.
-
Method Summary
Modifier and Type Method Description voidapplyViewingTransform()Apply current viewing transform to all displayable objects.booleanautoDataEnabled()Returns state of PixelTeleporter's automatic data handlervoiddisableAutoData()Disables automatic handling of per frame pixel request/read operations.voiddisablePixelInfo()Disable display of per pixel tooltips on mouse hovervoiddisableUI()Disables mouse/keyboard handlers.voiddispose()Called when the library shuts down.voiddraw(LinkedList<ScreenLED> obj)Draw an LED object using the selected renderer and the current viewing transform.voidenableAutoData()Enables automatic handling of per frame pixel request/read operations.voidenablePixelInfo()Enable display of per pixel tooltips on mouse hovervoidenableUI()Enables mouse/keyboard handlers.booleanexportPixelblazeMap(LinkedList<ScreenLED> obj, String fileName, float scale, boolean is3D)Convert a list of ScreenLEDs to a Pixelblaze compatible JSON pixel map and write it to the specified file.PVectorfindObjectCenter(LinkedList<ScreenLED> obj)Find geometric center of object represented by ScreenLED list.intgetElementSize()Gets the current pixel size.intgetPixel(int index)Gets the color of a pixelLinkedList<ScreenLED>importPixelblazeMap(String fileName, float scale)Read a Pixelblaze compatible pixel map into a list of ScreenLED objects.booleanpixelInfoEnabled()Returns state of PixelTeleporter's pixel index order labelingvoidpost()voidpre()intreadData()To be called in draw() prior to rendering.voidrender2D(LinkedList<ScreenLED> obj)Deprecated.Use new draw() method instead.voidrender3D(LinkedList<ScreenLED> obj)Deprecated.Use new draw() method instead.voidrenderShape(LinkedList<ScreenShape> obj)Deprecated.Use new draw() method insteadvoidrequestData()Tells the transport to request a frame of pixel data from the server.ScreenLEDScreenLEDFactory()Creates ScreenLED object with x,y,z coords initialized to 0.ScreenLEDScreenLEDFactory(float x, float y)Creates ScreenLED object using x and y coordsScreenLEDScreenLEDFactory(float x, float y, float z)Creates ScreenLED object using x,y,z coordsScreenShapeScreenShapeFactory(PShape s)Creates ScreenShape object using supplied shapeScreenShapeScreenShapeFactory(PShape s, int opacity)Creates ScreenShape object using supplied shapevoidsetBackgroundImage(String imgPath)Loads an image file for to use as a background.voidsetElementSize(int n)Sets the size of displayed pixels with the illuminated portion defaulting to 40% of the total size.voidsetElementSize(int n, int pct)Sets size of displayed led "pixels"voidsetObjectCenter(float x, float y, float z)Set the center of rotation to specified x,y,z position.voidsetRenderMethod(RenderMethod m)Sets the method used to draw LED objects to the screen.voidsetRotation(float x, float y, float z)Set current rotation of displayable object to specified x,y,z angle (radians).voidsetRotationRate(float x, float y, float z)Set rotation rate of displayable object to x,y,z radians/millisecond.voidstart()Start data transport and initialize camera UI if enabledbooleanuiEnabled()Returns state of PixelTeleporter's mouse/keyboard handlers
-
-
-
Field Detail
-
pixelBuffer
public int[] pixelBuffer
-
VERSION
public static final String VERSION
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PixelTeleporter
public PixelTeleporter(PApplet pApp, String ipAddr, int serverPort, int clientPort)
Creates and initializes a PixelTeleporter object.- Parameters:
pApp- Pointer to currently running PAppletipAddr- IPv4 address of PixelTeleporter server deviceserverPort- Command receiver port on server device. Default: 8081clientPort- Port number to listen on. Default: 8082
-
PixelTeleporter
public PixelTeleporter(PApplet pApp, String ipAddr, int clientPort)
Creates and initializes a PixelTeleporter object. Alternate constructor to avoid breaking old scripts and firmware, this sets both client and server ports to the specified value. !!!! It will definitely not work with any server/bridge software version after 1.0.0 Please update/reflash your devices and use the new version which requires two ports.- Parameters:
pApp- Pointer to currently running PAppletipAddr- IPv4 address of PixelTeleporter server deviceclientPort- Port number to listen on. Default: 8081serverPort- Command receiver port on server device to receive commands. Default: 8082
-
-
Method Detail
-
enableUI
public void enableUI()
Enables mouse/keyboard handlers. These are enabled by default. Call disableUI() in Setup() if you want to use your own handlers.
-
disableUI
public void disableUI()
Disables mouse/keyboard handlers.
-
uiEnabled
public boolean uiEnabled()
Returns state of PixelTeleporter's mouse/keyboard handlers- Returns:
- true if enabled, false if disabled
-
enableAutoData
public void enableAutoData()
Enables automatic handling of per frame pixel request/read operations. This is enabled by default. Call disableAutoData() in your sketch's Setup() function if you want to do it yourself.
-
disableAutoData
public void disableAutoData()
Disables automatic handling of per frame pixel request/read operations.
-
autoDataEnabled
public boolean autoDataEnabled()
Returns state of PixelTeleporter's automatic data handler- Returns:
- true if enabled, false if disabled
-
enablePixelInfo
public void enablePixelInfo()
Enable display of per pixel tooltips on mouse hover
-
disablePixelInfo
public void disablePixelInfo()
Disable display of per pixel tooltips on mouse hover
-
pixelInfoEnabled
public boolean pixelInfoEnabled()
Returns state of PixelTeleporter's pixel index order labeling- Returns:
- true if enabled, false if disabled
-
start
public void start()
Start data transport and initialize camera UI if enabled
-
readData
public int readData()
To be called in draw() prior to rendering. Asks the transport to copy any pixel data it has recieved from the network to the internal ARGB pixel buffer, which we can use more easily for rendering.- Returns:
- number of pixels copied
-
requestData
public void requestData()
Tells the transport to request a frame of pixel data from the server. Called from draw() when ready to render pixels, although pixels will not be available for drawing until after the transport has received them from the network, and reformatted them into ARGB data via the readData() method.
-
getPixel
public int getPixel(int index)
Gets the color of a pixel- Parameters:
index- - index of pixel to be retrieved- Returns:
- - ARGB color of pixel at specified index
-
applyViewingTransform
public void applyViewingTransform()
Apply current viewing transform to all displayable objects. Should be called in draw() before rendering your displayable objects. See examples for details.
-
setElementSize
public void setElementSize(int n, int pct)Sets size of displayed led "pixels"Total size includes space around the lighted portion.
- Parameters:
n- total size of pixel element in world unitspct- (0-100) sets the percentage of the total that will be "lighted."
-
setElementSize
public void setElementSize(int n)
Sets the size of displayed pixels with the illuminated portion defaulting to 40% of the total size.- Parameters:
n- total size of pixel element in world units
-
getElementSize
public int getElementSize()
Gets the current pixel size.- Returns:
- size of LED "element" in world coords
-
setObjectCenter
public void setObjectCenter(float x, float y, float z)Set the center of rotation to specified x,y,z position.- Parameters:
x-y-z-
-
setRotation
public void setRotation(float x, float y, float z)Set current rotation of displayable object to specified x,y,z angle (radians).- Parameters:
x-y-z-
-
setRotationRate
public void setRotationRate(float x, float y, float z)Set rotation rate of displayable object to x,y,z radians/millisecond.- Parameters:
x-y-z-
-
setBackgroundImage
public void setBackgroundImage(String imgPath)
Loads an image file for to use as a background. Supported formats are: (.gif, .jpg, .tga, and .png) If the file is not available or an error occurs, no background will be created and a non-fatal error message will be printed to the console.- Parameters:
imgPath- An absolute path to a local file, or the URL of an image on the Web.
-
dispose
public void dispose()
Called when the library shuts down.Closes active devices and shuts down the transport listener thread.
-
ScreenLEDFactory
public ScreenLED ScreenLEDFactory()
Creates ScreenLED object with x,y,z coords initialized to 0.- Returns:
- new ScreenLED object
-
ScreenLEDFactory
public ScreenLED ScreenLEDFactory(float x, float y)
Creates ScreenLED object using x and y coords(the z coordinate will be initialized to 0.)
- Parameters:
x- x coordinate in 3D worldspacey- y coordinate in 3D worldspace- Returns:
- new ScreenLED object
-
ScreenShapeFactory
public ScreenShape ScreenShapeFactory(PShape s)
Creates ScreenShape object using supplied shape- Parameters:
s- PShape to attach to ScreenShape objectopacity- optional opacity for this object (0-255, default == 255)- Returns:
- new ScreenLED object
-
ScreenShapeFactory
public ScreenShape ScreenShapeFactory(PShape s, int opacity)
Creates ScreenShape object using supplied shape- Parameters:
s- PShape to attach to ScreenShape objectopacity- optional opacity for this object (int 0-255, default == 255)- Returns:
- new ScreenLED object
-
ScreenLEDFactory
public ScreenLED ScreenLEDFactory(float x, float y, float z)
Creates ScreenLED object using x,y,z coords.
- Parameters:
x- x coordinate in 3D worldspacey- y coordinate in 3D worldspacez- z coordinate in 3D worldspace- Returns:
- new ScreenLED object
-
importPixelblazeMap
public LinkedList<ScreenLED> importPixelblazeMap(String fileName, float scale)
Read a Pixelblaze compatible pixel map into a list of ScreenLED objects.- Parameters:
fileName- Name of file to writescale- Coordinate multiplier for scaling output- Returns:
- Linked list of ScreenLEDs corresponding to the pixel map if successful, null if unable to read the specified file.
-
exportPixelblazeMap
public boolean exportPixelblazeMap(LinkedList<ScreenLED> obj, String fileName, float scale, boolean is3D)
Convert a list of ScreenLEDs to a Pixelblaze compatible JSON pixel map and write it to the specified file.- Parameters:
obj- Linked list of ScreenLEDs representing a displayable objectfileName- Name of file to writescale- Coordinate multiplier for scaling final outputis3D- true for 3D (xyz), false for 2D (xy)- Returns:
- true if successful, false otherwise
-
findObjectCenter
public PVector findObjectCenter(LinkedList<ScreenLED> obj)
Find geometric center of object represented by ScreenLED list.- Parameters:
obj- Linked list of ScreenLEDs representing a displayable object- Returns:
- PVector with x,y,z set to object center
-
setRenderMethod
public void setRenderMethod(RenderMethod m)
Sets the method used to draw LED objects to the screen. Available methods are:- RenderMethod.DEFAULT - renders ScreenObj lists in 2D and ScreenShape lists in 3D. Fast and simple.
- RenderMethod.DRAW3D - renders all objects in 3D space using Processing graphics API calls
- RenderMethod.REALISTIC2D - uses Processing API calls to render realistic video-quality LED objects. Looks great, but performance will vary depending on your computer and GPU.
- RenderMethod.FILE - records incoming LED data to a JSON file for later playback. Useful for making movies and debugging.
- RenderMethod.SHADER3D - NOT YET IMPLEMENTED - Does nothing at the moment. (Uses OpenGL and GLSL to render highly detailed objects in 3D space. Performance may vary greatly depending on your GPU.)
-
draw
public void draw(LinkedList<ScreenLED> obj)
Draw an LED object using the selected renderer and the current viewing transform.
-
render2D
public void render2D(LinkedList<ScreenLED> obj)
Deprecated.Use new draw() method instead.
-
render3D
public void render3D(LinkedList<ScreenLED> obj)
Deprecated.Use new draw() method instead.
-
renderShape
public void renderShape(LinkedList<ScreenShape> obj)
Deprecated.Use new draw() method instead
-
pre
public void pre()
-
post
public void post()
-
-