load_libraries :planetarium, :control_panel include_package 'codeanticode.planetarium' attr_reader :cube_x, :cube_y, :panel, :hide, :camera, :grid def setup # For the time being, only use square windows size(600, 600, Dome::RENDERER) @camera = DomeCamera.new(self) @hide = false @grid = true control_panel do |c| c.title = "Control" c.look_feel "Metal" c.slider :cube_x, -width / 2.0 .. width / 2.0, -60.0 c.slider :cube_y, -height / 2.0 .. height / 2.0, 60.0 @panel = c end end def mouse_pressed @hide = false if hide # use mouse click to restore control panel end # Called five times per frame. def draw unless hide @hide = true panel.set_visible hide end face = camera.getFace case(face) when DomeCamera::POSITIVE_X background(240, 59, 31) when DomeCamera::NEGATIVE_X background(240, 146, 31) when DomeCamera::POSITIVE_Y background(30, 245, 0) when DomeCamera::NEGATIVE_Y background(30, 232, 156) when DomeCamera::POSITIVE_Z background(52, 148, 206) when DomeCamera::NEGATIVE_Z background(183, 115, 13) end push_matrix translate(width/2, height/2, 300) stroke(255) noFill push_matrix translate(cube_x, cube_y, 0) sphere_detail(8) sphere(30) pop_matrix lines_amount = 10 (0 ... lines_amount).each do |i| ratio = i/(lines_amount - 1.0) line(0, 0, cos(ratio * TWO_PI) * 50, sin(ratio * TWO_PI) * 50) end pop_matrix end def key_pressed @grid = !grid (grid)? camera.set_mode(Dome::GRID) : camera.set_mode(Dome::NORMAL) end
Experiments with ruby-processing (processing-2.2.1) and JRubyArt for processing-3.0
Showing posts with label andres colubri. Show all posts
Showing posts with label andres colubri. Show all posts
Monday, 9 September 2013
Planetarium calibrate sketch in ruby-processing
New Improved Planetarium Basic Sketch
That is more like it decent controls, no need for that reflection nonsense. Another example using Andrés Colubri's planetarium library.
# The planetarium library is designed to create real-time projections on # spherical domes. It is based on the FullDome project by Christopher # Warnow (ch.warnow@gmx.de): # https://github.com/mphasize/FullDome # # A brief descrition on how it works: a 360° view of the scene is generated # by rendering the scene 6 times from each direction: positive x, negative x, # positive y, and so on. The output of each rendering is stored inside a cube map # texture, which is then applied on a sphere representing the dome. # Hence, the library calls the draw method 6 times per frame in order to update # the corresponding side of the cube map texture (in reality, only 5 times since # the bottom side of the cube map is not invisible on the dome). # New improved version using control panel no need for reflection "nastiness" load_libraries :planetarium, :control_panel include_package 'codeanticode.planetarium' attr_reader :cube_x, :cube_y, :cube_z, :panel, :hide def setup # For the time being, only use square windows size(600, 600, Dome::RENDERER) @hide = false control_panel do |c| c.title = "Control" c.look_feel "Metal" c.slider :cube_x, -width / 2.0 .. width / 2.0, 10.0 c.slider :cube_y, -height / 2.0 .. height / 2.0, 10.0 c.slider :cube_z, -width / 2.0 .. 0, -20.0 @panel = c end end def mouse_pressed @hide = false if hide # use mouse click to restore control panel end # Called five times per frame. def draw unless hide @hide = true panel.set_visible(hide) end background(0) push_matrix translate(width/2, height/2, 300) lights stroke(0) fill(150) push_matrix translate(cube_x, cube_y, cube_z) box(50) pop_matrix stroke(255) lines_amount = 10 (0 ... lines_amount).each do |i| ratio = i/(lines_amount - 1.0) line(0, 0, cos(ratio * TWO_PI) * 50, sin(ratio * TWO_PI) * 50) end pop_matrix end
Subscribe to:
Posts (Atom)
Followers
About Me
- monkstone
- I have developed JRubyArt and propane new versions of ruby-processing for JRuby-9.1.5.0 and processing-3.2.2

