File: ruby-inventor.txt

package info (click to toggle)
pivy 0.6.10-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,216 kB
  • sloc: python: 36,331; cpp: 787; ansic: 733; makefile: 30; sh: 27; objc: 5
file content (87 lines) | stat: -rw-r--r-- 2,457 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
John K. Grytten <johnkeg@pvv.ntnu.no> reported that it is possible to use
Coin3d with Ruby by using pivy.

Pretty cool! :) thx, John!

Here are his instructions:

RubyInventor using Pivy
-----------------------

Yes, you can use Coin with Ruby. And no, you can't just yet install
a nicely wrapped up package with InstallShield for Windows
with everything needed! But if you don't mind using an highly
experimental and creative setup you may get a glimpse of
tomorrows' defacto standard scientific visualization and simulation
environment today(!) Surely it has great potential for prototyping stuff
that can later be implemented as NodeKits etc..

Ok, that's the vision anyway.. now to reality:

Hopefully it will be possible to get rid of the python dependency,
but that'll probably require some substantial work as one would
like to use the latest SWIG versions - but then new low-level
details concerning the Coin include files will probably have
to be sorted out again (a lot can be learned from pivy of course)
and also Ruby specific conversions must be worked out.
The following setup have only been tested on Debian GNU/Linux so far,
but it works ok (try it in irb - Interactive Ruby!).

Now, let's hack it all together in 1-2-3...

First step: install pivy module for Python:
-------------------------------------------
You need this:

pivy from cvs
coin1
soqt cvs
http://prdownloads.sourceforge.net/swig/swig-1.3.13.tar.gz


Install pivy.py, pivy.pyc and pivycmodule.so manually
to /usr/lib/python2.1

Second step: install Ruby/Python extension for Ruby:
----------------------------------------------------
http://www.goto.info.waseda.ac.jp/~fukusima/ruby/python/doc/

Please check that extconf.rb detects the correct
python module directory (you may have more than one python
installation)

Third step: ExaminerViewer in Ruby:
-----------------------------------
#!/usr/bin/env ruby

require 'python'
require 'python/pivy'

py = Py.pivy

myWindow = py.SoQt_init(ARGV[0].to_s)
if myWindow == nil
  raise "could not open window"
end

root = py.SoSeparator.new
root.ref
myMaterial = py.SoMaterial.new

mf = py.SoMFColor.new
mf.setValue(1.0,0.0,1.0)

myMaterial.getField('diffuseColor').copyFrom mf
mf.setValue(1.0,0.0,1.0)

root.addChild(myMaterial)
root.addChild(py.SoCube.new)

myViewer = py.SoQtExaminerViewer.new(myWindow)
myViewer.setSceneGraph(root)
myViewer.setTitle("Examiner Viewer")
myViewer.show

py.SoQt_show(myWindow)
py.SoQt_mainLoop