IrrLua

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
zenaku
Posts: 212
Joined: Tue Jun 07, 2005 11:23 pm

Irrlua Example 8 sample

Post by zenaku »

Here is 08.SpecialFX.lua for irrlua-0.4 (when it comes out)

All comments have been omitted to make the post short.

Code: Select all

function main()

	print("Please press 'y' if you want to use realtime shadows.")
	local shadows = io.read("*line")

	local installPath = "../../../../"

	print("Please select the driver you want for this example:\n" ..
		" (a) Direct3D 9.0c\n (b) Direct3D 8.1\n (c) OpenGL 1.2\n" ..
		" (d) Software Renderer\n (e) NullDevice\n (otherKey) exit\n\n")

	local answer = io.read("*line")
	local driverTypes = {["a"] = irr.video.EDT_DIRECTX9,
						 ["b"] = irr.video.EDT_DIRECTX8,
						 ["c"] = irr.video.EDT_OPENGL,
						 ["d"] = irr.video.EDT_SOFTWARE,
						 ["e"] = irr.video.EDT_NULL }

	local type = driverTypes[answer]
	if type == nil then 
		return 1 
		end 
	
	local device = irr.createDevice(type, irr.core.dimension2d(640, 480), 16, false, (shadows == "y") or (shadows == "yes"))

	if device == nil then
		return 1   -- could not create selected driver.
		end

	local driver = device:getVideoDriver()
	local smgr = device:getSceneManager()
	local mesh = smgr:getMesh(installPath ..  "media/room.3ds");

	smgr:getMeshManipulator():makePlanarTextureMapping(mesh:getMesh(0), 0.004)

	local node = smgr:addAnimatedMeshSceneNode(mesh)
	node:setMaterialTexture(0,	driver:getTexture(installPath .. "media/rockwall.bmp"))
	node:getMaterial(0).EmissiveColor:set(0,0,0,0)

	mesh = smgr:addHillPlaneMesh("myHill",
		irr.core.dimension2df32(20,20),
		irr.core.dimension2d(40,40), nil, 0,
		irr.core.dimension2df32(0,0),
		irr.core.dimension2df32(10,10))

	node = smgr:addWaterSurfaceSceneNode(mesh:getMesh(0), 3, 300, 30)
	node:setPosition(irr.core.vector3d(0,7,0))

	node:setMaterialTexture(0,	driver:getTexture(installPath .. "media/water.jpg"))
	node:setMaterialTexture(1,	driver:getTexture(installPath .. "media/stones.jpg"))

	node:setMaterialType(irr.video.EMT_REFLECTION_2_LAYER)

	node = smgr:addLightSceneNode(nil, irr.core.vector3d(0,0,0), 
		irr.video.SColorf(1.0, 0.6, 0.7, 1.0), 600.0)

	local anim = smgr:createFlyCircleAnimator(irr.core.vector3d(0,150,0),250.0)
	
	node:addAnimator(anim)
	anim:drop()

	node = smgr:addBillboardSceneNode(node, irr.core.dimension2df32(50, 50))
	node:setMaterialFlag(irr.video.EMF_LIGHTING, false)
	node:setMaterialType(irr.video.EMT_TRANSPARENT_ADD_COLOR)
	node:setMaterialTexture(0,	driver:getTexture(installPath .. "media/particlewhite.bmp"))

	local ps = smgr:addParticleSystemSceneNode(false) 
	ps:setPosition(irr.core.vector3d(-70,60,40))
	ps:setScale(irr.core.vector3d(2,2,2))

	ps:setParticleSize(irr.core.dimension2df32(20.0, 20.0))

	local em = ps:createBoxEmitter(
		irr.core.aabbox3d(-7,0,-7,7,1,7), 
		irr.core.vector3d(0.0,0.06,0.0),
		80,100, 
		irr.video.SColor(0,255,255,255), irr.video.SColor(0,255,255,255),
		800,2000)

	ps:setEmitter(em)
	em:drop()

	local paf = ps:createFadeOutParticleAffector()

	ps:addAffector(paf)
	paf:drop()

	ps:setMaterialFlag(irr.video.EMF_LIGHTING, false)
	ps:setMaterialType(irr.video.EMT_TRANSPARENT_ADD_COLOR)
	ps:setMaterialTexture(0, driver:getTexture(installPath .. "media/fire.bmp"))

	mesh = smgr:getMesh(installPath .. "media/faerie.md2")

	local anode = smgr:addAnimatedMeshSceneNode(mesh)
	anode:setPosition(irr.core.vector3d(-50,65,-60))
	anode:setScale(irr.core.vector3d(2,2,2))
	anode:setMD2Animation(irr.scene.EMAT_STAND)
	anode:setMaterialTexture(0, driver:getTexture(installPath .. "media/Faerie5.BMP"))

	anode:addShadowVolumeSceneNode()	
	smgr:setShadowColor(irr.video.SColor(150,0,0,0))

	local camera = smgr:addCameraSceneNodeFPS()
	camera:setPosition(irr.core.vector3d(-50,50,-150))

	device:getCursorControl():setVisible(false)

	local lastFPS = -1

	while device:run() do
	if device:isWindowActive() then
	
		driver:beginScene(true, true, nil)
		smgr:drawAll()
		driver:endScene()

		local fps = driver:getFPS()

		if lastFPS ~= fps then
		  local str = "Irrlicht Engine - SpecialFX example ["
		  str = str .. driver:getName()
		  str = str .. "] FPS:"
		  str = str .. fps

		  device:setWindowCaption(str)
		  lastFPS = fps
		  end
		end
	end

	device:drop()
	
	return 0
	end

main()

Sindwiller
Posts: 4
Joined: Sun Aug 07, 2005 7:16 pm

Post by Sindwiller »

I have an Question.

Im an LUA N00b, so i dont know much about the Language. Is it Possible to execute an Script with a Command from another?

Would the 0.4 Release have an Dev C++ Project of the Interpreter (Application)? If not, i can help, im workin with Dev C++.

And, is it possible to program the Interpreter Application, that the Initializing etc. is in the Application, and only the loading of Models etc. is controlled by Scripts? Actually, can you make the Interpreter like those XML Parsers, that you just most to add the Headers to your Project and start the interpreter with an Command. Like:

Code: Select all

// Getting Files
IrrLua.GetFile("main.lua");

//controle of the Interpreter
if (IrrLua.getfile) nil
then
IrrLua.drop;

// Execute them all!
 IrrLua.ExeAll;

// when it reaches end of File, drop Interpreter
if (IrrLua->endfile("main.lua))
then
IrrLua.drop;
(a little bit Pseudocode....)

mfg, SIndwiller
Guest

Post by Guest »

Is it Possible to execute an Script with a Command from another?
Yes, it's called 'dofile', and it's built into Lua.

Run the interpreter, then just type dofile("01.HelloWorld.lua").


Each example defines a function called main() and then runs it at the very bottom of the script. You could call that function MyFunc() instead of main() and then *not* call it at the end. Then, when you do dofile("myfunc.lua"), nothing will happen, but now you have a function called MyFunc(). This way you can define a bunch of functions and load them at runtime when you need them.


I highly recommend the book Programming in Lua, freely available online here

Would the 0.4 Release have an Dev C++ Project of the Interpreter (Application)? If not, i can help, im workin with Dev C++
I wasn't planning on it this release. If you want to create a Dev-C++ project, you'll need to create a project that runs tolua++ on IrrLua.pkg and then compiles the output file into IrrLua.dll. The linux makefile will probably be useful to look at if you're interested. Sorry, I figured most people using a non-free OS would be using a non-free compiler too. Maybe in the next release after 0.4 :)

The majority of the work revolves around cleaning up the irrlicht header files for tolua++ to process (mostly done), and then writing lua scripts to wrap the raw functions (~ 20% done). These wrappers mostly are just shifting types between lua types and irrlicht types. There isn't a lot of c++ work left to do. It's all lua wrapper functions from here until 1.0. If you look at one of the package files, you'll see the c++ declarations at the top, then the wrapper code at the bottom.
zenaku
Posts: 212
Joined: Tue Jun 07, 2005 11:23 pm

IrrLua 0.4 released

Post by zenaku »

IrrLua 0.4 has been released. http://irrlua.sourceforge.net

Updates:
The first 9 examples now work.
irrlicht-0.11.0 support
roughly 25% of the irrlicht api now has proper wrappers and around 80% of the irrlicht api is already imported in a raw format.


---
zen
etcaptor
Posts: 871
Joined: Fri Apr 09, 2004 10:32 pm
Location: Valhalla
Contact:

Post by etcaptor »

@zenaku, do you still working on this great feature?
ImageImage
Site development -Rock and metal online
--- etcaptor.com ------freenetlife.com
Guest

Post by Guest »

a question:

i dont know much about lua, but if this is more advanced and has a few customizations would it be possible to "script" a whole game (without compiling) ?
elander
Posts: 193
Joined: Tue Oct 05, 2004 11:37 am

Post by elander »

Talking about docs is there any way i can list all the commands available in IrrLua ? Like Python dir or something ?
zenaku
Posts: 212
Joined: Tue Jun 07, 2005 11:23 pm

Post by zenaku »

Hmm.

Code: Select all


function dumptable(t) 
    for i,v in pairs(t) do 
         if type(v) == "table" then 
            dumptable(v) 
         end 
    print(i,v) 
    end 
end

dumptable(irr)

If you want to look at the source, you can get a pretty good idea of whats available by looking at the file "pkg/IrrLua.pkg".


Sorry I haven't had any docs/updates recently. I've kind of been waiting for Niko to release a 0.13 so I don't have to update twice (0.11 -> 0.12 -> 0.13). Also, I quit my job, so I've been pre-occupied with doing things that actually bring money :).

I *have* been working on it, however.

Features so far:

- First 14 examples now work.
- Fixed the known memory leaks and garbage collection issues.
- Updated to tolua++-1.0.6
- Seperated IrrLua, Lua, and tolua++ in the project to allow sharing different lua binary modules. You can now, for example, use IrrLua with wxLua.
- Added an IrrLua module. You now have to do a ' require "IrrLua" ' to use IrrLua.
- Example 14 (Win32Window) has been alterered to use the wxLua interpreter. This way, you can render Irrlicht to a wxWidgets window, which should work on linux, btw.
- Speed improvements in the wrappers. s32 and f32 are now native lua_Numbers.




TODO for 0.5 -

- Finish porting the 'demo'
- Update to 0.12/0.13 depending on whats available
- Make sure everything still works on Linux :)

I'm also having an issue getting the low level shaders to work in example 10. The HLSL stuff works OK, however.
zenaku
Posts: 212
Joined: Tue Jun 07, 2005 11:23 pm

Post by zenaku »

GFXstyLER wrote:a question:

i dont know much about lua, but if this is more advanced and has a few customizations would it be possible to "script" a whole game (without compiling) ?
Yes :)

I added an IrrLua module to the dev version (0.5) to make it easier to use IrrLua with other Lua modules. Also, Lua and tolua++ have been seperated so you can mix and match Lua modules with IrrLua.

Other modules similiar to IrrLua can be found here: http://lua-users.org/wiki/LibrariesAndBindings
Guest

Post by Guest »

Wow, this is great! Between IrrLua and Dave's Dusty Engine, I'm in a programmers "hog heaven"!
Also, I quit my job, so I've been pre-occupied with doing things that actually bring money...
heh, funny how needing a make a living gets in the way... :wink:
Hope you find something you like to do and that it pays well. :)

Thanks too for continuing the IrrLua project. 8)
zenaku
Posts: 212
Joined: Tue Jun 07, 2005 11:23 pm

irrlua-0.5 released

Post by zenaku »

irrlua-0.5.0 has been released.

Features:

- Irrlicht-0.14.0 support (required)
- All examples now work (mostly)
- update to tolua++ 1.0.7
- The linux shared libraries don't need to be 'installed' and you don't need to mess with LD_LIBRARY_PATH; they now work more like windows DLLs.
- Shader support is mostly working in DX9
- numerous bugs squashed/memory leaks plugged


Sources and win32 binaries are available at http://irrlua.sourceforge.net
dracflamloc
Posts: 142
Joined: Sat Dec 11, 2004 8:13 am
Contact:

Post by dracflamloc »

thats neat
zenaku
Posts: 212
Joined: Tue Jun 07, 2005 11:23 pm

Post by zenaku »

I've put together some preliminary documentation for IrrLua:

http://irrlua.sourceforge.net/using.html


It's by no means complete, but it's a start! :) The best documentation is still the example programs.

Also, there are now some screenshots of IrrLua running. http://irrlua.sourceforge.net/screenshots.html


---
zenaku
needforhint
Posts: 322
Joined: Tue Aug 30, 2005 10:34 am
Location: slovakia

Post by needforhint »

what is irrlua? :lol:
what is this thing...
Guest

Post by Guest »

how about you read the thread :) ?
Post Reply