Ruby binding
Ruby binding
I tinkered a little with embedding ruby and thought well why not try with irrlicht.
this is a really basic start with just a few function to get something on screen. The code is actually not that nice to read. Could be cleaned up and the bindings could be done via templates. But yeah this was actually just a proof of concept idea. And it really surprised me how easy it is to bind ruby to c++.
here is the code.
(you will need irrlicht and ruby to compile it)
Download
this is a really basic start with just a few function to get something on screen. The code is actually not that nice to read. Could be cleaned up and the bindings could be done via templates. But yeah this was actually just a proof of concept idea. And it really surprised me how easy it is to bind ruby to c++.
here is the code.
(you will need irrlicht and ruby to compile it)
Download
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
Re: Ruby binding
what do you guys think would be better. Having a gem that allows the usage of irrlicht in ruby, or having only a binding lib. so one can push irrlicht objects to ruby and perform actions?
Edit: or do you think ruby is just a stupid idea for a 3d engine
Edit: or do you think ruby is just a stupid idea for a 3d engine
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
Re: Ruby binding
I'm pretty much a beginner in Ruby (I spend last ~3 weeks on it for coding some SketchUp Plugin). The cool stuff there was that you don't need too much coding knowledge to be able to modify stuff. So if you write tools where you want a lot of people to be able to contribute then such a script language is very useful. The not so cool stuff was ruby speed - it's been a constant hassle to get anything done without serious pauses when working with a larger 3d scene. So just from that experience I can tell that what I had wished for most in the last weeks would have been more wrapper functions in SketchUp written in a native language like c/c++ which I could have called from Ruby. Stuff like collect all Entities (like SceneNodes in Irrlicht) with a single call instead of having to do a slow recursive function in ruby.
So - it's definitely useful, but when working with Ruby it seems you have to really care about speed a lot. Otherwise ... well, let's just say I'm right now learning to use the c-api in SketchUp for my next task and going to switch to using that.
So - it's definitely useful, but when working with Ruby it seems you have to really care about speed a lot. Otherwise ... well, let's just say I'm right now learning to use the c-api in SketchUp for my next task and going to switch to using that.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: Ruby binding
well what did you do in ruby that was so slow? vertex manipulation?
i would basicly write a wrapper for irrlicht "user" features and maybe also animators
that would allow you to use irrlicht. but obviously not extend it.
i would basicly write a wrapper for irrlicht "user" features and maybe also animators
that would allow you to use irrlicht. but obviously not extend it.
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
Re: Ruby binding
I really don't know if I can blame Ruby - or should blame myself or maybe Sketchup in that case. Guess I'm just too much used to c++ speeds ;-)
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
-
- Competition winner
- Posts: 687
- Joined: Mon Sep 10, 2012 8:51 am
Re: Ruby binding
I think the wrapper idea sounds good, although maybe the Ruby community might rather have a gem (maybe???). Can't say I personally enjoy the language of Ruby (personal preferences on things are different), but I'm sure someone might like it.
Have fun making it!
Have fun making it!
-
- Competition winner
- Posts: 687
- Joined: Mon Sep 10, 2012 8:51 am
Re: Ruby binding
It probably is being used to C-speeds. However, I do recall running a demo in Panda3D (Python 3D library) and being surprised that it ran in real time. The demo was of a character running through hills, and his arms and legs were animated. It wasn't a very detailed hill or character, but at the time, it was surprising, especially since the library was written entirely (I believe) in Python. Some of the speed can be explained by taking into account that Python converts frequently used files to a binary format.CuteAlien wrote:I really don't know if I can blame Ruby - or should blame myself or maybe Sketchup in that case. Guess I'm just too much used to c++ speeds
The potential speed will depend entirely on Sudi's implementation. All I can say to that end is that most of the work should be left in C++ and maybe give Ruby calls for primarily changing settings and loading files.
Re: Ruby binding
Panda is a C++ lib with python bindings. The app may be fully python.
Re: Ruby binding
Well panda3d is actually written in c++ and Python is used as a wrapper.
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
Re: Ruby binding
ok tutorial 1 is wrapped
nicer looking
nicer looking
Code: Select all
device = IrrlichtDevice.new("opengl", {"width" => 1280, "height" => 720}, 16, false)
device.setWindowCaption("Hello World! - Irrlicht Engine Demo")
gui = device.guienvironment
smgr = device.scenemanager
gui.addStaticText("Hello World! This is the Irrlicht Software renderer!", 10,10,260,22, true)
mesh = smgr.getMesh("media/sydney.md2")
smgr.addAnimatedMeshSceneNode(mesh).setMaterialFlag("lightning", false).setMD2Animation("run").setMaterialTexture(0, "media/sydney.bmp")
smgr.addCameraSceneNodeFPS
while device.run do
device.driver.begin
device.scenemanager.drawAll
gui.drawAll
device.driver.end
end
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
-
- Competition winner
- Posts: 687
- Joined: Mon Sep 10, 2012 8:51 am
Re: Ruby binding
Ah, okay. I didn't know - it's been awhile since looking at it. I guess that determines my answer to your question then. lol.Sudi wrote:Well panda3d is actually written in c++ and Python is used as a wrapper.
Your implementation looks good, but I notice you have mixed case. Are you doing member objects in all lower case and methods as camel case or does it not matter? (I forget if it matters with Ruby - too much time in C++)
Re: Ruby binding
actually when i remember correctly all functions should be lower case seperated by underscore. but yeah i just copy pasted the function names to the wrapper...chronologicaldot wrote: Are you doing member objects in all lower case and methods as camel case or does it not matter? (I forget if it matters with Ruby - too much time in C++)
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
-
- Competition winner
- Posts: 687
- Joined: Mon Sep 10, 2012 8:51 am
Re: Ruby binding
Browsing through the readme doc for irrlicht, I discovered someone had already written a Ruby binding for irrlicht. I thought you might be interested.
http://irr.rubyforge.org/
http://rubyforge.org/projects/irr
It looks like development stopped a long time ago, but the code might be of interest.
http://irr.rubyforge.org/
http://rubyforge.org/projects/irr
It looks like development stopped a long time ago, but the code might be of interest.