Advertisement

Camera and clipping planes?

Started by May 17, 2000 01:46 PM
24 comments, last by Pascalix 24 years, 6 months ago
Problem solved! The formula had a small typo, it was:

float fovx = (float)atan(ar*(float)tan(fovy));

changed to:

float fovx = (float)atan( (float)tan(fovy) / ar );

Need to divide by aspect ratio not multiply, works great! Thanks much for all your help.

Rick
quote:
original post by WitchLord

Actually the normals point inwards, so a negative sign
would mean that the point is outside the visible frustum.


Well, some time ago I had to decide what’s out and what’s in. It made sense to make the normals point outward, so everything with a negative sign is in the half-space.
I automatically assumed, that the normals would point outwards (power of habit). No problem, I’ll just scale them by –1 and everything will be fine…
------------
Md2ge:
Yeah, I know, that bounding spheres are fine for most cases, but I can’t help it. I’m just a perfectionist (which just means that I often get stuck on small unimportant details).

Pascalix.
Pascalix;
Advertisement
Yah I know the feeling, I''m going to need AABB for the terrain stuff, I''m hoping it will be easy as long as the frustrum checking stuff works correctly, seems to work now that I found that typo, or at least I''m hopinng that''s what it was, not a bug on my code elsewhere that just happens to be getting fixed when I do this. Are you calculating the FovX the same way?

Thanks,
Rick
md2ge, although it wasn''t a typo you are still correct that you should divide by the aspect ration. This is because the aspect ratio you use is (Height/Width = 0.75) whereas I normally use (Width/Height = 1.333). Both are equally correct.

- WitchLord

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

I''m using width/height like you, here''s my projection code:

// fov prev declared as 110.0f
// aspect prev declared as 1.33f

D3DXMATRIX proj_matrix;
D3DXMatrixPerspectiveFovLH(&proj_matrix, D3DXToRadian(fov), aspect, minz, maxz);
d3d_device->SetTransform(D3DTRANSFORMSTATE_PROJECTION, (D3DMATRIX*) proj_matrix);

So the aspect needs to be multiplied if you set it up as height/width, such as 600/800=0.75, the main thing is that it works =) Thanks for all your great help, I can now replace my old frustrum check code that was not accurate and it had severe limitations, such as fov had to be 90 and the aspect ratio had to be 1.0 anything else would make it even less accurate.

I look forward to your next tutorial =)

Thanks,
Rick


- WitchLord

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement