Zooming in on a sphere

Blitz3D Forums/Blitz3D Beginners Area/Zooming in on a sphere

Kieran(Posted 2006) [#1]
So I have this code snippet, use the up arrow to zoom in, down arrow to zoom out. But when I zoom in on the spere, there comes a point where from the inside out it starts to disapear, how can I make the camera zoom right in on the spere, so it takes the whole screen without disapearing. Also Obviously for a space game, is using the camera as the space ship, and moving it around like this the way it's done?

Snippet:
Graphics3D 800,600,0,2

SetBuffer BackBuffer()

camera = CreateCamera()
CameraViewport camera,0,0,800,600

light = CreateLight()

cube = CreateSphere(16)
PositionEntity cube,0,0,5

While Not KeyHit(1)

If KeyDown(200) = True Then
MoveEntity camera,0,0,0.01
ElseIf KeyDown(208) = True Then
MoveEntity camera,0,0,-0.01
EndIf

UpdateWorld
RenderWorld

Flip

Wend
End


Baystep Productions(Posted 2006) [#2]
Check out the CameraZoom function in the manual.


AdsAdamJ(Posted 2006) [#3]
Alternatively you might want to check the CameraRange function as well:

CameraRange <cam_name>, .1, 1000

You have the name of the object, the nearest view distance (in this case .1) and the furthest view distance. (1000 units)


Steven Noyce(Posted 2006) [#4]
I think that increasing the camera zoom when the key is pressed is the way to go. It is a realy simple command, so I think you could easily figure it out, but if you need help, post!


Andy(Posted 2006) [#5]
>So I have this code snippet, use the up arrow to zoom in,
>down arrow to zoom out. But when I zoom in on the spere,
>there comes a point where from the inside out it starts to
>disapear


the camera can only see what is inside your camerarange. The camerarange has a near value and a far value. The near value is how far ahead of the camera the rendering will start. The far value is how far ahead the rendering will stop.

What is happening, is that the part of the sphere which is closest to the camera get's too close to the camera, so that part of the sphere is not rendered.

Try adding

CameraRange camera,0.01,1000

What you need to realize is that if part of an entity is outside the the boundary set by Near# and Far#, then that part isn't rendered.


Andy


Steven Noyce(Posted 2006) [#6]
Can the neer value of CameraRange be a negative number so that things behind the camera are rendered?

I don't care that much, it just seemed like an interesting thought.


Baystep Productions(Posted 2006) [#7]
Only One Way to find out.


Kieran(Posted 2006) [#8]
Ahh thanks Andy, that makes sense.


octothorpe(Posted 2006) [#9]
The larger the difference (in powers of two) between the near and far ranges of the camera frustum, the greater the chance of Z-fighting. Because of this, it may be wise to use CameraZoom() for zooming, as PCD GUY suggested.