Class 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.

    • 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 PApplet
        ipAddr - IPv4 address of PixelTeleporter server device
        serverPort - Command receiver port on server device. Default: 8081
        clientPort - 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 PApplet
        ipAddr - IPv4 address of PixelTeleporter server device
        clientPort - Port number to listen on. Default: 8081
        serverPort - Command receiver port on server device to receive commands. Default: 8082
      • PixelTeleporter

        public PixelTeleporter​(PApplet pApp,
                               String ipAddr)
        Creates and initializes a PixelTeleporter object using default server/client UDP ports (8081,8082)
        Parameters:
        pApp - Pointer to currently running PApplet
        ipAddr - IPv4 address of PixelTeleporter server device
    • 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 units
        pct - (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 worldspace
        y - 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 object
        opacity - 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 object
        opacity - 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 worldspace
        y - y coordinate in 3D worldspace
        z - 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 write
        scale - 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 object
        fileName - Name of file to write
        scale - Coordinate multiplier for scaling final output
        is3D - 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.)