#### Archived

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

# Camera and clipping planes?

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

## Recommended Posts

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

##### Share on other sites
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.

##### Share on other sites
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

##### Share on other sites
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

##### Share on other sites
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;
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

• 10
• 10
• 12
• 10
• 33