-
-
Notifications
You must be signed in to change notification settings - Fork 50
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
Projector Simulator #60
base: main
Are you sure you want to change the base?
Conversation
This is the initial commit for the Projector Simulator. Implemented the base for Projector Simulator. It has a working camera movement, room representation, and projector source.
- Add ProjectorSimulator sim field - Arrange draw to support Projector Simulator - ProjectorSimulator work on debug mode
@LuisMQuinones this is pretty amazing! I just had a first look and ran it. I noticed that the simulator only shows part of the stage. I attached a screenshot: I'll have a deeper look into the code now. I think we should add a keyboard shortcut to en- and disable the debug mode. Maybe some other people want to play with it. Not everyone has a project at hand when they want to test the software. |
Ok, I think i found the problem. I created a very simplified version of your approach: public class ProjectorSimulator extends PApplet{
private PImage projImg;
private int hires_factor = 2;
public ProjectorSimulator(){
super();
}
public void settings() {
pixelDensity(displayDensity());
size(800, 600, P3D);
}
public void setup(){
projImg = createImage(800,600,ARGB);
}
public void setImage(PImage img){
projImg = img;
}
public void draw(){
background(0);
drawBeams();
}
private void drawBeams(){
blendMode(ADD);
strokeWeight(hires_factor);
projImg.loadPixels();
color[] pixels = projImg.pixels;
translate(0, 0, -500);
for(int i=0; i < pixels.length; i+=hires_factor){
color pixel = pixels[i];
if(pixel != color(0)){
stroke(pixel);
int x = (i % (projImg.width * hires_factor)) / hires_factor;
int y = (i / (projImg.width * hires_factor)) / hires_factor;
line(projImg.width/hires_factor, 0, 0, x, y, 500);
}
}
}
} Now the problem is that |
Thank you! I really appreciate it. I'm still a student, so I'm still a little shy sharing my ideas and code. As far as a keyboard shortcut, my suggestion is the '`' key. It is used to open the console in games like CS: GO and other valve games. My concern for enabling and disabling debugMode is starting and properly killing threads. On the retina fix; I looked at the javadocs for PImage, and using projImg.pixelWidth and projOmg.pixelHeight instead of proj.width and proj.height should fix the problem. That, along with initializing hires_factor to pixelDensity, should fix the problem. It should be a quick fix, and I'll have the commit up shortly. |
How's performance? |
@LuisMQuinones no reason to be shy here, I wrote this when I was a student too ;) Also my Java is.... well lets say I don't do much Java these days. Ok, how do we continue. I would suggest you update your PR to support retina properly. I would probably for now also omit the rotation features. Oh and yes, rendering less pixel is totally fine. Especially on a retina there so many pixel ;) |
Problem: projImg.width and projImg.height does not return the proper values for Retina Displays. Solution: Instead of using projImg.width and projImg.height; use projImg.pixelWidth and projImg.pixelHeight. These will return the proper output for normal and retina displays. The rest of the code should work untouched. The initial camera position was also moved back to give a better view of the entire room
I don't quite understand, "I would probably for now also omit the rotation features. In the current build, the tool is only launched if the debugMode flag is true. User's can: Do you want the tool to open regardless if it's in debugMode? Do you want the tool to open, I know it will help people visualize the effects better if the tool opens up alongside the stage window, but my concern would be too many windows to handle for the user. As my understanding, this is what you when launching the app regularly: |
The simple fix in the last commit should fix the retina issues. I don't have a retina display myself to test it out. @codingjoe let me know if the commit fixes the retina issues |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @LuisMQuinones what I mean was:
Please remove the rotation feature. It adds complexity more than it adds functionality. For the sake of maintainability I would drop it. Unless you think it's really helpful.
MusicBeam/ProjectorSimulator.pde
Outdated
popMatrix(); | ||
} | ||
|
||
private void drawImage(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the unused code.
MusicBeam/ProjectorSimulator.pde
Outdated
for (int x =0; x<projImg.pixelWidth; x+=(2*beamWeight)){ | ||
int loc = x + y * width; | ||
color c = projImg.pixels[loc]; | ||
if( c !=0 && c != color(0)){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove double whitespaces
MusicBeam/ProjectorSimulator.pde
Outdated
color c = projImg.pixels[loc]; | ||
if( c !=0 && c != color(0)){ | ||
stroke(c,25); | ||
line(x,y,0,width/2,height/2,500); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add a trailing whitespace after a comma
MusicBeam/ProjectorSimulator.pde
Outdated
|
||
private float beamWeight; | ||
|
||
public ProjectorSimulator(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment to what this is feature does.
MusicBeam/ProjectorSimulator.pde
Outdated
eyeY = sceneY + coord[1]; | ||
eyeZ = sceneZ + coord[2]; | ||
|
||
//drawImage(); //uncomment to see image from stage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove commended code.
- Make changes that @codingjoe requested. - Use Google Java Style Guide to reformat code. - Comment and cleaned code for readability and maintainability.
Bump message. It's been a week since I've made the latest commit. @codingjoe Did you look at the changes that I've made? I've made the changes you wanted, reformat the rest of the code to Google Java Style Guide standards, and documented/commented the class, fields, and methods. I think the rotation feature and its associated camera system is a big part of the tool, but I'll voice my concern when this PR is merged, and I post my opinion on the issue thread. |
Hi @LuisMQuinones sorry for the late response. I was super busy at work. Ok, so I didn't review the code yet, but I tested it. It still doesn't seem to work correctly for retina displays. I still only see half the effect. |
Oh btw, I am trying to find a sponsor in MA for you ;) |
@LuisMQuinones I found some hardware for you :) just send me your shipping address to |
Implements #59
Proposed Changes