Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request -- making the preview look more like a L3D #1

Open
mgrider opened this issue Dec 18, 2014 · 2 comments
Open

feature request -- making the preview look more like a L3D #1

mgrider opened this issue Dec 18, 2014 · 2 comments

Comments

@mgrider
Copy link

mgrider commented Dec 18, 2014

Hey there! Great work on this processing library. I've been able to get it up and running and am extremely happy working with it. Only thing is that the output looks not so much like an L3D.

I've looked through the code, and I think I know where to change it, but I'm too new to java packaging (never tried to create a .jar before today!)

I'm not really sure it'll work, (because I haven't tested it!), but I think you should be able to replace the existing draw() method (around line 214 in L3D.java) with the following:

public void draw() {
    if(pose)  //translate the cube to the center and rotate it according to the mouse
        poseCube();
    if (drawCube) {
      float fourthScale = scale / 4.0;
      float halfScale = scale / 2.0;
      for (float x = 0; x < side; x++)
        for (float y = 0; y < side; y++)
          for (float z = 0; z < side; z++) {
            // draw just the white outline
            if (x<side-1 && y<side-1 && z<side-1) {
              parent.stroke(255, 10);
              parent.pushMatrix();
              parent.translate((x-(side-1)/2) * scale, (y-(side-1)/2) * scale, (side - 1 - (z-(side-1)/2))* scale);
              parent.noFill();
              parent.box(scale, scale, scale);
              parent.popMatrix();
            }
            // draw the actual color cube
            parent.noStroke();
            parent.pushMatrix();
            parent.translate((x-(side-1)/2) * scale - halfScale + fourthScale, (y-(side-1)/2) * scale - halfScale + fourthScale, (side - 1 - (z-(side-1)/2))* scale - halfScale + fourthScale);
            if (parent.brightness(cube[(int)x][(int)y][(int)z]) != 0)
              parent.fill(cube[(int)x][(int)y][(int)z]);
            else
              parent.noFill();
              parent.box(scale, scale, scale);
              parent.scale(0.5,0.5,0.5);
              parent.popMatrix();
           }

    }
    if ((stream != null) && (!manualUpdate))
        stream.sendData(cube);

}

If you wanted to preserve (or default to) the old look, you could always wrap all of this in a preference of some kind. (Which I would be happy to implement myself if I could just test my code!)

@mgrider
Copy link
Author

mgrider commented Dec 18, 2014

Hmmm. Embarrassingly, that's not quite right at all. I was able to finally see this by telling the cube object not to draw, and putting the above code in my script's draw function/method.

Looks like the parent.scale call isn't necessary at all, and changing the second parent.box(scale,scale,scale) to parent.box(fourthScale,fourthScale,fourthScale) seems to be closer to the size I was going for.

But also maybe there's an off-by-1 error? Since my testing method bypasses the cube "posing", I can't quite tell.

I would love to know the commands for building the .jar file, which would allow me to test this properly. I've basically tried variations on the following, and all give lots of errors:

[Dec 18 12:14:57] L3D (master *%) $ javac -d . L3D.java 
L3D.java:29: package processing.core does not exist
import processing.core.PApplet;

thanks!

@enjrolas
Copy link
Owner

Hey Martin,
Thanks for writing! I tried out your code this morning, and bumped into the same errors you mention.
I’ll send you the eclipse project that I use to build the processing library. I followed this tutorial https://github.com/processing/processing-library-template to build the processing library using eclipse, and after a little wrestling (this is my first processing library), it was pretty easy to edit code and get it to do what I want.

The cube pose function just uses translate and rotate to move the cube to the center of the screen, rotate it to a tantalizing angle, and tells the library to listen to mouseDragged events to rotate the cube according to the mouse’s movements.  It’s called at the end of the processing program’s draw() function, but before it actually draws the cube.  If you want to get rid of it in your processing code, just remove the line in setup() that says ‘cube.enablePoseCube()’, and the program will draw the cube centered around (0,0), with no rotation.

—me

On Dec 18, 2014, at 11:07 AM, Martin Grider [email protected] wrote:

Hmmm. Embarrassingly, that's not quite right at all. I was able to finally see this by telling the cube object not to draw, and putting the above code in my script's draw function/method.

Looks like the parent.scale call isn't necessary at all, and changing the second parent.box(scale,scale,scale) to parent.box(fourthScale,fourthScale,fourthScale) seems to be closer to the size I was going for.

But also maybe there's an off-by-1 error? Since my testing method bypasses the cube "posing", I can't quite tell.

I would love to know the commands for building the .jar file, which would allow me to test this properly. I've basically tried variations on the following, and all give lots of errors:

[Dec 18 12:14:57] L3D (master *%) $ javac -d . L3D.java
L3D.java:29: package processing.core does not exist
import processing.core.PApplet;
thanks!


Reply to this email directly or view it on GitHub #1 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants