#1 Members - Reputation: 365
Posted 05 January 2013 - 12:36 PM
#3 Members - Reputation: 365
Posted 05 January 2013 - 02:51 PM
I have the field of view set to "D3DX_PI / 4" by default, how do I change it to add zoom in/out amount so when I call the method Zoom(float amount); I can change the field of view accordingly?
I tried:
camera->fov = (D3DX_PI / 4) + amount;
Not sure if the above is correct, however it cause a problem when amount reach certain number, the camera get up side down.
#5 Members - Reputation: 1842
Posted 05 January 2013 - 03:22 PM
camera->fov = (D3DX_PI / 4) * amount; // amount = 1.0f -> no zoom
#6 Members - Reputation: 365
Posted 07 January 2013 - 12:00 AM
@Paradigm Shifter: What If I want to zoom in more?
Also, I notice two problems when I zoom in till the maximum value:
1. The textures get weird effect
2. The camera can see what is the behind the mesh (like it's penetrating the mesh) which is not realistic.
#7 Moderators - Reputation: 13599
Posted 07 January 2013 - 12:22 AM
Don't treat "D3DX_PI / 4" as some kind of magic number -- Pi/4 radians == 45 degrees.
You can work in degrees to make things more obvious if you want to, e.g.
float regularFov = 45.0f; float sniperFov = 5.0f; camera->fov = DegreesToRadians( isSniping ? sniperFov : regularFov );
#8 Members - Reputation: 365
Posted 07 January 2013 - 12:55 AM
@Hodgman: When zooming, the value shouldn't change suddenly, instead, the zoom should be changing smoothly.
I have the same problems that I mentioned when earlier when I zoom in to the maximum value, I also want to zoom MORE than the maximum value.
#9 Moderators - Reputation: 13599
Posted 07 January 2013 - 01:15 AM
It was just an example of using intuitive values in degrees, you can animate them however you like, e.g.
inline float lerp( float a, float b, float f ) { return b*f + a*(1-f); }
float fovDegrees = lerp( regularFov, sniperFov, zoomFraction )
What is your maximum zoom value -- what fov value are you using as the 'maximum'? If you use an fov of 0, then you'd end up with an infinitely thin frustum with no area... but any value greater than 0 should work (and smaller than 180º...)
Can you post a picture of your "weird" textures?
Edited by Hodgman, 07 January 2013 - 01:16 AM.
#11 Moderators - Reputation: 1918
Posted 08 January 2013 - 12:52 PM
Steve Macpherson
Senior programmer, Firebrand Games
#12 Members - Reputation: 560
Posted 08 January 2013 - 01:05 PM
As Steve curiously asked, a small FOV should result in more zoom(And by asking, I'm sure it was more a question you should ask yourself). As Hodgman noted, a FOV of 0 results in just that. 0 field of view, your frustum essentially becomes a 2d slice(whose angle would depend on the aspect ratio), rather than a volume. A FOV = epsilon is the maximum zoom you could possibly get.
Sidenote: Hodgman, you asked if we could see the "weird textures" I'm guessing here, but are you expecting a moiré pattern?
Edited by Burnt_Fyr, 08 January 2013 - 01:10 PM.






