xyRatio(_xyRatio),
zNear(_zNear),
zFar(_zFar),
- projection(perspective(yFov, xyRatio, zNear, zFar)),
+ projection(perspective(yFov* (float)M_D2R, xyRatio, zNear, zFar)),
pitch(0.f),
yaw(0.f),
dist(2.f), //DIST
xyRatio = _xyRatio;
- projection = perspective(yFov, xyRatio, zNear, zFar);
+ projection = perspective(yFov * (float)M_D2R, xyRatio, zNear, zFar);
}
void Camera::updateProjection(float _yFov, float _xyRatio, float _zNear, float _zFar)
zNear = _zNear;
zFar = _zFar;
- tan_alphaY = tan(yFov / 2.f);
- Icos_alphaX = 1.f / cos(yFov / 2.f*xyRatio);
- Icos_alphaY = 1.f / cos(yFov / 2.f);
+ tan_alphaY = tan(yFov * (float)M_D2R * .5f);
+ Icos_alphaX = 1.f / cos(atan(tan_alphaY*xyRatio));
+ Icos_alphaY = 1.f / cos(yFov * (float)M_D2R * .5f);
- projection = perspective(yFov, xyRatio, zNear, zFar);
+ projection = perspective(yFov * (float)M_D2R, xyRatio, zNear, zFar);
}
Camera::FC_stat Camera::frustum_sphere(vec3 _center, float _radius) const
{
FC_stat result = FC_INSIDE;
- //return result;
vec3 v(_center - cCenter);
vec3 pVCam(dot(v,cRight), dot(v,cUpVector), dot(v,cFront));
float h2 = pVCam.z * tan_alphaY;
float w2 = h2 * xyRatio;
- //float d = _radius * cos
if (_radius == 0) {
if (pVCam.z > zFar || pVCam.z < zNear)
for (auto i = SceneObjects.cbegin(); i != SceneObjects.cend(); ++i)
{
- auto result = camera.frustum_sphere((*i)->getPosition() + (*i)->gModel()->getBox().center());// , (*i)->gModel()->getBox().radius());
+ auto result = camera.frustum_sphere((*i)->getPosition() +(*i)->gModel()->getBox().center() , (*i)->gModel()->getBox().radius());
if (result == camera.FC_OUTSIDE)
continue;
(*i)->draw(_target);