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

Thursday, 30 September 2010

SunflowAPIAPI in ruby processing

# sunflow_test.rb

class SunflowTest < Processing::App
  load_libraries :sunflow_api, :sunflow
  include_package 'com.briansteen'
  include_package "org.sunflow.math"
  API = Java::Com::briansteen::SunflowAPIAPI
  SMath = Java::Org::sunflow::math
  WIDTH = 500
  HEIGHT = 500

  def setup
    @sunflow = API.new
    @sunflow.set_camera_position(0, 2.5, -5)
    @sunflow.set_camera_target(0, 0, 0)
    @sunflow.set_thinlens_camera("thinLensCamera", 50, WIDTH/HEIGHT)
    @sunflow.draw_plane("ground", SMath::Point3.new(0,-3.5,0), SMath::Vector3.new(0, 1, 0))
    @sunflow.draw_sphere_flake("mySphereFlake", 20, SMath::Vector3.new(0, 1, 0), 1)
    @sunflow.setPathTracingGIEngine 6
    @sunflow.render "SunflowTestRender.png"

  def draw


SunflowTest.new :title => "Sunflow Test"

This example was copied from amnon, following his recent posting on the processing discussion boards.

Checkout the sunflowapapi source (created by  Christopher Warnow?) as follows:-
svn checkout http://sunflowapiapi.googlecode.com/svn/trunk/ sunflowapiapi-read-only

Get the sunflow libraries here, NB must be version 0.07.3:-


Or possible here for Windows users:-


The usual library setup required compile and jar the sunflowapiapi code into sunflow_api.jar nest that as follows in a folder library, in a folder sunflow_api in the library folder (in the directory where the sketch you want to run is stored). Do similar for the sunflow.jar put the janino.jar in the same folder.  The janino.jar provides a fast java compiler, version is 2.~ is supplied with the sunflow download, however with a few minor modifications sunflow can be updated to use the latest version 2.6.1 (basically include the commons-compiler.jar, and remove a couple of deprecated exception types from the code and  update the CompileException to the commons compiler version org.codehaus.commons.compiler.CompileException, do this in an ide unless you are crazy).

No comments:

Post a Comment


Blog Archive

About Me

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