3D object spin?? Please Help :)
in
Programming Questions
•
1 year ago
- import processing.opengl.*;
- H20 myH20;
- void setup() {
- size(800, 600, OPENGL);
- myH20 = new H20();
- }
- void draw() {
- background(0);
- myH20.display();
- myH20.move();
- }
- class H20 {
- color c;
- float xpos = width/2;
- float ypos = height/2;
- float xspeed =5;
- float yspeed =5;
- H20() {
- c = color(255);
- xpos = width/2;
- ypos = height/2;
- xspeed = 1;
- }
- void display() {
- pushMatrix();
- lights();
- translate(xpos,ypos, 50);
- noStroke();
- fill(255, 100, 100);
- sphere(50);
- popMatrix();
- pushMatrix();
- lights();
- translate(xpos+40, ypos-35, 50);
- noStroke();
- fill(90);
- sphere(35);
- popMatrix();
- pushMatrix();
- translate(xpos-40, ypos-35, 50);
- noStroke();
- fill(90);
- sphere(35);
- popMatrix();
- }
- void move() {
- xpos = xpos + xspeed;
- ypos = ypos + yspeed;
- if(xpos > width-100 || xpos <=100) {
- xspeed=xspeed*-1;
- }
- if(ypos > height-100 || ypos <= 100) {
- yspeed=yspeed*-1;
- }
- }
- }
please i need to get my "molecule" to spin
xD
1