'Drag' Scrolling in 3D

Blitz3D Forums/Blitz3D Programming/'Drag' Scrolling in 3D

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Hi,

I never played B&W so I'm not sure if you mean entity or camera movement, here's a camera method, is this right?

Use LMB to drag, and cursors left/right to rotate

Graphics3D 800,600,32,2


piv=CreatePivot()
cam=CreateCamera(piv)

PositionEntity piv,0,8,0
RotateEntity cam,30,0,0

light=CreateLight()
RotateEntity light,30,30,0

plane=CreatePlane()
EntityColor plane,100,200,200

Dim box(200)

box(1)=CreateCube()
ScaleEntity box(1),Rnd(.2,.4),Rnd(1,1.5),Rnd(.2,.4)
EntityColor box(1),Rand(100,255),Rand(100,255),Rand(100,255)

For i=2 To 200
	box(i)=CopyEntity(box(1))
	ScaleEntity box(i),Rnd(.2,.4),Rnd(1,1.5),Rnd(.2,.4)
	EntityColor box(i),Rand(100,255),Rand(100,255),Rand(100,255)
	PositionEntity box(i),Rnd(-50,50),.5,Rnd(-50,50)
Next


While Not KeyDown(1)

	If MouseHit(1) Gosub moveLoop

	If KeyDown(203) TurnEntity piv,0,1,0
	If KeyDown(205) TurnEntity piv,0,-1,0
	
	UpdateWorld
	RenderWorld
	Flip
Wend
End

.moveLoop
	;Clicked X,Y
	cx#=MouseX()
	cy#=MouseY()

	ex#=EntityX#(piv,1)
	ez#=EntityZ#(piv,1)

	sens#=.025
	
	While MouseDown(1)
		mx#=MouseX()-cx
		mz#=MouseY()-cy

		mx=-mx*sens
		mz=mz*sens

		If KeyDown(203) TurnEntity piv,0,1,0
		If KeyDown(205) TurnEntity piv,0,-1,0

		TFormVector mx,0,mz,piv,0

		PositionEntity piv,ex#+TFormedX#(),8,ez#+TFormedZ#()
		UpdateWorld
		RenderWorld
		Flip
	Wend
Return


Tom