Camera Zoom

Blitz3D Forums/Blitz3D Programming/Camera Zoom

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.

Here's what I'm using. ZoomFactor is either 1 or 5. When it's 5, the hit point moves on the screen.
I never move the camera, only angle it. CPV is of type Vector.

Type Vector
Field x#, y#, z#
End Type

Function SetCPV() ; CameraPointingVector

Local length#, temp#

CPV\y# = -Sin(Altitude)
temp# = Cos(Altitude)

CPV\x# = -Sin(Azimuth) * temp#
CPV\z# = Cos(Azimuth) * temp#


length# = Sqr(CPV\x# * CPV\x# + CPV\y# * CPV\y# + CPV\z# * CPV\z#)
CPV\x# = CPV\x# / length
CPV\y# = CPV\y# / length
CPV\z# = CPV\z# / length

AlignToVector(theCamera, 0, 1, 0, 2)
AlignToVector(theCamera, CPV\x#, CPV\y#, CPV\z#, 3)

End Function

;end SetCPV

Function SetZoomFactor(inzoom#)

ZoomFactor# = inzoom
CameraZoom(theCamera, ZoomFactor#)
If inzoom = 1 Then
	ASDActivateSprite(SightSprite, 0)
	ASDActivateSprite(ScopeSprite, 0)
Else
	ASDActivateSprite(SightSprite, 1)
	ASDActivateSprite(ScopeSprite, 1)
	Azimuth# = Azimuth# + Rnd(-2, 2)
	Altitude# = Altitude# + Rnd(-2, 2)
EndIf

End Function

;end SetZoomFactor

Function Shoot()
	
Local tempx#, tempy#, tempz#
tempx# = EntityX(theCamera)
tempy# = EntityY(theCamera)
tempz# = EntityZ(theCamera)
LinePick(tempx#, tempy#, tempz#, tempx# + CPV\x# * 50000, tempy# + CPV\y# * 50000, tempz# + CPV\z# * 50000)
AddSmak(PickedX(), PickedY(), PickedZ())
PlaySound(ShotSound)

BeforeZoomOutFramesLeft = BeforeZoomOutDelay
ReloadFramesLeft = ReloadDelay

End Function

;end Shoot

Function AddSmak(inx#, iny#, inz#)

PositionEntity(Smaks(SmakPointer)\Entity, inx#, iny#, inz#)
ShowEntity(Smaks(SmakPointer)\Entity)
Smaks(SmakPointer)\FramesLeft = 45
Smaks(SmakPointer)\Active = 1
SmakPointer = SmakPointer + 1
If SmakPointer > NumSmaks Then SmakPointer = 1

End Function

;end AddSmak