3d Mouse Control

Blitz3D Forums/Blitz3D Beginners Area/3d Mouse Control

I figured out why i had to readjust the pick coordinates, fitmesh cube,1,1,1,1,1,1 doesn't exactly work right, sorry about the need for the media. Here try this.

Right Click places a 1x1x1 floor tile, right clicking lets you select how big it is.(doesn't work right if you go down/left though). I only made 1 1 color brush *sniff*.
Graphics3D 800,600,0,1
SetBuffer BackBuffer()
ClsColor 255,0,0
Cls

;brush1=CreateBrush(255,0,0)
brush2=CreateBrush(255,0,0)

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

plane=CreateTerrain(128)
PositionEntity plane,-64,0,0
EntityPickMode plane,2
;PaintEntity plane,brush1

cube=CreateMesh()
surf=CreateSurface(cube)
v1=AddVertex(surf,0,0,0,0,0)
v2=AddVertex(surf,1,0,0,1,0)
v3=AddVertex(surf,1,0,1,1,1)
v4=AddVertex(surf,0,0,1,0,1)
tri=AddTriangle(surf,v4,v3,v1)
tri2=AddTriangle(surf,v3,v2,v1)

PaintEntity cube,brush2
PositionEntity cube,0,.1,0
EntityAlpha plane,.1
EntityParent light,cube 
LightMesh CUBE,255,0,0
obj$="floor"
status=game

sel=0

While Not KeyDown( 1 )
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.0

CameraPick(camera,MouseX(),MouseY())
x1=Int(PickedX#())
y1=Int(PickedY#())
z1=Int(PickedZ#())
PositionEntity cube,x1,curr_level,z1

If sel=1 Then
If x1>oldx xd=oldx-x1
If z1>oldz zd=oldz-z1
ScaleEntity ex,xd,1,zd
PositionEntity ex,x1,curr_level,z1
UpdateNormals(ex)
obj$=oldx+","+oldz+","+newx+","+newz
EndIf

If MouseHit(1) Then
entity=CopyEntity(cube)
PositionEntity entity,x1,curr_level,z1
EndIf

If MouseHit(2) Then
Select True
Case sel=0
	oldx=x1
	oldy=y1
	oldz=z1
	sel=1
	sy=1
	sz=1
	sx=1
	ex=CopyEntity(cube)
	UpdateNormals(ex)
	PositionEntity ex,oldx,curr_level,oldz
	HideEntity cube
	LightMesh ex,255,0,0
Case sel=1
	newx=x1
	newy=y1
	newz=z1
	If newx>oldx xd=newx-oldx
	If newz>oldz zd=newz-oldz
	If newx<1 newx=1
	If newz<1 newz=1
	;entity=CopyEntity(cube)
	;ScaleEntity entity,sx,1,sz
	;PositionEntity entity,oldx,curr_level,oldz
	sel=0
	ShowEntity cube
	End Select
EndIf

Cls
FlushMouse

UpdateNormals cube
RenderWorld
Text 10,50,"Current object: "+obj$
Flip
Delay 100
Wend
 
ClearWorld()
End