It has been positively ages since I last posted any ruby-processing sketches here is one processing library that you might like to experiment with it is the Hemesh library by Frederik Vanhoutte aka W:Blut. Over on my other blog I have been describing the development of my latest processing library "povwriter" a tool for exporting processing sketches to the povray format and this is one of the sketches I have used. Next I will attempt to get my "povwriter" library working in ruby processing.
# RandomCage.rb is a processing sketch that shows
# how you can use the Hemesh library in Ruby-Processing.
class RandomCage < Processing::App
load_libraries 'hemesh', 'opengl'
include_package 'wblut.hemesh'
include_package 'wblut.hemesh.creators'
include_package 'wblut.hemesh.iterators'
include_package 'wblut.hemesh.modifiers'
include_package 'wblut.hemesh.subdividors'
import "processing.opengl"
full_screen
TWO_PI = Math::PI * 2
attr_reader :cage
def setup
configure_opengl
@cage = HE_Mesh.new(HEC_Box.new(self).set_depth(height/2).set_height(height/2).set_width(height/2))
@cage.modify(HEM_ChamferCorners.new.set_distance(height*0.1))
#HES_Planar() subdivision can include a measure of randomness
@cage.subdivide(HES_Planar.new.set_random(true).set_range(0.4),2)
#A save choice after introducing any kind of randomness is to triangulate possible concave faces.
#Concave faces do not invalidate the mesh but can give unexpected results.
@cage.triangulate_concave_faces()
@cage.modify(HEM_Lattice.new.set_depth(0.016*height).set_width(0.016*height).set_fuse(true))
sel = HE_Selection.new
for f in cage.f_itr # using ruby syntax here
sel.add f
end
cage.subdivide_selected(HES_CatmullClark.new(),sel,2)
end
def draw
background(120)
lights
translate(width/2, height/2)
rotate_y(mouse_x * 1.0 / width * TWO_PI - Math::PI)
rotate_x(mouse_y * 1.0 / height * TWO_PI - Math::PI)
fill(255)
no_stroke
cage.draw_faces
stroke(0)
cage.draw_edges
end
def configure_opengl
render_mode OPENGL
hint ENABLE_OPENGL_4X_SMOOTH # optional
hint DISABLE_OPENGL_ERROR_REPORT # optional
end
end
Here is my blog in which I will describe my experiments with ruby-processing, find out more about ruby-processing at:- http://wiki.github.com/jashkenas/ruby-processing and http://github.com/jashkenas/context_free for the cfdg DSL (context-free-art)
Monday, 2 May 2011
Subscribe to:
Post Comments (Atom)
Blog Archive
-
►
2010
(73)
-
►
September
(15)
- Basic Hair Example SunflowAPIAPI just using jruby
- Basic Hair Example SunflowAPIAPI in ruby processin...
- SunflowAPIAPI in ruby processing
- A Staffordshire Knot Using Ruby Processing and A C...
- An Infinity Loop? With My 3D Context Free Library
- Revised 3D Context Free DSL Sketch, with Mouse Whe...
- A Mouse Wheel Listener in Ruby Processing
- 3D Context Free DSL Screen Saver?
- Translating the default.es to ruby processing DSL
- Testing the cube primitive in my context free DSL
- Experimental 3D Context Free DSL in ruby-processin...
- Using the control panel and Toxi Processing Libra...
- Tone map example of Gray-Scott diffusion using tox...
- Another Example of Using Toxi Processing Libraries...
- Using the Toxi Processing Libraries in ruby proces...
-
►
June
(6)
- Cesàro fractal using ruby processing context free ...
- Exploring Dynamic Randomness in ruby-processing co...
- Towards an Escher Bird Tiling (Ruby processing con...
- Weird Flower Ruby Processing Context Free DSL
- Alhambra Tiling Ruby Processing Context Free DSL
- Red Dwarf (Ruby Processing Context Free DSL)
-
►
September
(15)
About Me
- monkstone
- Consolidating my online identity as monkstone. I am a 64 bit linux user and advocate of open source software, you can sometimes find me on the processing forum.

0 comments:
Post a Comment