Example #1 in Boo

Irrlicht.Net is no longer developed or supported, Irrlicht.Net Cross Platform is a much more complete wrapper. Please ask your C# related questions on their forums first.
yazzgoth
Posts: 1
Joined: Sun Oct 02, 2005 4:55 pm
Contact:

Example #1 in Boo

Post by yazzgoth »

Hi, I just thought you may be interested in a 'wrist friendly' language which is Boo ( http://boo.codehaus.org/ )

The Example #1 (Hello World) rewriten in Boo looks like this:

Code: Select all

namespace HelloWorld
import System
import Irrlicht
import Irrlicht.Video
import Irrlicht.Core
import Irrlicht.Scene

[Module]
class Example:
	[STAThread()]
	static def Main(args as (string)):
		device as IrrlichtDevice = IrrlichtDevice(DriverType.OPENGL)
		device.WindowCaption = 'Irrlicht.NET Boo example 01 - Hello World'
		texSydney as ITexture = device.VideoDriver.GetTexture('sydney.bmp')
		mesh as Irrlicht.Scene.IAnimatedMesh = device.SceneManager.GetMesh('sydney.md2')
		cam as ICameraSceneNode = device.SceneManager.AddCameraSceneNodeFPS(null, 100, 100, -1)
		cam.Position = Vector3D(20, 0, -50)
		node as ISceneNode = device.SceneManager.AddAnimatedMeshSceneNode(mesh, null, -1)
		node.SetMaterialTexture(0, texSydney)
		node.SetMaterialFlag(MaterialFlag.LIGHTING, false)
		device.CursorControl.Visible = false
		fps as int = 0
		while device.Run():
			if device.WindowActive:
				device.VideoDriver.BeginScene(true, true, Color(0, 100, 100, 100))
				device.SceneManager.DrawAll()
				device.VideoDriver.EndScene()
				if fps != device.VideoDriver.FPS:
					fps = device.VideoDriver.FPS
					device.WindowCaption = 'Irrlicht.NET Boo example 01 - Hello World [' + device.VideoDriver.Name + '] fps:' + fps
Zaggarish

Post by Zaggarish »

What's with all the casting and stuff?

"device as IrrlichtDevice = IrrlichtDevice(DriverType.OPENGL)"

can be written as "device = IrrlichtDevice(DriverType.OPENGL)" =D

"device.WindowCaption = 'Irrlicht.NET Boo example 01 - Hello World [' + device.VideoDriver.Name + '] fps:' + fps"

device.WindowCaption = "Irrlicht.NET Boo example 01 - Hello World [${device.VideoDriver.Name}] ${fps}"

Here's a quick primer if you're new to Boo =D

http://docs.codehaus.org/display/BOO/Boo+Primer
Guest

Post by Guest »

Zaggarish wrote:What's with all the casting and stuff?
explict is better than implict ;)
Zaggarish wrote:
"device.WindowCaption = 'Irrlicht.NET Boo example 01 - Hello World [' + device.VideoDriver.Name + '] fps:' + fps"

device.WindowCaption = "Irrlicht.NET Boo example 01 - Hello World [${device.VideoDriver.Name}] ${fps}"
I came from Python ;)
Zaggarish

Post by Zaggarish »

Anonymous wrote:
Zaggarish wrote:What's with all the casting and stuff?
explict is better than implict ;)
I'm not sure I understand, can you explain what makes the explicit type declaration better?
Guest

Post by Guest »

let's say you have a polimorphed versions of a object, or a object that can return diffrent types of objects... it's always better to know what you want to achieve, and tell that to compiler rather to assume it will work by itself. Now you can argue with that but it's just a good way of awoiding errors that may be hard to find later on.
Bot_Builder
Posts: 23
Joined: Thu Apr 14, 2005 6:59 pm
Location: Bushland

Post by Bot_Builder »

I use boo now, although I havent used irrlicht in 6 months - a year orso.

anyway, this code looks like you just pooped it through Daniel Grunwald(sp?)'s C# to boo converter. It's using basically none of boo's sexiness.

Untested edit:

Code: Select all

namespace HelloWorld
import System
import Irrlicht
import Irrlicht.Video
import Irrlicht.Core
import Irrlicht.Scene

device = IrrlichtDevice(DriverType.OPENGL, WindowCaption:'Irrlicht.NET Boo example 01 - Hello World')
device.CursorControl.Visible = false
VideoDriver = device.VideoDriver
SceneManager = device.SceneManager

cam = SceneManager.AddCameraSceneNodeFPS(null, 100, 100, -1, Position:Vector3D(20, 0, -50))
node = SceneManager.AddAnimatedMeshSceneNode(SceneManager.GetMesh('sydney.md2'), null, -1)
node.SetMaterialTexture(0, VideoDriver.GetTexture('sydney.bmp'))
node.SetMaterialFlag(MaterialFlag.LIGHTING, false)
fps = 0
while device.Run():
	if device.WindowActive:
		VideoDriver.BeginScene(true, true, Color(0, 100, 100, 100))
		SceneManager.DrawAll()
		VideoDriver.EndScene()
		continue unless fps != VideoDriver.FPS
		fps = VideoDriver.FPS
		device.WindowCaption = "Irrlicht.NET Boo example 01 - Hello World [${VideoDriver.Name}] fps:${fps}"
ImageXP SP2, AMD Athlon 64 3500+, 1GB HyperX RAM, Radeon X700 Pro (PCI-e), 120GB SATA drive :)
Guest

Post by Guest »

never heard of boo before, but it hardly looks any different from vb .net....
ilikepython

Post by ilikepython »

hi,

i tried to do the same (with the necessary modifications) with ironpython 0.9.2 but i always get the message "no module named irrlicht"!

i have the Irrlicht.dll and Irrlicht.NET.dll in my folder.

maybe someone knows what's wrong or what i have to do? i am new to .net.

...
and what's the system module? is this irrlicht related or .net related?
ilikepython

Post by ilikepython »

i have figured it out! you have to do it like that for ironpython:

Code: Select all

import sys
sys.LoadAssemblyFromFile("Irrlicht.NET.dll")

import System
from Irrlicht import *
from Irrlicht.Video import *
from Irrlicht.Core import *
from Irrlicht.Scene import *
but i still can't get the example to really work. only the engine window shows up and then it crashes. it needs some more modifications for ironpython...

but i find it's very cool that any language with support for .net can use irrlicht now! :)
Guest

Post by Guest »

ok, here is the rest:

Code: Select all

import sys
sys.LoadAssemblyFromFile("Irrlicht.NET.dll")

import System
from Irrlicht import *
from Irrlicht.Video import *
from Irrlicht.Core import *
from Irrlicht.Scene import *



device = IrrlichtDevice(DriverType.OPENGL, WindowCaption = "Irrlicht.NET IronPython - example 01 - Hello World")
device.CursorControl.Visible = False
VideoDriver = device.VideoDriver
SceneManager = device.SceneManager



cam = SceneManager.AddCameraSceneNodeFPS(None, 100, 100, -1)
node = SceneManager.AddAnimatedMeshSceneNode(SceneManager.GetMesh("sydney.md2"), None, -1)
node.SetMaterialTexture(0, VideoDriver.GetTexture("sydney.bmp"))
node.SetMaterialFlag(MaterialFlag.LIGHTING, False)



fps = 0
while device.Run():
    if device.WindowActive:
        VideoDriver.BeginScene(True, True, Color(0, 100, 100, 100))
        SceneManager.DrawAll()
        VideoDriver.EndScene()
        if fps != VideoDriver.FPS:
            fps = VideoDriver.FPS
            device.WindowCaption = "Irrlicht.NET IronPython - example 01 - Hello World - [%s] - fps: %d" % (VideoDriver.Name, fps)
now it works and only crashes when i close the engine window. what could be the reason for this? :)
Guest

Post by Guest »

now it works and only crashes when i close the engine window. what could be the reason for this?
Perhaps it's because IronPython is still pre-alpha and has bugs?
Bot_Builder
Posts: 23
Joined: Thu Apr 14, 2005 6:59 pm
Location: Bushland

Post by Bot_Builder »

never heard of boo before, but it hardly looks any different from vb .net....
Clearly you know near-nothing about programming. Well, that's my impression anyway. It looks way more like its inspiration, python. maybe a few VB keywords here and there, but what language doesn't?

Anyway, no you dont ned to do that ironpython crap.

you could do

Code: Select all

import Irrlicht from 'Irrlicht.dll'
import Irrlicht.Video from 'Irrlicht.dll'
import Irrlicht.Core from 'Irrlicht.dll'
import Irrlicht.Scene from 'Irrlicht.dll'
The recommended way, however, on the commandline:

booc example.boo -r:Irrlicht.dll

assuming irrlicht is in path, or the current dir. In nant (xml .net buildfile) you would do:

Code: Select all

<booc name = "Example">
    <sources>
        <include name = "IrrlichtExample.boo">
    </sources>
    <references>
        <include name = "Irrlicht.dll">
    </references>
</booc>
ImageXP SP2, AMD Athlon 64 3500+, 1GB HyperX RAM, Radeon X700 Pro (PCI-e), 120GB SATA drive :)
rektide
Posts: 3
Joined: Sat Dec 03, 2005 12:12 am

Post by rektide »

damn I love boo. its soo concise. nice re-hash, err, Guest...

CLR does not support polymorphing.

Rektide
kapace
Posts: 4
Joined: Tue Nov 14, 2006 4:58 am

Really Good

Post by kapace »

Boo and IronPython are really good,

Irrlicht.NET doesn't work with the lastest version of IronPython i don't think... (it can load the dll using another method,but i can't get it to integrate with the namespace)

Boo is great, its like python but compilable. :D

I never knew what .NET was for, now i understand the power: cross-language portability
kapace
Posts: 4
Joined: Tue Nov 14, 2006 4:58 am

NVM!

Post by kapace »

Wait!

Code: Select all

import sys 
import clr
clr.AddReference("Irrlicht.NET.dll") 

import System 
from Irrlicht import * 
from Irrlicht.Video import * 
from Irrlicht.Core import * 
from Irrlicht.Scene import * 



device = IrrlichtDevice(DriverType.DIRECT3D9, WindowCaption = "Irrlicht.NET IronPython - example 01 - Hello World") 
device.CursorControl.Visible = False 
VideoDriver = device.VideoDriver 
SceneManager = device.SceneManager 



cam = SceneManager.AddCameraSceneNodeFPS(None, 100, 100, -1) 
node = SceneManager.AddAnimatedMeshSceneNode(SceneManager.GetMesh("sydney.md2"), None, -1) 
node.SetMaterialTexture(0, VideoDriver.GetTexture("sydney.bmp")) 
node.SetMaterialFlag(MaterialFlag.LIGHTING, False) 



fps = 0 
while device.Run(): 
    if device.WindowActive: 
        VideoDriver.BeginScene(True, True, Color(0, 100, 100, 100)) 
        SceneManager.DrawAll() 
        VideoDriver.EndScene() 
        if fps != VideoDriver.FPS: 
            fps = VideoDriver.FPS 
            device.WindowCaption = "Irrlicht.NET IronPython - example 01 - Hello World - [%s] - fps: %d" % (VideoDriver.Name, fps)
this works on ironpython 1.01
Locked