3d Mouse Control

Blitz3D Forums/Blitz3D Beginners Area/3d Mouse Control

This is how I started, this is really really ugly and simple, and just places a few things. Can I readjust the x/y/z picks any better?

Graphics3D 800,600,0,2
SetBuffer BackBuffer()

ClsColor 0,0,255
camera=CreateCamera()
PositionEntity camera,0,5,-1
RotateEntity camera,45,0,0
CameraClsColor camera,0,0,128
light=CreateLight()
RotateEntity light,90,0,0
PositionEntity light, 0,0,0
light2=CreateLight()
PositionEntity light,0,50,0
plane=CreateTerrain(128)
PositionEntity plane,-64,0,0
EntityPickMode plane,2 
ground_tex=LoadTexture("c:\gridtex2.bmp")
EntityTexture plane,ground_tex
cube=CreateCube()
cube_tex=LoadTexture("c:\gridtex.bmp")
FitMesh cube,1,0,1,1,.1,1
EntityTexture cube,cube_tex 
PositionEntity cube,0,.1,0
EntityAlpha plane,.1
EntityParent light,cube 
LightMesh CUBE,255,0,0
Const game=1
Const menu=2
image=LoadImage("c:\menua.bmp")
image2=LoadImage("c:\fileimage.bmp")

Dim mObject(3)
mObject(1)=CreateCube()
mObject(2)=CreateSphere()
mObject(3)=CreateCone()
For x=1 To 3 Step 1
FitMesh mobject(x),1,1,1,1,1,1
Next

HideEntity mObject(1)
HideEntity mObject(2)
HideEntity mObject(3)
mtype=1
obj$="cube"
curr_level=-1
EntityParent camera,plane
While Not KeyDown( 1 )
If KeyHit(208)=True Then
MoveEntity plane,0,-1,0
MoveEntity cube,0,-1,0
curr_level=curr_level-1
EndIf
If KeyHit(200)=True Then
MoveEntity plane,0,1,0
MoveEntity cube,0,1,0
curr_level=curr_level+1
EndIf

status=game
If KeyDown( 205 )=True Then TurnEntity camera,0,-1,0
If KeyDown( 203 )=True Then TurnEntity camera,0,1,0
If KeyDown( 208 )=True Then MoveEntity camera,0,0,-0.05
If KeyDown( 200 )=True Then MoveEntity camera,0,0,0.05
newx=MouseX()
newy=MouseY()
If newy<100  status=menu
;a=0
;If newx>oldx+5 Then a=1
;If newx<oldx-5 Then a=1
;If newy<oldy-5 Then a=1
;If newy>oldy+5 Then a=1
;oldx=newx
;oldy=newy
;If a=1
;If MouseHit(1) Then
If status=menu Then
If MouseHit(1) Then
Select True
Case newx<100
	mtype=1
	obj$="cube"
Case newx>100 And newx<320
	mtype=2
	obj$="sphere"
Case newx>320
	mtype=3
	obj$="cone"
End Select
EndIf
EndIf

If status=game Then
CameraPick(camera,MouseX(),MouseY())
x1=Int(PickedX#()-1.25)
y1=Int(PickedY#())
z1=Int(PickedZ#()-1.5)
PositionEntity cube,x1,y1,z1
If MouseHit(1) Then
entity=CopyEntity(mObject(mtype))
UpdateNormals entity
PositionEntity entity,x1,curr_level,z1
EndIf
EndIf
Cls
UpdateNormals cube
RenderWorld
DrawImage image,0,0
DrawImage image2,0,0
Text 10,50,"Current object: "+obj$
Flip
Delay 100
Wend
 
ClearWorld()
End