proof of concept test

BlitzMax Forums/MiniB3D Module/proof of concept test

gman(Posted 2007) [#1]
hey folks. ive been off on a tangent these last few days following a concept i came up with several months ago. the concept was essentially, can the mesh loaders of Irrlicht be used in a generic fashion and made available for use in any 3D engine. here is a proof of concept test. it has a long way to go but the initial results i feel have been very encouraging. if you feel adventurous (and your running windows), please download this, give it a whirl, and report back on FPS and memory usage. FYI... it takes a few seconds to load due to the size of the BSP model its loading. folks familiar with Irrlicht should recognize the models :)

http://www.gprogs.com/irrlicht.mod/2007_01_10_model_loader_example2.zip

the example is using MiniB3D to render the models. the code is :
Strict
Framework BRL.Blitz
Import "minib3d.bmx"
Import Irrlicht.Core
Import "minib3d_meshloader.bmx"
Import BRL.BMPLoader
Import BRL.JPGLoader
Import BRL.PNGLoader

Local width=640,height=480,depth=16,mode=0

Graphics3D width,height,depth,mode

IrrlichtMeshLoader.AddZipFileArchive("map-20kdm2.pk3")
Local ent1:IrrlichtMesh=IrrlichtMeshLoader.LoadMesh("20kdm2.bsp").CreateMesh()
PositionEntity ent1,-1370,-130,-1400

Local ent2:IrrlichtMesh=IrrlichtMeshLoader.LoadMesh("dwarf.x").CreateMesh()
PositionEntity ent2,-70,0,-90
ent2.setFramesPerSec(15)

Local ent3:IrrlichtMesh=IrrlichtMeshLoader.LoadMesh("sydney.md2").CreateMesh()
PositionEntity ent3,-20,0,-60
entitytexture(ent3,loadtexture("sydney.bmp"))
ent3.setFramesPerSec(70)

Local ent4:IrrlichtMesh=IrrlichtMeshLoader.LoadMesh("faerie.md2").CreateMesh()
PositionEntity ent4,-70,0,-30
entitytexture(ent4,loadtexture("faerie2.bmp"))

Local ent5:IrrlichtMesh=IrrlichtMeshLoader.LoadMesh("faerie.md2").CreateMesh()
PositionEntity ent5,-70,0,-45
entitytexture(ent5,loadtexture("faerie2.bmp"))
ent5.setFramesPerSec(55)

Local ent6:IrrlichtMesh=IrrlichtMeshLoader.LoadMesh("faerie.md2").CreateMesh()
PositionEntity ent6,-70,0,-60
entitytexture(ent6,loadtexture("faerie2.bmp"))
ent6.setFramesPerSec(70)

Local ent7:IrrlichtMesh=IrrlichtMeshLoader.LoadMesh("faerie.md2").CreateMesh()
PositionEntity ent7,-70,0,-75
entitytexture(ent7,loadtexture("faerie2.bmp"))
ent7.setFramesPerSec(95)

Local ent8:IrrlichtMesh=IrrlichtMeshLoader.LoadMesh("bird.b3d").CreateMesh()
PositionEntity ent8,-30,20,-90
ent8.setFramesPerSec(2000)

Local cam:TCamera=CreateCamera()
Local light:TLight=CreateLight()
PositionEntity cam,-100,50,-150

' used by camera code
Local mxs#=0
Local mys#=0
Local move#=2.0
MouseXSpeed() ' flush
MouseYSpeed() ' flush

' used by fps code
Local old_ms=MilliSecs()
Local renders
Local fps
Local anim_time#=0
Local memory:Int=GCMemAlloced()

While Not KeyDown(KEY_ESCAPE)		

	If KeyHit(KEY_ENTER) Then DebugStop

	'' control camera
	
	' mouse look
	
	mxs#=mxs#+(MouseXSpeed()/5.0)
	mys#=mys#+(MouseYSpeed()/5.0)

	RotateEntity cam,mys#,-mxs#,0

	MoveMouse width/2,height/2
	MouseXSpeed() ' flush
	MouseYSpeed() ' flush

	' move camera forwards/backwards/left/right with cursor keys
	
	If KeyDown(KEY_UP)=True Then MoveEntity cam,0,0,move# ' move camera forward
	If KeyDown(KEY_DOWN)=True Then MoveEntity cam,0,0,-move# ' move camera back

	If KeyDown(KEY_LEFT)=True Then MoveEntity cam,-move#,0,0 ' move camera left
	If KeyDown(KEY_RIGHT)=True Then MoveEntity cam,move#,0,0 ' move camera right
	
	''
	'SetAnimTime(mesh_list[0],anim_time#)

	RenderWorld
	renders=renders+1
	
	' calculate fps
	If MilliSecs()-old_ms>=1000
		old_ms=MilliSecs()
		fps=renders
		renders=0
		memory=GCMemAlloced()
	EndIf
	
	IrrlichtMeshLoader.UpdateWorld()
	
	DebugText 0,0,"FPS: "+String(fps)
	DebugText 0,20,"Mem: "+memory

	Flip

Wend
End



klepto2(Posted 2007) [#2]
FPS: Constant 60
MEM: ~2400000

That's awesome. Works really good. Is there a way of getting rid with the dll (for crossplatform) and what fileformats does
Irrlicht support?


Pax(Posted 2007) [#3]
Hi

FPS: 60
MEM: 2380000 to 2700000

Klepto, the 3d formats supported in irrlicht in ver 1.2 are:


    * 3D Studio meshes (.3ds)
    * B3D files (.b3d)
    * Alias Wavefront Maya (.obj)
    * Cartography shop 4 (.csm)
    * COLLADA (.xml, .dae)
    * DeleD (.dmf)
    * FSRad oct (.oct)
    * Irrlicht scenes (.irr)
    * Microsoft DirectX (.x) (binary & text)
    * Milkshape (.ms3d)
    * My3DTools 3 (.my3D)
    * OGRE meshes (.mesh)
    * Pulsar LMTools (.lmts)
    * Quake 3 levels (.bsp)
    * Quake 2 models (.md2)


Thanks for your efforts Gman.


gman(Posted 2007) [#4]
good to hear some success thank you for trying it out :)

@klepto2 - it is crossplatform currently via the Irrlicht mod. the DLL i provided is a UPX'd version of the stock v1.2 Irrlicht DLL and the Irrlicht mod is being used to access it. the ultimate goal is to strip the DX and OGL rendering components of Irrlicht to make a relatively small footprint for all OS.

@Pax - thx for posting the formats :) the only one of those listed that will probably not fly is the .irr files. these load actual scenenodes in Irrlicht and im not sure im going to have that type of access.

i think its important to note that im working from the exposed mesh interface in Irrlicht which for any one format may not be as detailed, full-featured, or efficient as an implementation written in BMAX for MiniB3D. .x files for example, i cant get the frames used per named animation. you can still access all the animations by frame #, just some of the niceties built-in to the model format are lost. for more simple models i think this is really going to be groovy. its the more complex scene-level type models that are still a huge grey area.

items remaining:

- convert SMaterial properties to TBrush
- implement joints
- improve animation mechanism/options (will resemble AnimateMD2() command in B3D)
- improve cleanup
- figure out process to build a small-footprint

after the first 4 i will release it to the public.

thanks again for trying it out :)


Barbapapa(Posted 2007) [#5]
FPS: 55
MEM: 2400000 to 3000000

I tried IrrEdit 0.6, it's not bad, would it be possible to use it as import/export medium. I'm also waiting for the new Ogre Export-Plugin for XSI 6, because IrrEdit load Ogre-Meshes.


Mikele(Posted 2007) [#6]
fps: 60
mem: 2375000 - 3210000

gman>
Can your wrapper load and animate skinned b3d?


simonh(Posted 2007) [#7]
Nice work gman.


slenkar(Posted 2007) [#8]
fps:9
mem:2300000-3000000

good stuff


gman(Posted 2007) [#9]
thx for the compliments :) i just uploaded a slightly modified demo. this one has the B3D bird model in it as ywell.

@Mikele - im not sure. the Irrlicht B3D loader does state that it animates skin. as long as the gentlemen that wrote it implemented that into the frame reading interface then yes it should handle it. you can download the example2 above and rename one of your models as the bird model and give it a whirl.

@Slunkar - what are your system specs?


impixi(Posted 2007) [#10]
FPS: 60
Mem; Fluctuates between 2,390,000 and 3,061,000

256MB ATI Radeon X800GT (Catalyst 6.11 drivers, NOT the latest)

With the following notes:

“Could not find texture in Q3 .bsp:…” errors.
“Performance warning, slow unlock of non power of 2 texture.” warnings.

The animated models are not aligned to the ground.

In any case, good work, gman.


Luke.H(Posted 2007) [#11]
Mikele,


Can your wrapper load and animate skinned b3d?



Yes,

Just make sure that the weights are normalised (most meshes are), 1.2 doesn’t normalise weights, the next version (in the SVN now) does.

Note the loader scales the animation frames by 100, this is a hack of mine to get perfectly smooth animations, so times all frames you pass to it by 100.


slenkar(Posted 2007) [#12]
sorry,

600Mhz 128MB of ram intel integrated graphics,
not capable of hardware transform and lighting


Filax(Posted 2007) [#13]
I get 60 FPS on a GEForce 6600 GT + Athlon XP 2.9G


degac(Posted 2007) [#14]
60 Fps

Athlon64 3500, Geforce 6600gt