From Schmid.wiki
Jump to: navigation, search
FAQ Example Requirements Installation Download

FAQ

What is poveruby?

It is a extremely simple framework for using Embedded Ruby (erb) with POV-Ray.

POV-Ray has a built-in scripting language. Why not use it?

Because the scripting language sucks, and Ruby does not.

How do I install poveruby?

?

Example Program

<%  require 'matrix'
    class Vector
        def to_s() "<#{to_a.join ','}>" end
    end %>

#include "colors.inc"

light_source { < -10, 50, 30 >, White }
camera       { location <0,0,10> direction -z up y}
plane        { -y, 4 pigment { color White } }

<% (0..4).each do |y| (0..4).each do |x| %>
    box {
        <%= v = Vector[x*2-4.5, y*2-3, 0.5 ] %>,
        <%= v + Vector[1,1,1] %>
        pigment {
            color <%= %w( Red Green Blue Orange )[y] %>
        }
    }
<% end end %>

Requirements

Installation

Your Poveruby programs are written in .rpov files. Begin them with the code listed below and use Rake for building.

Poveruby Template

Start your .rpov files with the following:

<%  require 'matrix'
    class Vector
        def to_s() "<#{to_a.join ','}>" end
    end %>

Rakefile

Create a Rakefile:

# project settings
# ================
INI = "scene.ini"

require 'rake/clean'

RPOV_FILES      = FileList['*.rpov']
GENERATED_FILES = RPOV_FILES.ext('pov')
CLOBBER.include(GENERATED_FILES)

task :default => :render

task :render => [INI, GENERATED_FILES] do
    output = `povray #{INI} 2>&1`
    output.scan(/File: .*?  Line: .*?$.*?Error:.*?$/m) do |match|
        puts match.gsub(/File: (.*?)  Line: (.*?)$.*?Error:(.*?)$/m,'\1:\2: error: \3')
    end
end

rule '.pov' => ['.rpov'] do |t|
   sh "erb #{t.source} >#{t.name}"
end

Download

  • not available yet.