Shifty,
Here's a small demo of how I do this ... just replace the texture name with your own as per the norm.
I do use a second camera as this keeps the gui separate from everything else and means you don't have to worry about camerazoom etc.. not that that's a big issue mind.
Hopefully it will resolve you problems ...
Stevie
Graphics3D 640,480,16,1
AmbientLight 255,255,255
Global CAMERA = CreateCamera() , LIGHT = CreateLight()
Global GH = GraphicsHeight()
Global GW = GraphicsWidth()
Global HGW = GW * .5
Global HGH = GH * .5
Global GUIcamera
Global GUIcursor
Global GUIsx#, GUIsy#
;draw some backgound stuff
For l = 0 To 50
entity = CreateCube()
ScaleEntity entity , Rand(1,5), Rand(1,5), Rand(1,5 )
RotateEntity entity , 0, Rand(-180,180 ), 0
EntityColor entity, Rand( 128,255 ), Rand( 128,255 ), Rand( 128,255 )
PositionEntity entity, Rand(-100,100 ), Rand(-100,100 ), Rand(-100,100 )
Next
GUI_Init()
While Not KeyDown(1)
TurnEntity CAMERA, 1, 1, 0
GUI_Position( GUIcursor , MouseX(), MouseY() )
RenderWorld()
Flip
Wend
;===========================================================================
;===========================================================================
;===========================================================================
Function GUI_Init()
GUIcamera = CreateCamera()
CameraClsMode GUIcamera,False,True
CameraRange GUIcamera, .1,5
PositionEntity GUIcamera, 0,0,10000
EntityOrder GUIcamera,-999
;get 3d reso independant scaling
GUIplane = CreatePlane( 1, GUIcamera )
RotateEntity GUIplane, -90,0,0
PositionEntity GUIplane, 0,0,1
EntityPickMode GUIplane, 2
CameraPick ( GUIcamera, 0,0 )
sx# = PickedX()
sy# = PickedY()
CameraPick ( GUIcamera, GW, GH )
GUIsx# = ( PickedX() - sx ) / Float( GW )
GUIsy# = ( sy - PickedY() ) / Float( GH )
FreeEntity GUIplane
;cursor
GUIcursor = GUI_Quad( GUIcamera, 16 , 16 , LoadTexture( "../TrackEditor/Cursor.png", 4 ) , True , 0 , 0 , 1, -1000 )
End Function
;===========================================================================
;===========================================================================
;===========================================================================
Function GUI_Position( Entity , x#, y# )
PositionEntity Entity, ( x - HGW ) * GUIsx , ( HGH - y ) * GUIsy, 0
End Function
;===========================================================================
;===========================================================================
;===========================================================================
Function GUI_Quad( parent , sx#, sy#, Texture , Free = False , ox#=0, oy#=0 , oz# = 1 , order=-998 )
mesh = CreateMesh( parent )
s = CreateSurface( mesh )
For iy = 0 To 1
For ix = 0 To 1
px# = ( ix * sx - ox ) * GUIsx
py# = ( -iy * sy + oy ) * GUIsy
AddVertex s, px, py, oz, ix+.5*(1.0/sx), iy+.5*(1.0/sy )
Next
Next
AddTriangle s, 0,1,3
AddTriangle s, 3,2,0
EntityFX mesh, 1
EntityTexture mesh , Texture
If Free FreeTexture Texture
EntityOrder mesh, order
Return mesh
End Function