gg.IrrBMAX

BlitzMax Forums/BlitzMax Beginners Area/gg.IrrBMAX

DirtBikeDude(Posted 2005) [#1]
I'm trying to load an .x file into gg.IrrBMAX. But when I tryloading a model nothing shows up. I'm a beginner to Blitzmax. I'm really trying to find out about this irrlicht wrapper. I've tried this "Local ship:T_irrIAnimatedMesh = scene.getMesh("media/ship.x")". Then I wanted to set the postions, textures, and a text scene node. I was just modifying the shader sample. Are there any tutorials about the gg.IrrBMAX mod or can someone help me?


Haramanai(Posted 2005) [#2]
pls post your code so i can help. and plus from where you created the .x file


DirtBikeDude(Posted 2005) [#3]
i checked my log and it says "Unknown data object in x file: Header
Unknown data object in mesh in x file: MeshVertexColors". so it could be my .x file.

to make the .x file, i used gamespace and just saved it as an .x file. it's loading in DX9 SDK, soo... it should work.

but here's what i'm working with

'===================================
'-------- Space Game v0.0 --------
'===================================
'copyrite Darrell Eastman.
' *!* make sure you build this example with the "Build GUI App" option turned off

Strict
Framework BRL.Blitz
Import BRL.StandardIO

Import gg.IrrBMAX

Local driverType:Int=EDT_OPENGL

Global device:T_irrIrrlichtDevice= ..
	T_irrIrrlichtDevice.create(driverType,T_irrDimension2d_s32.create(800,600))

If device.handle=0 Then Return ' could Not create selected driver.
Local video:T_irrIVideoDriver=device.getVideoDriver()
Local scene:T_irrISceneManager=device.getSceneManager()
Local gui:T_irrIGUIEnvironment=device.getGUIEnvironment()

' create materials

Local gpu:T_irrIGPUProgrammingServices = video.getGPUProgrammingServices()
Local newMaterialType1:Int = 0
Local newMaterialType2:Int = 0

Local node:T_irrISceneNode = scene.addTestSceneNode(50)
node.setPosition(T_irrVector3df.createFromVals(0,0,0))
node.setMaterialTexture(0, video.getTexture("media/wall.bmp"))
node.setMaterialType(newMaterialType1)

scene.addTextSceneNode(gui.getBuiltInFont(), ..
		"Box 3", ..
		T_irrSColor.createFromVals(255,255,255,255),node)

Local anim:T_irrISceneNodeAnimator = scene.createRotationAnimator( ..
		T_irrVector3df.createFromVals(0,0.3,0))
node.addAnimator(anim)
anim=Null

node = scene.addTestSceneNode(50)
node.setPosition(T_irrVector3df.createFromVals(0,-10,50))
node.setMaterialTexture(0, video.getTexture("media/wall.bmp"))
node.setMaterialType(newMaterialType2)

scene.addTextSceneNode(gui.getBuiltInFont(), ..
		"Box 2", ..
		T_irrSColor.createFromVals(255,255,255,255),node)

anim = scene.createRotationAnimator(T_irrVector3df.createFromVals(0,0.3,0))
node.addAnimator(anim)
anim=Null

node = scene.addTestSceneNode(50)
node.setPosition(T_irrVector3df.createFromVals(0,50,25))
node.setMaterialTexture(0, video.getTexture("media/wall.bmp"))
scene.addTextSceneNode(gui.getBuiltInFont(), "Box 1", ..
	T_irrSColor.createFromVals(255,255,255,255),node)
anim=Null

Rem
Now I'll test a ship model, ship.x. and add an text scene node.

EndRem

Local ship:T_irrIAnimatedMesh = scene.getMesh("media/ship.x")

'ship.setPosition(T_irrVector3df.createFromVals(0, 50, 25))
'ship.setMeterialTexture(0, video.getTexture("media/wall.bmp"))
'scene.addTextSceneNode(gui.getBuiltInFont(), "Ship", ..
'	T_irrSColor.createFromVals(255,255,255,255),ship)

Global thrust:Int = 0
Global retro:Int = 0

Type MyEventReceiver Extends T_irrIEventReceiver

	Method OnEvent:Int(event:T_irrSEvent)

		If (event.getEventType()=EET_KEY_INPUT_EVENT And event.getKeyPressedDown()=True)
			
			Local key:Int=event.getKeyInputKey()
					
			Select key
				Case EKEY_KEY_W
					thrust:Int = 1
					Return True
				Case EKEY_KEY_S
					retro:Int = 1
					Return True
				Default
					Return False
			EndSelect
		Else thrust:Int = 0 And retro:Int = 0
		EndIf

		Return False
	EndMethod

	' we must override the generate function in order for instantiation to work properly
	' must return T_irrIEventReceiver
	Function generate:T_irrIEventReceiver()
		Return T_irrIEventReceiver(New MyEventReceiver)
	EndFunction
EndType

Rem
And last, we add a skybox And a user controlled camera To the scene.
For the skybox textures, we disable mipmap generation, because we don't
need mipmaps on it.
EndRem

' add a nice skybox

scene.addSkyBoxSceneNode( ..
	video.getTexture("media/galaxy_up.bmp"), ..
	video.getTexture("media/galaxy_dn.bmp"), ..
	video.getTexture("media/galaxy_rt.bmp"), ..
	video.getTexture("media/galaxy_lt.bmp"), ..
	video.getTexture("media/galaxy_ft.bmp"), ..
	video.getTexture("media/galaxy_bk.bmp"))

video.setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, True)

Rem
To be able To look at And move around in this scene,
we create a first person shooter style camera And make the
mouse cursor invisible.
EndRem

Local cam:T_irrICameraSceneNode = scene.addCameraSceneNodeFPS(0, 100.0, 100.0)
cam.setPosition(T_irrVector3df.createFromVals(-100,50,100))
cam.setTarget(T_irrVector3df.createFromVals(0,0,0))
device.getCursorControl().setVisible(False)

Local lastFPS:Int = -1
Local fps:Int = 0
Local str:String=""

While(device.run())
	If (device.isWindowActive())

		video.beginScene(True, True, T_irrSColor.createFromVals(255,0,0,0))
		scene.drawAll()
		video.endScene()

		fps = video.getFPS()

		If (lastFPS <> fps) Then
			str$ = "Space Game - Irrlicht ["
			str$ :+ video.getName()
			str$ :+ "] FPS:"
			str$ :+ fps

			device.setWindowCaption(str$)
			lastFPS = fps
		EndIf
		
	EndIf
	
	FlushMem
Wend

device.drop()

copy paste this link and save it for the model.
http://home.comcast.net/~dirtbiker100/Uploads/ship.x

sorry if this looks messed up, i don't know the bb code for these forums.


Haramanai(Posted 2005) [#4]
first of all you have to declare a node for your ship.
You have only The mesh.
the mesh will not be displayed if it isn't attached to a node
write after the line: Local ship:T_irrIAnimatedMesh = scene.getMesh("media/ship.x")
global ShipNode:T_irrIAnimatedMeshSceneNode = scene.addAnimatedMeshSceneNode(ship)

but it's better to read thru the first tutorials.


Haramanai(Posted 2005) [#5]
'Try this

Strict

Framework BRL.Blitz


Import gg.IrrBMAX


Local device:T_irrIrrlichtDevice=T_irrIrrlichtDevice.create(EDT_OPENGL,T_irrDimension2d_s32.create(640,480),16,False,False,False,0)


device.setWindowCaption("Hello World! - Irrlicht Engine Demo")



Local driver:T_irrIVideoDriver=device.getVideoDriver()
Local smgr:T_irrISceneManager=device.getSceneManager()

Local camera:T_irrICameraSceneNode = smgr.addCameraSceneNodeMaya()


Local mesh:T_irrIAnimatedMesh=smgr.getMesh("media/ship.x")
Local node:T_irrIAnimatedMeshSceneNode=smgr.addAnimatedMeshSceneNode(mesh)

If node.handle<>0
node.setMaterialFlag(EMF_LIGHTING,False)
node.setFrameLoop(0,310)
node.setMaterialTexture(0,driver.getTexture("media/wall.bmp"))
EndIf

While (device.run())

Rem
Anything can be drawn between a beginScene() And an endScene()
call. The beginScene clears the screen with a color And also the
depth buffer If wanted. Then we let the Scene Manager And the
GUI Environment draw their content. With the endScene() call
everything is presented on the screen.
EndRem
driver.beginScene(True,True,T_irrSColor.createFromVals(0,200,200,200))

smgr.drawAll()


driver.endScene()

FlushMem
Wend


device.drop()

'And be sure to check the first tutorials


DirtBikeDude(Posted 2005) [#6]
another problem, my gui wont work at the same time as my 3d scene. the gui shows but wont register input. or do i need to set the camera to static and how?
another thing i was trying to do was scale my ship mesh, but i'll look in the tutorials for something.

http://home.comcast.net/~dirtbiker100/Uploads/SpaceGame.zip

thanks


gman(Posted 2005) [#7]

the gui shows but wont register input


you have not hooked up the event receiver. add this line below the if device.handle=0 check:
device.setEventReceiver(T_irrIEventReceiver.create(MyEventReceiver.generate))

to scale your mesh, you have 2 options. you can scale the mesh itself, which will in turn scale all nodes created off it, or you can scale the individual node. to scale the mesh itself (you will need to play with the vector3df values), add the following line after the call to getMesh for the ship:
scene.getMeshManipulator().scaleMesh(ship.getMesh(0),T_irrVector3df.createFromVals(25,25,25))

to scale the individual node use the following code somewhere after you create ShipNode:
ShipNode.setScale(T_irrVector3df.createFromVals(25,25,25))

i would highly recommend downloading or bookmarking the irrlicht documentation. one of the main strengths of the wrapper is that it closely follows the C++ version of the API, making the manual very valuable as a resource.

Irrlicht Online API Docs

you can get the CHM file (i would recommend this) by downloading the Irrlicht SDK.

hope this helps you out :) its always good to see folks using the wrapper :)