Experiments with ruby-processing (processing-2.2.1) and JRubyArt for processing-3.0

Thursday 5 May 2011

Exploring modelX in ruby processing


############################
# processing modelX
# examples in ruby processing
###########################


def setup
  size 500, 500, P3D
  no_fill
end

def draw
  background 0
 
  push_matrix
  # start at the middle of the screen
  translate(width/2, height/2, -200)    
  # some pseudo random rotation to make things interesting
  rotate_y 1.0 # yrot
  rotate_z 2.0 # zrot
  # rotate in X a little more each frame
  rotate_x(frame_count / 100.0)
  # offset from center
  translate(0, 150, 0)
 
  # draw a white box outline at (0, 0, 0)
  stroke 255
  box 80
 
  # the box was drawn at (0, 0, 0), store that location
  x = model_x(0, 0, 0)
  y = model_y(0, 0, 0)
  z = model_z(0, 0, 0)
  # clear out all the transformations
  pop_matrix

  # draw another box at the same (x, y, z) coordinate as the other
  push_matrix
  translate(x, y, z)
  stroke(255, 0, 0)
  box 80
  pop_matrix
end

No comments:

Post a Comment

Followers

About Me

My photo
I have developed JRubyArt and propane new versions of ruby-processing for JRuby-9.1.5.0 and processing-3.2.2