3D Demo

Simple 3D Cube Demo

import processing.opengl.*;

float inc = 0.1;

void setup() 
{
  noStroke();
  size(600, 600, OPENGL);
}

void draw() 
{
  background(0);
  lights();
  stroke(255,0,0);
  strokeWeight(5);
  fill(0,255,0);
  inc +=0.01;
  //pushMatrix();
  translate(width/2, height/2,-0);
  rotateX(inc);
  //rotateY(inc);
   // rotateZ(inc);
  //  rotateZ(inc);
  box(150);
  //popMatrix();
}


import processing.opengl.*;

PFont font;
float incx = 0.1;
float incy = 0.1;
float incz = 0.1;

void setup() 
{
  noStroke();
  size(600, 600, OPENGL);
  smooth();
  font = createFont("Arial Bold",48);

  
}

void draw() 
{
  background(0);
  lights();
  stroke(255,0,0);
  strokeWeight(5);
  fill(0,255,0);
  incx +=0.01;
  pushMatrix();
  translate(width/2+100, height/2+100,0);
  
  //rotateX(inc);
  //rotateY(inc);
   rotateZ(incx);
 
  box(150);
  popMatrix();
  pushMatrix();
  
  stroke(255, 50);
  translate(200, 200, 0);
  //rotateX(incx);
  rotateY(incx);
  fill(mouseX * 2, 0, 160);
  sphereDetail(30);
  //sphereDetail(mouseX / 4);
  sphere(100);
  //println(frameRate);
  popMatrix();
  
  textFont(font,36);
  // white float frameRate
  fill(255);
  //text(frameRate,20,580);
  // gray int frameRate display:
  fill(200);
  text(int(frameRate),20,580);
  

}




Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s