camera mess up things
in
Contributed Library Questions
•
2 years ago
what i want to achieve is this (2nd post):
To make things easier, i added control p5 sliders.
I only don't see them when i add my own camera.
if you comment: spectatePlayer(player);
then the default camera is used and you can see stuff drawn on the screen.
- import processing.opengl.*;
- //import fullscreen.*;
- import controlP5.*;
- //FullScreen fs;
- ControlP5 controlP5;
- Player player;
- Player bot1;
- float tEyeX;
- float tEyeY;
- float tEyeZ;
- void setup() {
- size(800, 800, OPENGL);
- frameRate(200);
- //fs = new FullScreen(this);
- // fs.enter();
- player = new Player(0, 0, 0);
- bot1 = new Player(width/3.0, height/3.0, (height/3.0)/ tan(PI*60.0 / 360.0));
- controlP5 = new ControlP5(this);
- //width/2.0, height/2.0, (height/2.0) / tan(PI*60.0 / 360.0), width/2.0, height/2.0, 0, 0, 1, 0)
- controlP5.addSlider("tEyeX", 0, width, width/2.0, 20, 50, 100, 10);
- controlP5.addSlider("tEyeY", 0, height, height/2.0,20,70,100,10);
- controlP5.addSlider("tEyeZ",0,1000,(height/2.0) / tan(PI*60.0 / 360.0),20,90,100,10);
- println((height/2.0) / tan(PI*60.0 / 360.0));
- sphereDetail(10);
- smooth();
- }
- void draw() {
- background(255);
- noFill();
- stroke(0);
- hint(ENABLE_DEPTH_TEST);
- player.x = tEyeX;
- player.y = tEyeY;
- player.z = tEyeZ;
- //see what the specified player will see
- spectatePlayer(player);
- player.display();
- box(1000);
- hint(DISABLE_DEPTH_TEST);
- text("fps: "+frameRate, 20, 20);
- controlP5.draw();
- fill(0);
- rect(50, 400, 100, 100);
- }
- // . . . . . . . . . . . . . . . . . . . . . . . . .
- void spectatePlayer(Player pl) {
- //camera(pl.x, pl.y, pl.z, width/2.0, height/2.0, 0, 0, 1, 0);
- camera(pl.x, pl.y, pl.z, width/2, height/2, 0, 0, 1, 0);
- }
- // . . . . . . . . . . . . . . . . . . . . . . . . .
- class Player {
- float x, y, z;
- int sphereSize = 50;
- Player(float x, float y, float z) {
- this.x = x;
- this.y = y;
- this.z = z;
- }
- void display() {
- sphere(sphereSize);
- }
- }
1