zestyping / openpixelcontrol

A simple stream protocol for controlling arrays of RGB lights.
http://openpixelcontrol.org/
353 stars 103 forks source link

Documentation of freespace.py #46

Open osmithy opened 6 years ago

osmithy commented 6 years ago

The example suggests starting with the freespace layout, which works, but I have no idea how to change the layout because the code in freespace.py has no comments that explain what it does. Any chance you could add a few?

willisk-main commented 6 years ago

Hey Osmithy, we had trouble with the how the points were mapped also. From messing around with freespace.py it looks like the coordinates for the line

"point" ( 0, 0, 0,)

Map to the colored axis (red, green, blue) on the visual interface.

It's still not completely clear what inputs OPC will recognize for shapes though but from looking at the provided files it looks like "point" and "circle" are used.

Hope that helps.

longears commented 6 years ago

A layout file is a list of points in 3d space, in json, representing each LED. The numbers are x, y, z coordinates. The order of points should be the same order they occur on your LED string.

  {"point": [1.32, 0.00, 1.32]},
  {"point": [1.32, 0.00, 1.21]},
  {"point": [1.32, 0.00, 1.10]},

This format is not part of the OPC spec, which is only about sending colors to LEDs.

The spatial information from the layout file is used by:

gl_server.c draws a little red-green-blue axis marker at the origin to help you get oriented. Red is x, green is y, and blue is z.

I see that gl_server.c also supports lines in addition to points. Looks like it expects this format:

    {"line": {"start": [11, 22, 33], "end": [77, 88, 99]}}

...but I don't see any example layout files that use lines.

I think there were once "circles" or maybe "spheres" which were drawn as extra large spheres in the 3d preview, but I don't see that code here.

The purpose of freespace.py is to generate a layout file representing an installation that was at Freespace in SF which was a grid folded in half in the middle.

In my fork I have some more JSON layouts to play with and also a script objToLayout.py which converts the vertices of an OBJ file into a JSON layout.