Camera Zoom

Blitz3D Forums/Blitz3D Programming/Camera Zoom

Almo(Posted 2003) [#1]
Hi!

I'm raytracing along the camera's line of sight, and placing a block where it hits the scenery. It all seems to work. But the block isn't at 320, 240! This seems odd... tracing along the camera's z axis should hit the center of the screen.


Almo(Posted 2003) [#2]
It also appears to depend on the CameraZoom...


Shambler(Posted 2003) [#3]
Are you using EntityPick?

Post a little code to give us a better idea of what you are doing.


Rob(Posted 2003) [#4]
If linepicking, check your coords. If camerapicking, post some example code and we'll pick it apart.


Almo(Posted 2003) [#5]
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




Almo(Posted 2004) [#6]
This is still bugging me... Can't figure out why the aimpoint isn't centered.


Almo(Posted 2004) [#7]
Figured it out.