Global cameraRay:TRay= TRay.createEmpty()
Global normal:TVector4 = TVector4.Create( 0 , 0 , 0 , 0 )
Global result:TVector3 = TVector3.createempty()
Global entity:TEntity
Global cameraquery:TRaySceneQuery
Global omsx:Float
Global omsy:Float
Repeat
Local x:Float=Float(MouseX())/Float(ogre.width)
Local y:Float=Float(MouseY())/Float(ogre.height)
cameranode.yaw((MouseX()-omsx)*.1,ts_local)
cameranode.pitch((MouseY()-omsy)*.1,ts_local)
MoveMouse 640,480
omsx=MouseX()
omsy=MouseY()
mainCamera.getCameraToViewportRay( 0.5,0.5 , cameraRay )
Local Query:Int=-1'EntityType' | tformtype
cameraquery= MainSceneManager.createRayQuery( cameraRay,Query)
entity:TEntity = MainSceneManager.polyPick( cameraQuery , result , normal )
If entity.isNull() = False Then
DebugLog entity.getName()
EndIf
cameraQuery.clearResults()
ogre.renderOneFrame()
Until KeyDown(KEY_ESCAPE)