rotate the camera in all direction by mouse
in
Programming Questions
•
1 year ago
I want to rotate the camera by clicking and dragging the mouse in all direction . around x , y , z axis . how could I do that ?
- PFont font;
- int valueX = 0, valueY = 0;
- void setup() {
- size(screenWidth, screenHeight, P3D);
- fill(204);
- font = createFont("Sans Serif", 80);
- // font
- textFont(font);
- }
- void draw() {
- background(0, 0, 54);
- lights();
- // camera
- camera( 100, 210, 2000, // eyeX, eyeY, eyeZ
- -100, 200, -1000000, // centerX, centerY, centerZ
- 0.0, 0.0, 1.0 ); // upX, upY, upZ
- ShowCoordinates ();
- fill(212,117,122);
- SphereParameters (700, 300, -300, 44);
- }
- void ShowCoordinates () {
- // Show Coordinates x, y and z
- // X
- stroke (255, 0, 0);
- line (0, 0, 0, 100, 0, 0 ) ;
- fill(255, 0, 0);
- SphereParameters (100, 0, 0, 13);
- text ("X", 120, 60, 0);
- // Y
- stroke (0, 255, 0);
- line (0, 0, 0, 0, 100, 0 ) ;
- fill(0, 255, 0);
- SphereParameters (0, 100, 0, 13);
- text ("Y", 0, 180, 0);
- // Z
- stroke (0, 0, 255);
- line (0, 0, 0, 0, 0, -300 ) ;
- fill(0, 0, 255);
- SphereParameters (0, 0, -300, 33);
- text ("-Z", 30, 50, -300);
- } // function
- void SphereParameters ( float x, float y, float z,
- float w ) {
- // Position and size of a sphere
- noStroke();
- pushMatrix();
- translate ( x, y, z );
- sphere ( w );
- popMatrix();
- } // function
1