Staacks / there.oughta.be

Projects featured on my blog at https://there.oughta.be
https://there.oughta.be
GNU General Public License v3.0
101 stars 33 forks source link

Rotate one panel #22

Closed AlienCargo closed 2 years ago

AlienCargo commented 2 years ago

Hello

First, a great project. It looks awesome. Thank you for sharing the code. My cube runs fine. I have one question. I need to rotate the image of the third panel in the chain by 90 degree clockwise. I have tried to adapt the verticies, but i guess i'm not smart enough to understand this. Even in school i didn't understand the vector stuff. It would be nice if you could get me the values and an additional explanation for the new values. Maybe i can understand it more. I read your description and the samples here in the issues section, but i was not able to adapt to my situation. Can you help?

Staacks commented 2 years ago

Rotating the last eight lines (four points with x and y coordinates each) starting from here should be enough: https://github.com/Staacks/there.oughta.be/blob/master/led-cube/led-cube/cpu-stats-gl.cpp#L147

These are the coordinates that are mapped to the vertices and the last eight entries are coordinate pairs mapped to the last four vertices. Rotating in this case means that you take the last two lines (154 and 155) and move them in front of 147 - or - take the two lines at 147 and 148 and move them two the end to rotate in the opposite direction.

Does this achieve what you are looking for?

AlienCargo commented 2 years ago

Hello Thank you for your help but it didn't work. I have tried as suggested but the result is not correct. I made some pictures. Please have a look.

This is my start position. https://ibb.co/tsgvBsX Please note the first line only because the second line is a copy only.

I changed as first suggested and i got this result https://ibb.co/tbrWckr As you can see the panel didn*t rotate the right way

So i changed as second suggested and i got this result https://ibb.co/WKzCS7q As you can see it didn't rotate correct.

And in addition the last 8 coordinates changes the first panel in the chain. So i thought i need to change the first eight coordinates (Line 127-135). That ist right. If change the first 8 as suggested the last panel changes but with the same wrong result.

Please have a look. I took GIMP to manipulate the picture so you have an idea what i try to do. As mentioned only the first line as the second line is a copy only. And don't bother the value. In my final build i don't have this number. https://ibb.co/26S3GpQ

Do you have an idea what was is wrong?

Staacks commented 2 years ago

Ah, yes, sorry, I just realize that the vertices are not defined around one panel, but in a zig-zag pattern across the panel, because I render them as a triangle strip. So, the first vertex is in one corner, the next on a neighboring corner, then instead of going to the next corner it is the one across the diagonal, and then the final corner.

To visualize it: Instead of

1--2
|  |
4--3

It is

1--2
|  |
3--4

So, if we just number those eight lines, I previously suggested to turn 1,2,3,4,5,6,7,8 into 7,8,1,2,3,4,5,6 or 3,4,5,6,7,8,1,2. I think the correct suggestion would have been to turn 1,2,3,4,5,6,7,8 into 5,6,1,2,7,8,3,4 or 3,4,7,8,1,2,5,6.

AlienCargo commented 2 years ago

Thank you a lot. That did the trick. The second sequence rotates the third panel 90 degrees clockwise. I guess now i understand a litle bit more. Maybe you have asked why i need to rotate the third panel? I like to build a cube with 6 sides. So i duplicated the first row to the second. In addition i don't want to rotate the second row during assembly because the panel should point to the top. So if use a second app maybe a text scroller, the text can simple spin around the cube in x direction. If i would rotate the display during assembly it would be a lot harder to code such text scroll. Now i can build a six sided cube. I have two CPU animations at the opposites of the corners. I have copied and mirrored the first line to the second. Please have a look https://ibb.co/TWwXWV9 Panel 2 and 3 from the first row and Panel 5 and 6 from the second row will assembled to build the cube. Panel 1 is the top and Panel 4 is the bottom part of the cube. As i have rotated and mirrored the animation, the four "main" panels (2,3,5,6) are equal aligned and it is very easy to do some scrolling animation around the cube. At the moment i'm testing the electronic but when i'm finished, i can assemble the cube and build more animations and apps.

Again thanks a lot for your help or "Vielen, Vielen Dank für Deine Hilfe" as i'm german too :-)