Multiple cameras

Blitz3D Forums/Blitz3D Programming/Multiple cameras

Graythe(Posted 2003) [#1]
Hi.

I want to create a tactical camera to show a close up of the entity that is my target. It works just fine when at the same position as the default camera but when I move it closer to the target I get very strange results. Is there a trick to this?


Warren(Posted 2003) [#2]
Define "strange results".


jhocking(Posted 2003) [#3]
Seriously, that's a VERY vague description of your problem. Some sample code would be nice too; without knowing what you are doing there's no way to tell what you are doing wrong. And a more specific description of what you are trying to do would help too; by "a close up" do you mean switching to a close-up view or to showing a close-up image in the corner of the screen?


Graythe(Posted 2003) [#4]
I wanna display a 'close up' in the corner of the screen.

I defined a viewport and created a camera that is a child to the main camera. Then I point it at the entity that I'm targeting and move the camera towards that entity. At this point the tactical camera's display appears `out of sync` as though it were displaying views of the target from differing angles.

I'll see if I can't make some kinda simple code example...


GfK(Posted 2003) [#5]
At this point the tactical camera's display appears `out of sync` as though it were displaying views of the target from differing angles.
That's exactly the result you will get, as the tactical camera is moving as the main camera moves.

Why are you parenting it to the main camera? Surely it should remain close to the target object, so parent it to that if anything??


koekjesbaby(Posted 2003) [#6]
does it have something to do with the near clipping from te camera?

if it does you have to use the camererange command and set the near value to something small(er).

but maybe i'm just totally not understanding what your problem is :)


Graythe(Posted 2003) [#7]
O.k. I've been unable to reproduce the strange effects (possible cause - tweening?) but;

The following example works until I try to reposition the camera (or parent it to some object other than `MainCamera').


Graphics3D 640,480,32,1
MainCamera=CreateCamera()

Target=CreateSphere(8)
PositionEntity Target,0.,0.,5.
TacticalCamera=CreateCamera(MainCamera)

CameraViewport TacticalCamera,GraphicsWidth()-(GraphicsWidth()/3),GraphicsHeight()-(GraphicsHeight()/3),GraphicsWidth()/3,GraphicsHeight()/3

IncVal#=.25:Z#=5

While Not KeyDown(1)

PositionEntity Target,0.,0.,Z
PointEntity TacticalCamera,Target
;MoveEntity TacticalCamera, 0.,0.,EntityDistance(MainCamera,Target)-5.

If Z>150. Or Z<5. Then IncVal=-IncVal

Z=Z+IncVal

RenderWorld
Flip


Wend


DJWoodgate(Posted 2003) [#8]
I feel I must be missing something here, but try

PositionEntity TacticalCamera, 0.,0.,EntityDistance(MainCamera,Target)-5.

instead of

MoveEntity TacticalCamera, 0.,0.,EntityDistance(MainCamera,Target)-5.

Of course that will only work if your main camera is pointing at the target. My guess is you want to allow your main camera to point anywhere but the tactical camera to show the target at a fixed size from the viewpoint of the main camera ?

In which case (assuming TacticalCamera is parented to MainCamera)...

PositionEntity TacticalCamera,0,0,0
PointEntity TacticalCamera,Target
MoveEntity TacticalCamera, 0.,0.,EntityDistance(MainCamera,Target)-5.


Graythe(Posted 2003) [#9]
Doh! I guess I can chalk this up to 'unnecessary motions'.

[edit] almost forgot - thanks! [/edit]