51 Perspective(
double fov,
double ar,
double nd,
double fd) :
59 dmat4 transform()
const override {
return perspective(radians(fieldOfViewY), aspectRatio, nearDistance, farDistance); }
61 void changeExtent(
const VkExtent2D& prevExtent,
const VkExtent2D& newExtent)
override
63 double oldRatio =
static_cast<double>(prevExtent.width) /
static_cast<double>(prevExtent.height);
64 double newRatio =
static_cast<double>(newExtent.width) /
static_cast<double>(newExtent.height);
66 aspectRatio *= (newRatio / oldRatio);
75 void read(
Input& input)
override;
76 void write(
Output& output)
const override;
94 Orthographic(
double l,
double r,
double b,
double t,
double nd,
double fd) :
104 dmat4 transform()
const override {
return orthographic(left, right, bottom, top, nearDistance, farDistance); }
106 void changeExtent(
const VkExtent2D& prevExtent,
const VkExtent2D& newExtent)
override
108 double oldRatio =
static_cast<double>(prevExtent.width) /
static_cast<double>(prevExtent.height);
109 double newRatio =
static_cast<double>(newExtent.width) /
static_cast<double>(newExtent.height);
110 left *= newRatio / oldRatio;
111 right *= newRatio / oldRatio;
122 void read(
Input& input)
override;
123 void write(
Output& output)
const override;
173 horizonMountainHeight(hmh)
177 dmat4 transform()
const override
181 vsg::dvec3 lv = vsg::normalize(lookAt->center - lookAt->eye);
182 double R = ellipsoidModel->radiusEquator();
183 double H = ellipsoidModel->convertECEFToLatLongAltitude(v).z;
186 double alpha = (D > R) ? std::acos(R / D) : 0.0;
188 double beta_ratio = R / (R + horizonMountainHeight);
189 double beta = beta_ratio < 1.0 ? std::acos(beta_ratio) : 0.0;
191 double theta_ratio = -vsg::dot(lv, v) / (vsg::length(lv) * vsg::length(v));
192 double theta = theta_ratio < 1.0 ? std::acos(theta_ratio) : 0.0;
194 double l = R * (std::tan(alpha) + std::tan(beta));
196 double farDistance = std::cos(theta + alpha - vsg::PI * 0.5) * l;
197 double nearDistance = farDistance * nearFarRatio;
200 return perspective(radians(fieldOfViewY), aspectRatio, nearDistance, farDistance);
203 void changeExtent(
const VkExtent2D& prevExtent,
const VkExtent2D& newExtent)
override
205 double oldRatio =
static_cast<double>(prevExtent.width) /
static_cast<double>(prevExtent.height);
206 double newRatio =
static_cast<double>(newExtent.width) /
static_cast<double>(newExtent.height);
208 aspectRatio *= (newRatio / oldRatio);
213 double fieldOfViewY = 60.0;
214 double aspectRatio = 1.0;
215 double nearFarRatio = 0.0001;
216 double horizonMountainHeight = 1000.0;
219 void read(
Input& input)
override;
220 void write(
Output& output)
const override;