Problems with type fields

BlitzMax Forums/BlitzMax Programming/Problems with type fields

Ok, I seem to be having a weird problem here. I'm trying to encapsulate the IrrBMAX commands into helper functions to make it a little easier. Problem is that one of the fields keep changing to null for no apparent reason.
Strict
Import gg.irrBMAX

Type T_I3D
 Field device:T_irrIrrlichtDevice
 Field driver:T_irrIVideoDriver
 Field smgr:T_irrISceneManager
 Field guienv:T_irrIGUIEnvironment


 Method Graphics3D:Int(width:Int, height:Int, BPP:Int = 16, WindowMode:Int = False, ..
                         VSync:Int = False,Driver = EDT_OPENGL,Shadow:Int = False)

  device = T_irrIrrlichtDevice.create(Driver,T_irrDimension2d_s32.create(Width,Height), ..
                                   BPP,WindowMode,Shadow,VSync)
  If device = Null Then Return False
DebugLog("Graphics3D device "+(device<>Null))
  driver = device.getVideoDriver()
DebugLog("Graphics3D driver "+(driver<>Null))
  smgr = device.getSceneManager()
DebugLog("Graphics3D smgr "+(smgr<>Null))
  guienv = device.getGUIEnvironment()
DebugLog("Graphics3D guienv "+(guienv<>Null))
  Return True
 End Method

 Method SetCaption(cap:String)
  device.setWindowCaption(cap)
 End Method

 Method BeginScene(red:Int,green:Int,blue:Int,alpha:Int = 0)
  driver.beginScene(True,True,T_irrSColor.createFromVals(0,200,200,200))
 End Method

 Method EndScene()
  driver.endScene()
 End Method

 Method RenderAll()
  smgr.drawAll()
  guienv.drawAll()
 End Method

 Method Run:Int()
  Return Device.Run()
 End Method

 Method EndGraphics3D()
  device.drop()
 End Method

End Type

Local I3D:T_I3D = New T_I3D
I3D.Graphics3D(640,480,32)
DebugLog ("Main device "+(I3D.device <> Null))
DebugLog ("main driver "+(I3D.driver <> Null))
DebugLog ("Main smgr "+(I3D.smgr <> Null))
DebugLog ("Main guienv "+(I3D.guienv <> Null))

I3D.SetCaption("Test App")

While (I3D.Run())
 I3D.BeginScene(200,200,200)
 I3D.RenderAll()
 I3D.EndScene()
Wend

I3D.EndGraphics3D()

So why does driver become null after exiting the Graphics3D method, but device, smgr, and guienv do not?
I even tried using Global fields and Functions and calling them directly, but same problem there as well.

greetings TomToad :) just a guess, but try changing the parameter "Driver" to something else like graphics_driver.
Method Graphics3D:Int(width:Int, height:Int, BPP:Int = 16, WindowMode:Int = False, ..
                         VSync:Int = False,graphics_driver = EDT_OPENGL,Shadow:Int = False)

i think its getting confused trying to determine which "Driver" variable you meant to store it to.

also, if you are interested i already have a project going called gg.IrrB3D whose goal is replicate the B3D command set using the Irrlicht wrappers. i am always open to anyone helping if you feel like pooling resources.

if it helps you along, here is the engine Type (your T_I3D) for gg.IrrB3D so far.

Type ib3d_engine

	Field screenRect:T_irrRect_s32=Null
	Field clsColor:T_irrSColor=Null
	Field bClsBackBuffer:Int=True
	Field bClsZBuffer:Int=True
	Field device:T_irrIrrlichtDevice=Null
	Field smgr:T_irrISceneManager=Null
	Field driver:T_irrIVideoDriver=Null
	Field guienv:T_irrIGUIEnvironment=Null
	Field recv:ib3d_EventReceiver=Null
		
	Method New()
		_g_ib3d_engine=Self
	EndMethod
	
	Method Graphics3D:Int(width:Int,height:Int,depth:Int=16,mode:Int=0,stencilBufferShadows:Int=True,vsync:Int=False,deviceType:Int=EDT_OPENGL)
		Local fullscreen:Int=True
	
		Select mode
			Case 0
				' TODO: fix
				'?Debug
					fullscreen=False
				'?
				'	fullscreen=True
			Case 1
				fullscreen=True
			Case 2
				fullscreen=False
			Case 3
				fullscreen=False			
		EndSelect
	
		device=T_irrIrrlichtDevice.create(deviceType,T_irrDimension2d_s32.create(width,height),depth,fullscreen,stencilBufferShadows,vsync,0)
		
		' get references to the components of Irrlicht
		If device Then driver=device.getVideoDriver()
		If device Then smgr=device.getSceneManager()
		If device Then guienv=device.getGUIEnvironment()
		If device Then
			recv=ib3d_EventReceiver(T_irrIEventReceiver.create(ib3d_EventReceiver.generate))
			device.setEventReceiver(recv)
		EndIf
		If driver Then screenRect=T_irrRect_s32.createFromVals(0,0,driver.getScreenSize().getWidth(),driver.getScreenSize().getHeight())
		If device Then Self.setClsColor()
		
		Return (device<>Null)
	EndMethod

	Method OnEvent(event:T_irrSEvent)
		Return False
	EndMethod
	
	Method EndGraphics()
		If Not driver Or Not driver.IsValid() Then Throw "Graphics have not yet been initialized"
		
		' TODO: loop through all lists and destroy
		
		device.CloseDevice()
		device.drop()		
		recv=Null
		screenRect=Null
		clsColor=Null
		guienv=Null
		smgr=Null
		driver=Null
		device=Null
	EndMethod
			
	' TODO: NOTE showGUI parameter
	Method RenderWorld(showGUI:Int=False,tween:Float=1)
		If Not driver Or Not driver.IsValid() Then Throw "Graphics have not yet been initialized"
		
		' make sure the window is active
		If (device.run() And device.isWindowActive())
		
			' set the initial viewport to fullscreen
			driver.setViewPort(screenRect)
			
			' start the scene			
			driver.beginScene(bClsBackBuffer,bClsZBuffer,clsColor)
			
			If CAMERA.CameraList<>Null And smgr And smgr.IsValid()
				For Local camera:CAMERA=EachIn CAMERA.CameraList 
					If camera._node.IsVisible()
						camera.updateCam() ' update where the camera is looking 
						' apply any fog settings for the camera
						camera.applyFog()
						smgr.setActiveCamera(camera._cam)
						driver.setViewPort(camera._viewport)
						
						Local near:Float,far:Float
						
						' adjust based on zoom level if needed
						If (camera._zoom<>1.0)
							near=camera._cam.getNearValue()
							far=camera._cam.getFarValue()
							camera._cam.setNearValue(near*camera._zoom)
							camera._cam.setFarValue(far*camera._zoom)
						EndIf
						
						smgr.drawAll()
						
						' set the near/far back to normal
						If (camera._zoom<>1.0)
							camera._cam.setNearValue(near)
							camera._cam.setFarValue(far)
						EndIf						
					EndIf
				Next
			EndIf
			
			If showGUI And guienv And guienv.IsValid() Then guienv.drawAll()
			
			driver.endScene()
			Delta.Update()
		EndIf
	EndMethod
	
	Method UpdateWorld(anim_speed:Float=1.0)
		_g_ib3d_collision_manager.detectCollisions()
	EndMethod
	
	' ----------------------------------------------------------
	' CAMERA
	' ----------------------------------------------------------

	Method generateCamera:CAMERA()
		Return New CAMERA
	EndMethod
	
	Method createCamera:CAMERA(parent:ib3d_Entity=Null,camType:Int=CT_NORMAL)
		Local retval:CAMERA=generateCamera()
		retval._type=camType
				
		If camType=CT_FPS
			retval.setNode(smgr.addCameraSceneNodeFPS())
		ElseIf camType=CT_MAYA
			retval.setNode(smgr.addCameraSceneNodeMaya())
		ElseIf camType=CT_NORMAL
			retval.setNode(smgr.addCameraSceneNode())
		Else
			retval.setNode(smgr.addCameraSceneNode())		
		EndIf
		
		' set the parent if passed
		If parent Then retval._node.setParent(parent._node)
		
		' default to full window viewport
		retval.setViewportToScreen()
		' default near/far
		retval.setRange()

		Return retval
	EndMethod
	
	Method SetClsColor(r:Int=0,g:Int=0,b:Int=0)
		clsColor=T_irrSColor.createFromVals(0,r,g,b)
	EndMethod
	
	Method setClsMode(bBackBuffer:Int=True,bZBuffer:Int=True)
		bClsBackBuffer=bBackBuffer
		bClsZBuffer=bZBuffer
	EndMethod

	' ----------------------------------------------------------
	' LIGHT
	' ----------------------------------------------------------

	Method generateLight:LIGHT()
		Return New LIGHT
	EndMethod
	
	' TODO: NOTE lack of parameter
	Method createLight:LIGHT(parent:ib3d_Entity=Null)
		Local retval:LIGHT=generateLight()
		
		retval.setNode(smgr.addLightSceneNode())
		' set the parent if passed
		If parent Then retval._node.setParent(parent._node)
		Return retval
	EndMethod

	' ----------------------------------------------------------
	' TEXTURE
	' ----------------------------------------------------------

	Method generateTexture:TEXTURE()
		Return New TEXTURE
	EndMethod
	
	Method loadTexture:TEXTURE(file:String)
		Local retval:TEXTURE=generateTexture()
		
		retval.tex=driver.getTexture(file)
		Return retval		
	EndMethod

	' ----------------------------------------------------------
	' MESH
	' ----------------------------------------------------------

	Method generateMesh:MESH()
		Return New MESH
	EndMethod
	
	Method loadAnimMesh:MESH(file:String,parent:ib3d_Entity=Null)
		Local retval:MESH=generateMesh()
		retval._mesh=smgr.getMesh(file)
		If Not retval._mesh Or Not retval._mesh.IsValid() Then RuntimeError "Unable to load mesh: "+file
		
		retval.setNode(smgr.addAnimatedMeshSceneNode(T_irrIAnimatedMesh(retval._mesh)))
		
		If parent Then retval._node.setParent(parent._node)
		
		Return retval		
	EndMethod
				
	Method loadMesh:MESH(file:String,parent:ib3d_Entity=Null)
		Local retval:MESH=generateMesh()
		retval._mesh=smgr.getMesh(file)
		If Not retval._mesh Or Not retval._mesh.IsValid() Then RuntimeError "Unable to load mesh: "+file
		
		retval.setNode(smgr.addMeshSceneNode(T_IrrIAnimatedMesh(retval._mesh).getMesh(0)))
		
		If parent Then retval._node.setParent(parent._node)
		
		Return retval		
	EndMethod

	Method loadOctTreeMesh:MESH(file:String,parent:ib3d_Entity=Null)
		Local retval:MESH=generateMesh()
		retval._mesh=smgr.getMesh(file)
		If Not retval._mesh Or Not retval._mesh.IsValid() Then RuntimeError "Unable to load mesh: "+file
		
		retval.setNode(smgr.addOctTreeSceneNode(T_irrIAnimatedMesh(retval._mesh).getMesh(0)))
		
		If parent Then retval._node.setParent(parent._node)
		
		Return retval		
	EndMethod

	Method createMesh:MESH(parent:ib3d_Entity=Null)
		Local retval:MESH=generateMesh()
		retval._mesh=T_irrSMesh.create()
		If Not retval._mesh Or Not retval._mesh.IsValid() Then RuntimeError "Unable to create mesh"
		
		retval.setNode(smgr.addMeshSceneNode(T_irrSMesh(retval._mesh)))
		
		If parent Then retval._node.setParent(parent._node)  ' set the parent if there is one
		
		Return retval
	EndMethod

	Method generateSurface:SURFACE()
		Return New SURFACE
	EndMethod
			
	Method createSurface:SURFACE(mesh:MESH,surface_type:Int=SF_NORMAL)
		If Not mesh._mesh Or Not mesh._mesh.isValid() Then RuntimeError "Mesh is invalid"
		If Not T_irrSMesh(mesh._mesh) Then RuntimeError "Mesh is not editable"
		Local retval:SURFACE=generateSurface()
		If surface_type=SF_LIGHTMAP
			retval._mbuf=T_irrSMeshBufferLightMap.create()
		ElseIf surface_type=SF_TANGENTS
			retval._mbuf=T_irrSMeshBufferTangents.create()
		Else
			retval._mbuf=T_irrSMeshBuffer.create()
		EndIf
		
		' add this new buffer to the passed mesh
		T_irrSMesh(mesh._mesh).addMeshBuffer(retval._mbuf)
		
		Return retval
	EndMethod
	
	' ----------------------------------------------------------
	' INPUT
	' ----------------------------------------------------------

	Method KeyHit:Int(scancode:Int,bClear:Int=True)
		If Not recv Then Return 0
		Return recv.KeyHitCnt(scancode,bClear)
	EndMethod
				
	Method KeyDown:Int(scancode:Int)
		If recv Then Return recv.IsKeyDown(scancode) Else Return False
	EndMethod

    	Method setShadowColor(alpha:Int,red:Int,green:Int,blue:Int)
    		smgr.setShadowColor(T_irrSColor.createFromVals(alpha,red,green,blue))
    	EndMethod

	' ----------------------------------------------------------
	' PIVOT
	' ----------------------------------------------------------

	Method generatePivot:PIVOT()
		Return New PIVOT
	EndMethod
	
	Method createPivot:PIVOT(parent:ib3d_Entity=Null)
		Local retval:PIVOT=generatePivot()
		retval.setNode(smgr.addEmptySceneNode())
		
		If parent Then retval._node.setParent(parent._node)
		
		Return retval		
	EndMethod
		
	' ----------------------------------------------------------
	' PLANE
	' ----------------------------------------------------------

	Method generatePlane:PLANE()
		Return New PLANE
	EndMethod
	
	Method createPlane:PLANE(tileSizeX:Float,tileSizeY:Float,tileCountX:Int,tileCountY:Int,parent:ib3d_Entity=Null)
		Local retval:PLANE=generatePlane()
		
		retval._mesh=smgr.addHillPlaneMesh("hillplanemesh_"+PLANE.PlaneList.Count(),T_irrDimension2d_f32.create(tileSizeX,tileSizeY),T_irrDimension2d_s32.create(tileCountX,tileCountY))
		If Not retval._mesh Then RuntimeError "Unable to create HillPlaneMesh"
		retval.setNode(smgr.addAnimatedMeshSceneNode(T_irrIAnimatedMesh(retval._mesh)))

		If parent Then retval._node.setParent(parent._node)

		Return retval		
	EndMethod

	Method addZipFileArchive:Int(file:String,bIgnoreCase:Int=True,bIgnorePaths:Int=True)
		device.getFileSystem().addZipFileArchive(file,bIgnoreCase,bIgnorePaths)
	EndMethod

	' ----------------------------------------------------------
	' TERRAIN
	' ----------------------------------------------------------

	Method generateTerrain:TERRAIN()
		Return New TERRAIN
	EndMethod

	Method loadTerrain:TERRAIN(file:String,parent:ib3d_Entity=Null)
		Local retval:TERRAIN=generateTerrain()
		
		retval.setNode(smgr.addTerrainSceneNodeFromFile(file))
		
		If parent Then retval._node.setParent(parent._node)
		
		Return retval		
	EndMethod

	' ----------------------------------------------------------
	' BRUSH
	' ----------------------------------------------------------

	Method generateBrush:BRUSH()
		Return New BRUSH
	EndMethod			
	
	Method createBrush:BRUSH(red:Float=255,green:Float=255,blue:Float=255)
		Local retval:BRUSH=generateBrush()
		Local color:T_irrSColor=T_irrSColor.createFromVals(0,red,green,blue)
		Local colorf:T_irrSColorf=T_irrSColorf.createFromSColor(color)
		
		retval._material=T_irrSMaterial.create()
		retval._material.getDiffuseColor().set(colorf.getAlpha(),colorf.getRed(),colorf.getGreen(),colorf.getBlue())
    		retval._material.getAmbientColor().set(colorf.getAlpha(),colorf.getRed(),colorf.getGreen(),colorf.getBlue())
		
		Return retval
	EndMethod

	Method loadBrush:BRUSH(texture_file:String)
		Local retval:BRUSH=createBrush()
		ib3d_BrushTexture(retval,ib3d_LoadTexture(texture_file))
		Return retval
	EndMethod
		
EndType


Ack! You're right. Isn't strict suppose to catch things like that? I was going bonkers trying to track that down and I didn't realize I use the same name twice.

As far as the B3D thing goes, I was aiming more at keeping the flexibility of the IrrLicht, but wrap the commands so that they're easier to call. Instead of T_irrDimension2d_s32.create(width,height) and such stuff that makes the calls a little difficult.

ETA: While we're on the subject, do you know how the custom importer is suppose to work? I've been thinking about creating an importer that'll allow me to import .b3d files.


Isn't strict suppose to catch things like that?


you would think :) the reason it compiles in this case (i believe) is because you can store objects to integers.

As far as the B3D thing goes, I was aiming more at keeping the flexibility of the IrrLicht, but wrap the commands so that they're easier to call.


i think we are on similar targets. im taking the approach of many of the BRL BMAX modules where they have functions that can do many things, but underneath they are actually calling type methods. while i have a B3D function set, all the functions really do are call methods on types. you would never actually need to call a single ib3d function if you so desired. plus, all the underlying functionality is still there (ie. the entity stores the T_irrISceneNode reference, ib3d_engine stores references to all its corrosponding T_irr types) and you can call Irrlicht commands direct any time. for example, here is my entity Type of which all the ib3d entities are based:

Type ib3d_Entity Extends ib3d_base

	' maps a b3d entity to an ISceneNode
	Global SceneNodeToEntity:THashtable=Null
	Global EntityList:TList=Null

	Field _userdata:TMap=Null
	Field _node:T_irrISceneNode=Null
	Field _radius:T_irrVector3df=Null
	Field _collision_offset:T_irrVector3df=T_irrVector3df.create()
	Field _lastposition:T_irrVector3df=Null
	Field _OnCollision:ONCOLLISIONEVENTHANDLER=Null
			
	Method New()
		' setup the ISceneNode to b3d_entity map
		If Not SceneNodeToEntity Then SceneNodeToEntity=New THashtable
		If Not EntityList Then EntityList=New TList
		EntityList.AddLast(Self)
	EndMethod

	Method Destroy()
		SceneNodeToEntity.RemoveKey(_node.handle)
		EntityList.Remove(Self)
		
		If _userdata Then _userdata.Clear()
		
		' remove from the scene graph
		_node.Remove()
		_node=Null
	EndMethod

	Method setNode(node:T_irrISceneNode)
		If Not node.IsValid() Then RuntimeError "setNode is invalid"
		SceneNodeToEntity.Add(node.handle,Self,True)
		_node=node
		
		' set the initial collision radius based on the bounding box extents/2
		Local boxextent:T_irrVector3df=_node.getBoundingBox().getExtent()
		setCollisionRadius(boxextent.getX()/2,boxextent.getY()/2,boxextent.getZ()/2)		
	EndMethod
	
	Function findEntity:ib3d_entity(node:T_irrISceneNode)
		If Not node Or Not node.IsValid() Then Return Null
		Local temp:TKeyValuePair=SceneNodeToEntity.ContainsKey(node.handle)
		If Not temp Return Null Else Return ib3d_entity(temp.Value)
	EndFunction

	' ----------------------------------------------
	' userdata methods
	' ----------------------------------------------
	
	Method setUserData(key:String,data:Object)
		If Not _userdata Then _userdata=New TMap
		_userdata.Insert(key,data)
	EndMethod
	
	Method getUserData:Object(key:String)
		If _userdata Then Return _userdata.ValueForKey(key) Else Return Null
	EndMethod
	
	Method removeUserData(key:String)
		If _userdata Then _userdata.Remove(key)
	EndMethod		

	' ----------------------------------------------
	' collision support methods
	' ----------------------------------------------
	
	Method setCollisionOffset(offset:T_irrVector3df)
		_collision_offset=offset
	EndMethod
	
	Method setCollisionRadius(x:Float,y:Float,z:Float)
		_radius=T_irrVector3df.createFromVals(x,y,z)
	EndMethod
	
	Method setCollisionRadiusFromBox(box:T_irrAABbox3df)
		Local boxextent:T_irrVector3df=box.getExtent()
		setCollisionRadius(boxextent.getX()/2,boxextent.getY()/2,boxextent.getZ()/2)		
	EndMethod

	Method getCollisionRadius:T_irrVector3df()
		Return _radius
	EndMethod
	
	Method setOnCollisionEventHandler(handler:ONCOLLISIONEVENTHANDLER)
		_OnCollision=handler
	EndMethod
	
	Method OnCollision(collision:COLLISION)
		If _OnCollision Then _OnCollision.OnCollision(collision)
	EndMethod
	
	Method setLastPosition(pos:T_irrVector3df=Null)
		If Not _node Or Not _node.isValid() Then RuntimeError "Node is invalid"
		If Not pos Then _lastposition=_node.getPosition() Else _lastposition=pos
	EndMethod
	
	Method getLastPosition:T_irrVector3df()
		Return _lastposition
	EndMethod
	
	' ---------------------------------------------------------------
	' B3D methods
	' ---------------------------------------------------------------
			
	Method X:Float(globl:Int=False)
		If Not _node Or Not _node.isValid() Then RuntimeError "Node is invalid"
		If (globl=False)
			Return _node.getPosition().getX()
		Else
			Return _node.getAbsolutePosition().getX()
		EndIf
	EndMethod

	Method Y:Float(globl:Int=False)
		If Not _node Or Not _node.isValid() Then RuntimeError "Node is invalid"
		If (globl=False)
			Return _node.getPosition().getY()
		Else
			Return _node.getAbsolutePosition().getY()
		EndIf
	EndMethod

	Method Z:Float(globl:Int=False)
		If Not _node Or Not _node.isValid() Then RuntimeError "Node is invalid"
		If (globl=False)
			Return _node.getPosition().getZ()
		Else
			Return _node.getAbsolutePosition().getZ()
		EndIf
	EndMethod

	Method Pitch:Float(globl:Int=False)
		If Not _node Or Not _node.isValid() Then RuntimeError "Node is invalid"
		If (globl=False)
			Return _node.getRotation().getX()
		Else
			Return _node.getAbsoluteTransformation().getRotationDegrees().getX()
		EndIf
	EndMethod

	Method Yaw:Float(globl:Int=False)
		If Not _node Or Not _node.isValid() Then RuntimeError "Node is invalid"
		If (globl=False)
			Return _node.getRotation().getY()
		Else
			Return _node.getAbsoluteTransformation().getRotationDegrees().getY()
		EndIf
	EndMethod

	Method Roll:Float(globl:Int=False)
		If Not _node Or Not _node.isValid() Then RuntimeError "Node is invalid"
		If (globl=False)
			Return _node.getRotation().getZ()
		Else
			Return _node.getAbsoluteTransformation().getRotationDegrees().getZ()
		EndIf
	EndMethod
	
	Method Scale(x:Float,y:Float,z:Float)
		If Not _node Or Not _node.isValid() Then RuntimeError "Node is invalid"
		_node.setScale(T_irrVector3df.createFromVals(x,y,z))
	EndMethod
	
	Method Show()
		If Not _node Or Not _node.isValid() Then RuntimeError "Node is invalid"
		_node.setVisible(True)
	EndMethod
	
	Method Hide()
		If Not _node Or Not _node.isValid() Then RuntimeError "Node is invalid"
		_node.setVisible(False)
	EndMethod

	Method Name(name:String)
		If Not _node Or Not _node.isValid() Then RuntimeError "Node is invalid"
		_node.setName(name)
	EndMethod
	
	Method GetName:String()
		If Not _node Or Not _node.isValid() Then RuntimeError "Node is invalid"
		Return _node.getName()
	EndMethod
	
	' TODO: implement globl param
	Method Parent(parent:ib3d_Entity,globl:Int=True)
		If Not _node Or Not _node.isValid() Then RuntimeError "Node is invalid"
		_node.setParent(parent._node)
	EndMethod
	
	Method GetParent:ib3d_Entity()
		If Not _node Or Not _node.isValid() Then RuntimeError "Node is invalid"
		Return findEntity(_node)
	EndMethod

	Method CountChildren:Int()
		If Not _node Or Not _node.isValid() Then RuntimeError "Node is invalid"
		Return _node.getChildren().Size()
	EndMethod
	
	Method GetChild:ib3d_Entity(index:Int)
		If Not _node Or Not _node.isValid() Then RuntimeError "Node is invalid"
		Local children:T_irrArray_ISceneNode_Ptr=_node.getChildren()
		Local childcnt:Int=children.Size()
		If childcnt<1 Or index>childcnt Then RuntimeError "Child index "+index+" outside of child count "+childcnt
	
		Return findEntity(children.elementAt(index-1))
	EndMethod
	
	Method FindChild:ib3d_Entity(name:String)
		If Not _node Or Not _node.isValid() Then RuntimeError "Node is invalid"
		Local child:T_irrISceneNode=Null
		Local children:T_irrArray_ISceneNode_Ptr=_node.getChildren()
		Local childcnt:Int=children.Size()
		
		If childcnt>0
			Local tempnode:T_irrISceneNode
			For Local i:Int=0 To childcnt-1
				tempnode=children.elementAt(i)
				If tempnode.getName()=name
					child=tempnode
					Exit
				EndIf		
			Next
		EndIf

		If Not child Then Return Null Else Return findEntity(child)
	EndMethod

	' ----------------------------------------------------------------------
	' not sure about the following
	' ----------------------------------------------------------------------

	' TODO: not sure about global
	Method Position(x:Float,y:Float,z:Float,globl:Int=False)
		If Not _node Or Not _node.isValid() Then RuntimeError "Node is invalid"
		_node.setPosition(T_irrVector3df.createFromVals(x,y,z))
	EndMethod
	
	Method Rotate(pitch:Float,yaw:Float,roll:Float,globl:Int=False)
		If Not _node Or Not _node.isValid() Then RuntimeError "Node is invalid"
		_node.setRotation(T_irrVector3df.createFromVals(pitch,yaw,roll))				
	EndMethod
	
	Method Move(x:Float,y:Float,z:Float)
		If Not _node Or Not _node.isValid() Then RuntimeError "Node is invalid"
		If x<>y Then x:*Delta.Time()
		If y<>0 Then y:*Delta.Time()
		If z<>0 Then z:*Delta.Time()
		Local dest:T_irrVector3df=T_irrVector3df.createFromVals(x,y,z)
		_node.getRelativeTransformation().transformVect(dest)
		_node.setPosition(dest)
	EndMethod
	
	Method Turn(pitch:Float,yaw:Float,roll:Float,globl:Int=False)
		If Not _node Or Not _node.isValid() Then RuntimeError "Node is invalid"
		If pitch<>0 Then pitch:*Delta.Time()
		If yaw<>0 Then yaw:*Delta.Time()
		If roll<>0 Then roll:*Delta.Time()
		_node.setRotation(_node.getRotation().Plus(T_irrVector3df.createFromVals(pitch,yaw,roll)))
	EndMethod

	Method Translate(x:Float,y:Float,z:Float)
		If Not _node Or Not _node.isValid() Then RuntimeError "Node is invalid"
		If x<>0 Then x:*Delta.Time()
		If y<>0 Then y:*Delta.Time()
		If z<>0 Then z:*Delta.Time()
		Local m:T_irrMatrix4=T_irrMatrix4.create()
		m.setTranslation(T_irrVector3df.createFromVals(x,y,z))
		Local pos:T_irrVector3df=_node.getPosition()
		m.translateVect(pos)
		_node.setPosition(pos)		
	EndMethod
	
	' TODO: implement
	Method Point(target:ib3d_Entity)
		If Not _node Or Not _node.isValid() Then RuntimeError "Node is invalid"
		PointToVect(target._node.getPosition())
	EndMethod
	
	Method PointToVect:T_irrVector3df(target:T_irrVector3df)
		Rem
		Local diff:T_irrVector3df=_node.getPosition().Minus(target)
		Local dist:Float=Sqr((diff.getX()*diff.getX())+(diff.getZ()*diff.getZ()))
		Local pitch:Float=ATan2(diff.getY(),dist)
		Local yaw:Float=ATan2(diff.getX(),-diff.getZ())		
		Rotate(pitch,yaw,0)
		EndRem
		
		Local pos:T_irrVector3df=_node.getPosition()
		Local xdiff:Float=target.getX()-pos.getX()
		Local ydiff:Float=target.getY()-pos.getY()
		Local zdiff:Float=target.getZ()-pos.getZ()
		Local dist:Float=Sqr((xdiff*xdiff)+(zdiff*zdiff))
		Local pitch:Float=ATan2(ydiff,dist)
		Local yaw:Float=ATan2(xdiff,-zdiff)
		Rotate(pitch,yaw,0)

		
		Rem
		xdiff# = EntityX(entity)-x#
		ydiff# = EntityY(entity)-y#
		zdiff# = EntityZ(entity)-z#
		dist#=Sqr#((xdiff#*xdiff#)+(zdiff#*zdiff#))
		pitch# = ATan2(ydiff#,dist#)
		yaw#   = ATan2(xdiff#,-zdiff#)
		RotateEntity entity,pitch#,yaw#,0
		EndRem		
	EndMethod
	
	' TODO: note index only support 0,1
	' TODO: implement animated texture support
	Method setTexture(texture:TEXTURE,frame:Int=0,index:Int=0)
		If Not _node Or Not _node.isValid() Then RuntimeError "Node is invalid"
		_node.setMaterialTexture(index,texture.tex)
	EndMethod
	
	Method setDebugDataVisible(bShow:Int)
		If Not _node Or Not _node.isValid() Then RuntimeError "Node is invalid"
		_node.setDebugDataVisible(bShow)
	EndMethod

    	Method SetColor(red:Float,green:Float,blue:Float,MaterialIDX:Int=0)
		If Not _node Or Not _node.isValid() Then RuntimeError "Node is invalid"
		Local color:T_irrSColor=T_irrSColor.createFromVals(0,red,green,blue)
		Local colorf:T_irrSColorf=T_irrSColorf.createFromSColor(color)
		
		_node.getMaterial(MaterialIDX).getDiffuseColor().set(colorf.getAlpha(),colorf.getRed(),colorf.getGreen(),colorf.getBlue())
    		_node.getMaterial(MaterialIDX).getAmbientColor().set(colorf.getAlpha(),colorf.getRed(),colorf.getGreen(),colorf.getBlue())
    	EndMethod

	Method setAmbientColor(red:Float,green:Float,blue:Float,MaterialIDX:Int=0)
		If Not _node Or Not _node.isValid() Then RuntimeError "Node is invalid"
		Local color:T_irrSColor=T_irrSColor.createFromVals(0,red,green,blue)
		Local colorf:T_irrSColorf=T_irrSColorf.createFromSColor(color)
		
    		_node.getMaterial(MaterialIDX).getAmbientColor().set(0,colorf.getRed(),colorf.getGreen(),colorf.getBlue())
	EndMethod

	Method setDiffuseColor(red:Float,green:Float,blue:Float,MaterialIDX:Int=0)
		If Not _node Or Not _node.isValid() Then RuntimeError "Node is invalid"
		Local color:T_irrSColor=T_irrSColor.createFromVals(0,red,green,blue)
		Local colorf:T_irrSColorf=T_irrSColorf.createFromSColor(color)
		
    		_node.getMaterial(MaterialIDX).getDiffuseColor().set(0,colorf.getRed(),colorf.getGreen(),colorf.getBlue())
	EndMethod
	
	Method setEmissiveColor(red:Float,green:Float,blue:Float,MaterialIDX:Int=0)
		If Not _node Or Not _node.isValid() Then RuntimeError "Node is invalid"
		Local color:T_irrSColor=T_irrSColor.createFromVals(0,red,green,blue)
		Local colorf:T_irrSColorf=T_irrSColorf.createFromSColor(color)
		
    		_node.getMaterial(MaterialIDX).getEmissiveColor().set(0,colorf.getRed(),colorf.getGreen(),colorf.getBlue())
	EndMethod

	Method setSpecularColor(red:Float,green:Float,blue:Float,MaterialIDX:Int=0)
		If Not _node Or Not _node.isValid() Then RuntimeError "Node is invalid"
		Local color:T_irrSColor=T_irrSColor.createFromVals(0,red,green,blue)
		Local colorf:T_irrSColorf=T_irrSColorf.createFromSColor(color)
		
    		_node.getMaterial(MaterialIDX).getSpecularColor().set(0,colorf.getRed(),colorf.getGreen(),colorf.getBlue())
	EndMethod														

	Method setFX(E_MATERIAL_FLAG:Int,bNewVal:Int,MaterialIDX:Int=-1)
		If Not _node Or Not _node.isValid() Then RuntimeError "Node is invalid"
		If MaterialIDX>=0 Then
			_node.setMaterialFlag(E_MATERIAL_FLAG,bNewVal)
		Else
			_node.getMaterial(MaterialIDX).setFlag(E_MATERIAL_FLAG,bNewVal)
		EndIf
	EndMethod

	Method SetBlend(E_MATERIAL_TYPE:Int,MaterialIDX:Int=-1)
		If Not _node Or Not _node.isValid() Then RuntimeError "Node is invalid"
		If MaterialIDX>=0 Then
			_node.setMaterialType(E_MATERIAL_TYPE)
		Else
			_node.getMaterial(MaterialIDX).setMaterialType(E_MATERIAL_TYPE)
		EndIf
	EndMethod

	Method setShininess(shininess:Float=20.0,MaterialIDX:Int=0)
		If Not _node Or Not _node.isValid() Then RuntimeError "Node is invalid"
		_node.getMaterial(MaterialIDX).setShininess(shininess)
	EndMethod
	
	Method getDistanceFrom:Double(entity:ib3d_Entity)
		If Not _node Or Not _node.isValid() Then RuntimeError "Node is invalid"
		If Not entity._node Or Not entity._node.isValid() Then RuntimeError "Distance node is invalid"
		Return _node.getPosition().getDistanceFrom(entity._node.getPosition())
	EndMethod
												
EndType


do you know how the custom importer is suppose to work?


you will need to extend type T_irrIMeshLoader type. override isALoadableFileExtension() and return true if you can load the file passed in. override the createMesh method. this method must return an instance of T_irrIAnimatedMesh. there is no way to actually _create_ T_irrIAnimatedMesh, but that is what T_irrSAnimatedMesh is for. so you essentially return an instance of T_irrSAnimatedMesh. you then create an instance of your new type and then pass it to the AddExternalMeshLoader() method of T_irrISceneManager.

HTH :)