PDA

View Full Version : Nutcracker: Make your own target files



smeighan
04-20-2012, 07:18 PM
I have been getting requests for more targets than i have coded so far.

Most are requesting the horizontal matrix.

I will build a target generator for that, but i wanted to let all of you know that you can make your own target files.

horizontal matrix, LEDs wrapped around your bush, leds on the side of your house, stack matrix quads on top of each other. You can do it.

Here is the basic concept for Nutcracker targets. Whatever you have has to be divided into vertical strands. Each strand has pixels. Those pixels will always start with Pixel #1 at the top. For each pixel include the x,y,z location in world coordinates.

Well, thats it.

Here is what a target file looks like. It should be a space delimited ASCII file. Comments begin with a hash mark. Blank lines are ignored.


# ../targets/2/AA.dat
# Col 1: Your TARGET_MODEL_NAME
# Col 2: Strand number.
# Col 3: Nutcracker Pixel#
# Col 4: X location in world coordinates
# Col 5: Y location in world coordinates
# Col 6: Z location in world coordinates
# Col 7: User string <= This is your string#. Start at 1 and go to how many you have
# Col 8: User pixel <= This is the physical pixel # on your string
# Col 9: Username. This is a uneeded field and can be left blank
# Col 10: Targetname (again). This is an unneeded field and can be left blank

AA 1 1 0.000 0.728 131.254 0 1 50 f AA
AA 1 2 0.000 1.455 128.343 0 1 49 f AA
AA 1 3 0.000 2.183 125.433 0 1 48 f AA
AA 1 4 0.000 2.910 122.522 0 1 47 f AA
AA 1 5 0.000 3.638 119.612 0 1 46 f AA
AA 1 6 0.000 4.366 116.702 0 1 45 f AA
AA 1 7 0.000 5.093 113.791 0 1 44 f AA
AA 1 8 0.000 5.821 110.881 0 1 43 f AA
AA 1 9 0.000 6.548 107.970 0 1 42 f AA
AA 1 10 0.000 7.276 105.060 0 1 41 f AA


AA 2 1 0.142 0.714 131.254 0 1 51 f AA
AA 2 2 0.284 1.427 128.343 0 1 52 f AA
AA 2 3 0.426 2.141 125.433 0 1 53 f AA
AA 2 4 0.568 2.855 122.522 0 1 54 f AA
AA 2 5 0.710 3.568 119.612 0 1 55 f AA
AA 2 6 0.852 4.282 116.702 0 1 56 f AA
AA 2 7 0.994 4.995 113.791 0 1 57 f AA
AA 2 8 1.136 5.709 110.881 0 1 58 f AA
AA 2 9 1.278 6.423 107.970 0 1 59 f AA
AA 2 10 1.419 7.136 105.060 0 1 60 f AA


So let me show you how to make one in pseudo code:

A user here has 12 flat strings, 30 pixels each. He wants to string them horizontally and make a horizontal matrix.

He probably wants scrolling text to work and create a nice sign board.

We need the above file to be created.


# In x,y,z world coordinates, we can consider this a 2D object. In Nutcracker space the z axis is up and down, the x axis is left and right, the y axis is front and back
# we will start at the bottom of his first string and consider that (0,0,0).
# Y axis will always be 0 since this is a 2d object. Let us assume 3" spacing between his pixels and 3" spacing between the rows of strings. My aha moment was
# when i realized these dimensions do NOT have to match your display, they only have to be keep referential intact for my calculations. Let me simply this
# by saying always use 3" or 8cm for the spacing between your objects and all my effects will work.

for (s=1;s<=12;s++) # Lets go through all of his strings
for (p=1;p<=30;p++) # and for each of his strings look at all of his pixels.
{
y=0.0; # we have a 2d shape, the matrix will be a flat plane
x=p*3; # in a horizontal matrix, pixels are going horizontally
z=s*3; # and strings stack on top of each other.

strand =p; # i need the verticals to be strands. 30 pixels laid out horizontally. We will therefore have 30 strands
pixel = 13-s; The very top string needs to be labeled as pixel #1, the very last (bottom string) needs to be labels as pixel 12
print "HMATRIX ",strand,pixel,x,y,z,s,p;
}


The code in red will produce a target file for a horizontal matrix.,

This will work with all effects in the Nutcracker.

As you can see , making the target files is pretty simple. It gets a little more complex if the object is in 3d.

Make a target file and email it to me, i will add it into your library of targets. I will make a screen where you can upload your own targets. The only other little cleanup is each target has to be entered into the mysql database.

Materdaddy
05-21-2012, 11:28 PM
What is the perspective of generated previews? I'm trying to get my roofline which I am going to simplify to two rectangles. I was planning on making the model a top-down view (Z will always be 0), but I was wondering if the view will put all pixels on top of each other and I should keep Y 0, like your example, depending on the "camera" in your graphic generation.

Is the code that supports this in the source that you've released? If so, I might get it up and running locally so I can test my target. Does it run in a LAMP environment? I thought I remembered seeing it was a window$ implementation.

smeighan
05-22-2012, 01:26 AM
What is the perspective of generated previews? I'm trying to get my roofline which I am going to simplify to two rectangles. I was planning on making the model a top-down view (Z will always be 0), but I was wondering if the view will put all pixels on top of each other and I should keep Y 0, like your example, depending on the "camera" in your graphic generation.

Is the code that supports this in the source that you've released? If so, I might get it up and running locally so I can test my target. Does it run in a LAMP environment? I thought I remembered seeing it was a window$ implementation.

meighan.net/nutcracker is a LAMP environment.

localhost/nutcracker is a WAMP environment.

the coordinate system i use is right handed. http://en.wikipedia.org/wiki/Right-hand_rule
for me the thumb is +Z, the index finger is +X and the palm/middle finger is +Y.

for my set viewpoint to work, you should have Z nd X if doing 2d work.

Materdaddy
05-22-2012, 10:16 AM
I have your code up and running, but it was a bit of work. I believe your install and manifest need a little bit of cleanup. It attempts getting the manifest from nutcracker/manifest, but when logging into the FTP site it's in the top level. There are also many files in the manifest that have invalid subdirectories that I was able to work around. I can help re-write that file if you want.

Thanks for the reply. I'll be making my target using Z and X since it will be 2D.

smeighan
05-22-2012, 10:30 AM
thanks.

rge way this works is after i modified code on my pc i upload it to meighan.net.

i then run
http://meighan.net/nutcracker/create_manifest.php. This creates a new file. The table manifest has the list of what should be downloaded.

i have not yet put everything under spource control in source forge. I eventually thought that i would create a zip file that people would download and unzip into \wamp\www.

This current download process was just for myself and one other person, Emanuel Miranda.

i have been thinking of taking the steps off the main page until i finish the download method.

that you got it working is great.
If you want to fix the install.php script so it corrects any of the errors you see that would be a big help.

again, almost no one needs to install nutcracker on a local machine yet. This will change when i release the new nutcracker (jun/jul) that is going to have the capability of syncing the music to your mp3 files . i will be running the nutcracker to generate an entire song in one pass. There is going be a new table called projects.

Projects => a mp3 and many effects postioned on the timeline.

you will be able to generate individual effects or generate the entrire 3 1/2 minute song in one pass. I expect the entire generation of a song could take 30-60 minutes, When projects are released , most people will then need to install WAMP.

thanks

Materdaddy
05-22-2012, 11:57 AM
I'd love to contribute as well as keep it WAMP/LAMP. So far everything seemed to work (other than the install itself, and a couple other things) on my LAMP install. I'll keep track of anything I change (I'll put it in my own revision control to track things).

Thank YOU for this great project! I have many projects/hobbies, so I might return to lurk-only mode for a few weeks at a time.

Materdaddy
05-23-2012, 01:21 AM
Ok, I have a couple more questions... I need clarification on the following:

What is the difference between "Nutcracker Pixel#" (for column 3) and "User pixel" (for column 8)?
What is the difference between "Strand number" (for column 2) and "User string" (for column 7)?

My roofline configuration I'm trying to configure looks like the following:



_______33________ _____24____
| | |
| | |
|37 37| |38
| | |
| |___________|
|_________________| 27
33


I wrote some python code to generate the file based on what I *think* your target layout is. The code basically iterates on a multidimensional array. Each array is the bulb count, starting X/Y (which are translated to X/Z for the purposes of nutcracker's 2D projection) and a direction from that starting X/Y point. The direction is based on what direction the bulb count is as the string travels outward from the E681. Here is the code:


strings = [[ 33, 33, 38, 'w' ],
[ 24, 33, 38, 'e' ],
[ 38, 57, 1, 'n' ],
[ 27, 33, 1, 'e' ],
[ 33, 0, 0, 'e' ],
[ 37, 0, 0, 'n' ],
[ 37, 33, 0, 'n' ]]

count = 0
bulb = 0

for string in strings:
count += 1
(bulbs, x, y, direction) = string
for i in range(0, bulbs):
bulb += 1
if direction == "n":
_y = y+i
elif direction == "s":
_y = y-i
else:
_y = y
if direction == "e":
_x = x+i
elif direction == "w":
_x = x-i
else:
_x = x

print "TEST", count, i+1, _x, 0, _y, i+1, count, "Materdaddy", "TEST"


It generates a test file I redirect to a "TEST.dat" which I placed and generated some images for, however I don't think it's exactly what I'm intending. Here's a butterfly on this layout:
http://i892.photobucket.com/albums/ac127/materdaddy/diyc/diyc%20-%20posts/TESTTEST-1.gif

(If you're curious about the bulb counts being off, it's because certain segments of the roofline have "features" (like chimney) that the bulbs go around that I simplified for planning purposes.)

smeighan
05-23-2012, 01:34 AM
Ok, I have a couple more questions... I need clarification on the following:

What is the difference between "Nutcracker Pixel#" (for column 3) and "User pixel" (for column 8)?
What is the difference between "Strand number" (for column 2) and "User string" (for column 7)?

My roofline configuration I'm trying to configure looks like the following:



_______33________ _____24____
| | |
| | |
|37 37| |38
| | |
| |___________|
|_________________| 27
33


I wrote some python code to generate the file based on what I *think* your target layout is. The code basically iterates on a multidimensional array. Each array is the bulb count, starting X/Y (which are translated to X/Z for the purposes of nutcracker's 2D projection) and a direction from that starting X/Y point. The direction is based on what direction the bulb count is as the string travels outward from the E681. Here is the code:


strings = [[ 33, 33, 38, 'w' ],
[ 24, 33, 38, 'e' ],
[ 38, 57, 1, 'n' ],
[ 27, 33, 1, 'e' ],
[ 33, 0, 0, 'e' ],
[ 37, 0, 0, 'n' ],
[ 37, 33, 0, 'n' ]]

count = 0
bulb = 0

for string in strings:
count += 1
(bulbs, x, y, direction) = string
for i in range(0, bulbs):
bulb += 1
if direction == "n":
_y = y+i
elif direction == "s":
_y = y-i
else:
_y = y
if direction == "e":
_x = x+i
elif direction == "w":
_x = x-i
else:
_x = x

print "TEST", count, i+1, _x, 0, _y, i+1, count, "Materdaddy", "TEST"


It generates a test file I redirect to a "TEST.dat" which I placed and generated some images for, however I don't think it's exactly what I'm intending. Here's a butterfly on this layout:
http://i892.photobucket.com/albums/ac127/materdaddy/diyc/diyc%20-%20posts/TESTTEST-1.gif

(If you're curious about the bulb counts being off, it's because certain segments of the roofline have "features" (like chimney) that the bulbs go around that I simplified for planning purposes.)

Nutcracker has this internal coordinate system, rgb devices are made of strands that run from the top of your device downward.
a Nutcracker pixel starts at the top of each strand and counts downward. In other words any nutcracker pixel #1 is always the top of your rgb target.

String and user pixels are the physical string and pixel of your device.

say you had one string with 100 pixels.

you start it at the bottom of your tree, go up 50 pixels and then foldit and come back down. Your string will make 2 strands of 50 pixels each. Those 2 strands in Nutcracker space will be
Strand #1, pixel 1 is the top of the strand, pixel 50 is bottom
Strand #2, pixel 1 is the top of the strand, pixel 50 is bottom

so for the first pixel of your string

User Nutcracker
String Pixel Strand Pixel
1 1 1 50
1 2 1 49
....
1 50 1 1
1 51 2 1
1 52 2 2
...
1 100 2 50

Your pixture of the butterfly is probably what it is going to look like.


You take whatever you have and imagine making vertical stripes from left to right.
The first strand looks like it would have all 50 pixels, the second strand would just have pixel 1 and 50, .etc.

My effects are looking for pixels next to each other. They will work on yours, but i am not sure how good the effect will be.

Now if i were to make an effect that is a color chase and you then connect each line of your window to a strand, then you would get chases going around the window.

i like the discussion, we will see where it takes us. i am happy to make a chase effect class if you want.

Materdaddy
05-25-2012, 01:05 PM
What are the bounds/limits on the X/Y/Z planes? I tried a simple doubling of the values in my python script so the pixels are more spaced out than the demo GIF I posted and things are cut out of view. Do I need to keep it within a certain frame?

smeighan
05-26-2012, 11:49 AM
What are the bounds/limits on the X/Y/Z planes? I tried a simple doubling of the values in my python script so the pixels are more spaced out than the demo GIF I posted and things are cut out of view. Do I need to keep it within a certain frame?

i should be autoscaling.

you can see for this image

http://meighan.net/nutcracker/effects/workspaces/2/AA+FLY_0_0.gif

you can view the dat file for it by changing th gif to dat

i create 80 frames. The dat file for frame 80 is

http://meighan.net/nutcracker/effects/workspaces/2/AA+FLY_0_0_d_1.dat
to
http://meighan.net/nutcracker/effects/workspaces/2/AA+FLY_0_0_d_80.dat

givr mr ur login name and the effect name
thanks