Skip to content

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

@mgrider

Description

@mgrider

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!)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions