More boring zooming questions...

Blitz3D Forums/Blitz3D Programming/More boring zooming questions...

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.

This isn't perfect, as it zooms into the corner of the zoom point. The football is on, so i'll maybe see if i can get it working properly.

ARROW keys to move the zoom point. key "1" to zoom in. Key "2" to zoom out.

Graphics3D 800,600
SetBuffer BackBuffer()

Global camera = CreateCamera()
PositionEntity camera,0,0,-10

Global light = CreateLight()


Global zoom_piv = CreateSphere()
ScaleEntity zoom_piv,0.3,0.3,0.3

Global plane = CreatePlane()
TurnEntity plane,-90,0,0

Global plane_texture = CreateTexture(64,64)
SetBuffer TextureBuffer(plane_texture)
Color 128,128,255
Rect 0,0,64,64
Color 64,64,255
Rect 1,1,62,62

SetBuffer BackBuffer()

EntityTexture plane,plane_texture


While Not KeyHit(1)

	If KeyDown(203) Then MoveEntity zoom_piv,-0.1,0,0
	If KeyDown(205) Then MoveEntity zoom_piv,0.1,0,0
	If KeyDown(200) Then MoveEntity zoom_piv,0,0.1,0
	If KeyDown(208) Then MoveEntity zoom_piv,0,-0.1,0
	
	If KeyDown(2) Then
		zoom_in()
	ElseIf KeyDown(3) Then
		zoom_out()
	End If
	
	UpdateWorld
	RenderWorld
	Flip
	
Wend

Function zoom_in()

	PointEntity camera,zoom_piv
	If EntityDistance#(zoom_piv,camera)>1.9 Then
		MoveEntity camera,0,0,EntityDistance#(zoom_piv,camera)/30.0
	End If
	RotateEntity camera,0,0,0
	
End Function

Function zoom_out()

;	PointEntity camera,zoom_piv
	If EntityDistance(zoom_piv,camera)<10 Then
		MoveEntity camera,0,0,-EntityDistance#(zoom_piv,camera)/30.0
	End If
	RotateEntity camera,0,0,0
	
End Function