• Advertisement

Archived

This topic is now archived and is closed to further replies.

Zoom in 3rd person camera

This topic is 5257 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! In a game with 3rd person camera perspective where the camera can rotate around always targeting the character... How is the zoom implemented? Scaling the scene or moving the camera nearer of far away the character? Will the result be diferent? Thanks!

Share this post


Link to post
Share on other sites
Advertisement
A solid way to keep the camera on a player is to use the LookAt functions of your API. OpenGL provides a glLookAt() and DirectX has a D3DXMATRIXLookAtFovLH() or RH() if you are using a right-handed coordinate system. Just use some Cos / Sin functions to rotate around the player''s point.

Zoom is set using the Field of View (Fov). Notice that I chose D3DXMATRIXLookAtFovLH() instead of any other LookAt functions for DirectX. If you change the FoV, you change the zoom.

You can also achieve some neat looking things like in Lord of the Rings: The Fellowship...After the hobbits all meet and fall down the hill, Frodo suggests everyone get off the road...then the camera''s FoV widens and the camera moves forward. It gives a neat result.

I guess if you wanted something like a sniper rifle''s zoom, you would move the camera closer too.

Also ...just for the sake of being on topic, our 3d math really doesn''t allow for focusing. If you want focusing effects, you will be working with the pixel shader.

I hope this helped.

Share this post


Link to post
Share on other sites

Hi, thanks for your reply!

I''ve tested the FoV and it zoomed ok for a certain range... but than there is a distortion just like when moving the camera nearer.

When changing the FoV do i need to change the "aspect"? Btw, i''m using OpenGL... and the efect i''m looking for is the Never Winter Nights, dont know about LotR.

Thank again!

Share this post


Link to post
Share on other sites
I don''t know how Neverwinter nights works but the simplest way to zoom would be to simply move the camera closer to the player it is focusing on. USe some simple trigonometry to change the position in gluLookAt();

Changing the FOV resembles more closely how real world camera''s work but it gives distortions under a certain range. When I played QuakeII a looong time ago I had keybindings to my custom zoom function that simply changed the FOV to 30 degrees and it looked pretty distorted. It works okay if the camera doesn''t move (like when you''re snipering) but in motion the distortion look and feels a lot worse.

Sander Maréchal
[Lone Wolves Game Development][RoboBlast][Articles][GD Emporium][Webdesign][E-mail]


GSACP: GameDev Society Against Crap Posting
To join: Put these lines in your signature and don''t post crap!

Share this post


Link to post
Share on other sites
Zooming is like a 1st person camera. What i mean is that you move the camera forward along the view direction INCLUDING the y-axis. Moving using a 1st person camera does not alter the y-axis.

Share this post


Link to post
Share on other sites

  • Advertisement