SPH
Camera.cpp
Go to the documentation of this file.
1 #include "gui/objects/Camera.h"
3 #include "objects/geometry/Box.h"
4 #include "quantities/Quantity.h"
5 #include "quantities/Storage.h"
6 
8 
10  const Quantity& pos = storage.getQuantity(QuantityId::POSITION);
11  if (storage.has(QuantityId::PERSISTENT_INDEX)) {
12  // use persistent indices if available
14  auto iter = std::find(pi.begin(), pi.end(), index);
15  if (iter != pi.end()) {
16  const Size i = Size(iter - pi.begin());
17  return { pos.getValue<Vector>()[i], pos.getDt<Vector>()[i] };
18  }
19  } else if (index < storage.getParticleCnt()) {
20  // use storage index if valid
21  return { pos.getValue<Vector>()[index], pos.getDt<Vector>()[index] };
22  }
23  // fallback if no such particle exists
24  return { Vector(0._f), Vector(0._f) };
25 }
26 
29  Array<Float> x(r.size());
30  Array<Float> y(r.size());
31  Array<Float> z(r.size());
32  for (Size i = 0; i < r.size(); ++i) {
33  x[i] = r[i][X];
34  y[i] = r[i][Y];
35  z[i] = r[i][Z];
36  }
37  const Size mid = r.size() / 2;
38  std::nth_element(x.begin(), x.begin() + mid, x.end());
39  std::nth_element(y.begin(), y.begin() + mid, y.end());
40  std::nth_element(z.begin(), z.begin() + mid, z.end());
41  return { Vector(x[mid], y[mid], z[mid]) + offset, Vector(0._f) };
42 }
43 
44 
45 // ----------------------------------------------------------------------------------------------------------
46 // OrthoCamera
47 // ----------------------------------------------------------------------------------------------------------
48 
50  : data(data) {
51  this->update();
52  // world units to world-to-pixel
53  this->data.ortho.fov = float(data.imageSize.y / data.ortho.fov);
54 }
55 
56 void OrthoCamera::update() {
57  cached.w = getNormalized(data.target - data.position);
58  cached.v = getNormalized(data.up);
59  cached.v -= dot(cached.v, cached.w) * cached.w;
60  cached.u = cross(cached.v, cached.w);
61 }
62 
63 float OrthoCamera::estimateFov(const Storage& storage) const {
64  // handle case without mass in storage
67  if (storage.has(QuantityId::MASS)) {
69  } else {
70  Array<Float> dummy(r.size());
71  dummy.fill(1._f);
72  m = makeArrayRef(std::move(dummy), RefEnum::STRONG);
73  }
74 
75  Float m_sum = 0._f;
76  Vector r_com(0._f);
77 
78  for (Size i = 0; i < r.size(); ++i) {
79  m_sum += m[i];
80  r_com += m[i] * r[i];
81  }
82  SPH_ASSERT(m_sum > 0._f);
83  r_com /= m_sum;
84 
85  Array<Float> distances(r.size());
86  for (Size i = 0; i < r.size(); ++i) {
87  const Vector dr = r[i] - r_com;
88  distances[i] = getLength(dr - cached.w * dot(cached.w, dr));
89  }
90  // find median distance
91  const Size mid = r.size() / 2;
92  std::nth_element(distances.begin(), distances.begin() + mid, distances.end());
93  // factor 5 is ad hoc
94  const Float fov = max(5._f * distances[mid], EPS);
95 
96  return float(data.imageSize.y / fov);
97 }
98 
99 void OrthoCamera::autoSetup(const Storage& storage) {
100  data.ortho.fov = this->estimateFov(storage);
101 
102  /*const Box box = getBoundingBox(storage);
103  if (box.contains(data.position)) {
104  const Vector dir = data.position - data.target;
105 
106  }*/
107 }
108 
110  const float fov = data.ortho.fov;
111  const float x = float(dot(r - data.position, cached.u)) * fov;
112  const float y = float(dot(r - data.position, cached.v)) * fov;
113  const Coords point = Coords(data.imageSize.x / 2 + x, data.imageSize.y / 2 - y - 1);
114  return { { point, fov * float(r[H]) } };
115 }
116 
117 Optional<CameraRay> OrthoCamera::unprojectImpl(const Coords& coords, const bool adjustZ) const {
118  const float fov = data.ortho.fov;
119  const float rx = (coords.x - data.imageSize.x * 0.5f) / fov;
120  const float ry = (data.imageSize.y * 0.5f - coords.y - 1) / fov;
121  CameraRay ray;
122  ray.origin = data.position + cached.u * rx + cached.v * ry;
123  if (adjustZ) {
125  const Float scale = data.imageSize.y / fov;
126  ray.origin -= cached.w * scale;
127  }
128  ray.target = ray.origin + cached.w;
129  return ray;
130 }
131 
133  return unprojectImpl(coords, true);
134 }
135 
137  return data.imageSize;
138 }
139 
141  return AffineMatrix(cached.u, cached.v, cached.w).removeTranslation().translate(data.position);
142 }
143 
145  return data.target;
146 }
147 
149  return getNormalized(data.up);
150 }
151 
153  return data.ortho.cutoff;
154 }
155 
157  return data.ortho.fov;
158 }
159 
161  data.ortho.cutoff = newCutoff;
162 }
163 
164 void OrthoCamera::zoom(const Pixel fixedPoint, const float magnitude) {
165  SPH_ASSERT(magnitude > 0.f);
166 
167  const Vector fixed1 = this->unprojectImpl(Coords(fixedPoint), false)->origin;
168  data.ortho.fov *= magnitude;
169  const Vector fixed2 = this->unprojectImpl(Coords(fixedPoint), false)->origin;
170  const Vector dp = fixed1 - fixed2;
171  data.position += dp;
172  data.target += dp;
173 }
174 
175 void OrthoCamera::setPosition(const Vector& newPosition) {
176  const Vector offset = newPosition - data.position;
177  data.position += offset;
178  this->update();
179 }
180 
181 void OrthoCamera::setTarget(const Vector& newTarget) {
182  const Vector offset = newTarget - data.target;
183  data.target += offset;
184  this->update();
185 }
186 
188  // reset camera position
189  this->update();
190  // const Float dist = getLength(data.target - data.position);
191  // data.position = cached.w * dist;
192 
193  // transform unit vectors
194  cached.u = matrix * cached.u;
195  cached.v = matrix * cached.v;
196  cached.w = cross(cached.u, cached.v);
197 
198  // orbit around target
199  // data.position = cached.w * dist;
200 }
201 
202 void OrthoCamera::pan(const Pixel offset) {
203  const float fov = data.ortho.fov;
204  const Vector dp = -offset.x / fov * cached.u - offset.y / fov * cached.v;
205  data.position += dp;
206  data.target += dp;
207 }
208 
209 void OrthoCamera::resize(const Pixel newSize) {
210  // const Coords scaling = Coords(newSize) / Coords(data.imageSize);
211  data.imageSize = newSize;
212  // center = Pixel(Coords(center) * scaling);
213 }
214 
215 // ----------------------------------------------------------------------------------------------------------
216 // PerspectiveCamera
217 // ----------------------------------------------------------------------------------------------------------
218 
220  : data(data) {
221  SPH_ASSERT(data.clipping.lower() > 0._f && data.clipping.size() > EPS);
222 
223  this->update();
224 }
225 
226 void PerspectiveCamera::autoSetup(const Storage& storage) {
227  (void)storage;
228  /*if (data.tracker) {
229  Vector newTarget;
230  tie(newTarget, cached.velocity) = data.tracker->getCameraState(storage);
231  data.position += newTarget - data.target;
232  data.target = newTarget;
233  this->update();
234  } else {
235  cached.velocity = Vector(0._f);
236  }*/
237 }
238 
240  const Vector dr = r - data.position;
241  const Float proj = dot(dr, cached.dir);
242  if (!data.clipping.contains(proj)) {
243  // point clipped by the clipping planes
244  return NOTHING;
245  }
246  const Vector r0 = dr / proj;
247  // convert [-1, 1] to [0, imageSize]
248  Vector left0;
249  Float leftLength;
250  tieToTuple(left0, leftLength) = getNormalizedWithLength(cached.left);
251  Vector up0;
252  Float upLength;
253  tieToTuple(up0, upLength) = getNormalizedWithLength(cached.up);
254  const float leftRel = float(dot(left0, r0) / leftLength);
255  const float upRel = float(dot(up0, r0) / upLength);
256  const float x = 0.5f * (1.f + leftRel) * data.imageSize.x;
257  const float y = 0.5f * (1.f + upRel) * data.imageSize.y;
258  const float hAtUnitDist = float(r[H] / proj);
259  const float h = hAtUnitDist / float(leftLength) * float(data.imageSize.x);
260 
261  return ProjectedPoint{ { x, data.imageSize.y - y - 1 }, max(float(h), 1.e-6f) };
262 }
263 
265  const float rx = 2.f * coords.x / data.imageSize.x - 1.f;
266  const float ry = 2.f * coords.y / data.imageSize.y - 1.f;
267  const Vector dir = cached.dir + cached.left * rx - cached.up * ry;
268  CameraRay ray;
270  ray.origin = data.position + data.clipping.lower() * dir;
271  ray.target = ray.origin + dir;
272  return ray;
273 }
274 
276  return data.imageSize;
277 }
278 
280  return AffineMatrix(getNormalized(cached.left), getNormalized(cached.up), getNormalized(cached.dir))
282  .translate(data.position);
283 }
284 
286  return data.target;
287 }
288 
290  // not implemented yet
291  return NOTHING;
292 }
293 
295  return NOTHING;
296 }
297 
299 
300 void PerspectiveCamera::zoom(const Pixel UNUSED(fixedPoint), const float magnitude) {
301  SPH_ASSERT(magnitude > 0.f);
302  // data.perspective.fov *= 1._f + 0.01_f * magnitude;
303  // this->transform(//cached.matrix);
304 }
305 
306 void PerspectiveCamera::setPosition(const Vector& newPosition) {
307  data.position = newPosition;
308  this->update();
309 }
310 
311 void PerspectiveCamera::setTarget(const Vector& newTarget) {
312  data.target = newTarget;
313  this->update();
314 }
315 
317  return getNormalized(data.up);
318 }
319 
321  // reset the previous transform
322  this->update();
323 
324  cached.dir = matrix * cached.dir;
325  cached.up = matrix * cached.up;
326  cached.left = matrix * cached.left;
327 }
328 
329 void PerspectiveCamera::pan(const Pixel offset) {
330  const Float x = Float(offset.x) / data.imageSize.x;
331  const Float y = Float(offset.y) / data.imageSize.y;
332  const Vector worldOffset = getLength(data.target - data.position) * (cached.left * x + cached.up * y);
333  data.position -= worldOffset;
334  data.target -= worldOffset;
335 }
336 
337 void PerspectiveCamera::resize(const Pixel newSize) {
338  data.imageSize = newSize;
339  this->update();
340 }
341 
342 void PerspectiveCamera::update() {
343  cached.dir = getNormalized(data.target - data.position);
344 
345  // make sure the up vector is perpendicular
346  Vector up = data.up;
347  up = getNormalized(up - dot(up, cached.dir) * cached.dir);
348  SPH_ASSERT(abs(dot(up, cached.dir)) < EPS);
349 
350  const Float aspect = Float(data.imageSize.x) / Float(data.imageSize.y);
351  SPH_ASSERT(aspect >= 1._f); // not really required, using for simplicity
352  const Float tgfov = tan(0.5_f * data.perspective.fov);
353  cached.up = tgfov / aspect * up;
354  cached.left = tgfov * getNormalized(cross(cached.up, cached.dir));
355 }
356 
357 // ----------------------------------------------------------------------------------------------------------
358 // PanoCameraBase
359 // ----------------------------------------------------------------------------------------------------------
360 
362  : data(data) {
363  SPH_ASSERT(data.clipping.lower() > 0._f && data.clipping.size() > EPS);
364 }
365 
366 void PanoCameraBase::autoSetup(const Storage& storage) {
367  /*if (data.tracker) {
368  const Vector newTarget = data.tracker->getCameraState(storage)[0];
369  data.position += newTarget - data.target;
370  data.target = newTarget;
371  this->update();
372  }*/
373  (void)storage;
374 }
375 
378 }
379 
381  return data.imageSize;
382 }
383 
386 }
387 
389  return data.target;
390 }
391 
393  return getNormalized(data.up);
394 }
395 
397  // not implemented yet
398  return NOTHING;
399 }
400 
402  return NOTHING;
403 }
404 
406 
407 void PanoCameraBase::zoom(const Pixel UNUSED(fixedPoint), const float UNUSED(magnitude)) {
409 }
410 
411 void PanoCameraBase::setPosition(const Vector& UNUSED(newPosition)) {
413 }
414 
415 void PanoCameraBase::setTarget(const Vector& UNUSED(newPosition)) {
417 }
418 
421 }
422 
423 void PanoCameraBase::pan(const Pixel UNUSED(offset)) {
425 }
426 
427 void PanoCameraBase::resize(const Pixel newSize) {
428  data.imageSize = newSize;
429  this->update();
430 }
431 
433  const Vector dir = getNormalized(data.target - data.position);
434 
435  // make sure the up vector is perpendicular
436  const Vector up = getNormalized(data.up - dot(data.up, dir) * dir);
437  SPH_ASSERT(abs(dot(up, dir)) < EPS);
438 
439  const Vector left = getNormalized(cross(up, dir));
440 
441  matrix = AffineMatrix(-dir, -left, up).inverse();
442 }
443 
444 // ----------------------------------------------------------------------------------------------------------
445 // FisheyeCamera
446 // ----------------------------------------------------------------------------------------------------------
447 
449  : PanoCameraBase(data) {
450  this->update();
451 }
452 
454  const Coords p = (coords - cached.center) / cached.radius;
455  const float r = getLength(p);
456  if (r > 1.f) {
457  return NOTHING;
458  }
459 
460  const Float theta = Float(r) * PI / 2._f;
461  const Float phi = Float(atan2(p.y, p.x)) + PI / 2._f;
462 
463  const Vector localDir = sphericalToCartesian(1._f, theta, phi);
464  const Vector dir = matrix * localDir;
465 
466  CameraRay ray;
467  ray.origin = data.position + dir * data.clipping.lower();
468  ray.target = ray.origin + dir;
469  return ray;
470 }
471 
472 void FisheyeCamera::update() {
473  const Vector dir = getNormalized(data.target - data.position);
474 
475  // make sure the up vector is perpendicular
476  const Vector up = getNormalized(data.up - dot(data.up, dir) * dir);
477  SPH_ASSERT(abs(dot(up, dir)) < EPS);
478 
479  const Vector left = getNormalized(cross(up, dir));
480 
481  matrix = AffineMatrix(up, left, dir).inverse();
482 
483  cached.center = Coords(data.imageSize.x / 2, data.imageSize.y / 2);
484  cached.radius = min(cached.center.x, cached.center.y);
485 }
486 
487 // ----------------------------------------------------------------------------------------------------------
488 // SphericalCamera
489 // ----------------------------------------------------------------------------------------------------------
490 
492  : PanoCameraBase(data) {
493  this->update();
494 }
495 
497  const Float phi = 2._f * PI * coords.x / data.imageSize.x;
498  const Float theta = PI * coords.y / data.imageSize.y;
499  const Vector dir = matrix * sphericalToCartesian(1._f, theta, phi);
500 
501  CameraRay ray;
502  ray.origin = data.position + dir * data.clipping.lower();
503  ray.target = ray.origin + dir;
504  return ray;
505 }
506 
ArrayRef< T > makeArrayRef(Array< T > &data, const RefEnum type)
Definition: ArrayRef.h:138
#define SPH_ASSERT(x,...)
Definition: Assert.h:94
#define NOT_IMPLEMENTED
Helper macro marking missing implementation.
Definition: Assert.h:100
NAMESPACE_SPH_BEGIN
Definition: BarnesHut.cpp:13
Object representing a three-dimensional axis-aligned box.
Defines projection transforming 3D particles onto 2D screen.
uint32_t Size
Integral type used to index arrays (by default).
Definition: Globals.h:16
double Float
Precision used withing the code. Use Float instead of float or double where precision is important.
Definition: Globals.h:13
constexpr INLINE T max(const T &f1, const T &f2)
Definition: MathBasic.h:20
NAMESPACE_SPH_BEGIN constexpr INLINE T min(const T &f1, const T &f2)
Minimum & Maximum value.
Definition: MathBasic.h:15
constexpr Float EPS
Definition: MathUtils.h:30
INLINE T tan(const T f)
Definition: MathUtils.h:301
INLINE T atan2(const T y, const T x)
Definition: MathUtils.h:321
INLINE auto abs(const T &f)
Definition: MathUtils.h:276
constexpr Float PI
Mathematical constants.
Definition: MathUtils.h:361
#define UNUSED(x)
Definition: Object.h:37
#define NAMESPACE_SPH_END
Definition: Object.h:12
const NothingType NOTHING
Definition: Optional.h:16
@ POSITION
Positions (velocities, accelerations) of particles, always a vector quantity,.
@ MASS
Paricles masses, always a scalar quantity.
Holder of quantity values and their temporal derivatives.
Container for storing particle quantities and materials.
INLINE Tuple< TArgs &... > tieToTuple(TArgs &... args)
Creates a tuple of l-value references. Use IGNORE placeholder to omit one or more parameters.
Definition: Tuple.h:304
INLINE Float getLength(const Vector &v)
Returns the length of the vector. Enabled only for vectors of floating-point precision.
Definition: Vector.h:579
INLINE Tuple< Vector, Float > getNormalizedWithLength(const Vector &v)
Returns normalized vector and length of the input vector as tuple.
Definition: Vector.h:597
INLINE BasicVector< float > cross(const BasicVector< float > &v1, const BasicVector< float > &v2)
Cross product between two vectors.
Definition: Vector.h:559
BasicVector< Float > Vector
Definition: Vector.h:539
INLINE float dot(const BasicVector< float > &v1, const BasicVector< float > &v2)
Make sure the vector is trivially constructible and destructible, needed for fast initialization of a...
Definition: Vector.h:548
INLINE Vector sphericalToCartesian(const Float r, const Float theta, const Float phi)
Constructs a vector from spherical coordinates.
Definition: Vector.h:788
INLINE Vector getNormalized(const Vector &v)
Definition: Vector.h:590
@ H
Definition: Vector.h:25
@ Y
Definition: Vector.h:23
@ X
Definition: Vector.h:22
@ Z
Definition: Vector.h:24
INLINE AffineMatrix & translate(const Vector &t)
Definition: AffineMatrix.h:58
AffineMatrix inverse() const
Definition: AffineMatrix.h:86
INLINE AffineMatrix & removeTranslation()
Definition: AffineMatrix.h:53
INLINE TCounter size() const
Definition: ArrayView.h:101
INLINE Iterator< StorageType > begin()
Definition: ArrayView.h:55
INLINE Iterator< StorageType > end()
Definition: ArrayView.h:63
INLINE Iterator< StorageType > end() noexcept
Definition: Array.h:462
INLINE Iterator< StorageType > begin() noexcept
Definition: Array.h:450
virtual Optional< CameraRay > unproject(const Coords &coords) const override
Returns a ray in particle coordinates corresponding to given coordinates in the image plane.
Definition: Camera.cpp:453
FisheyeCamera(const CameraParams &data)
Definition: Camera.cpp:448
INLINE Float lower() const
Returns lower bound of the interval.
Definition: Interval.h:74
INLINE Float size() const
Returns the size of the interval.
Definition: Interval.h:89
INLINE bool contains(const Float &value) const
Checks whether value is inside the interval.
Definition: Interval.h:55
virtual Pair< Vector > getTrackedPoint(const Storage &storage) const override
Definition: Camera.cpp:27
Wrapper of type value of which may or may not be present.
Definition: Optional.h:23
virtual Optional< float > getCutoff() const override
Returns the clipping distance from plane passing through origin, perpendicular to camera direction.
Definition: Camera.cpp:152
virtual AffineMatrix getFrame() const override
Returns the transformation matrix converting camera space to world space.
Definition: Camera.cpp:140
virtual void transform(const AffineMatrix &matrix) override
Transforms the current view by given matrix.
Definition: Camera.cpp:187
virtual void resize(const Pixel newSize) override
Changes the image size.
Definition: Camera.cpp:209
virtual Optional< float > getWorldToPixel() const override
Returns the world-to-pixel ratio.
Definition: Camera.cpp:156
virtual void zoom(const Pixel fixedPoint, const float magnitude) override
Definition: Camera.cpp:164
virtual void setPosition(const Vector &newPosition) override
Moves the camera to new position in world space.
Definition: Camera.cpp:175
virtual Pixel getSize() const override
Returns the current resolution of the camera.
Definition: Camera.cpp:136
virtual Vector getUpVector() const override
Returns the reference "up" direction of the camera.
Definition: Camera.cpp:148
OrthoCamera(const CameraParams &data)
Definition: Camera.cpp:49
virtual void setCutoff(const Optional< float > newCutoff) override
Modifies the clipping distance of the camera.
Definition: Camera.cpp:160
virtual void autoSetup(const Storage &storage) override
Initializes the camera, using the provided particle storage.
Definition: Camera.cpp:99
virtual Vector getTarget() const override
Returns the current target point of the camera.
Definition: Camera.cpp:144
virtual void setTarget(const Vector &newTarget) override
Definition: Camera.cpp:181
virtual Optional< ProjectedPoint > project(const Vector &r) const override
Returns projected position of particle on the image.
Definition: Camera.cpp:109
virtual Optional< CameraRay > unproject(const Coords &coords) const override
Returns a ray in particle coordinates corresponding to given coordinates in the image plane.
Definition: Camera.cpp:132
virtual void pan(const Pixel offset) override
Moves the camera by relative offset in image space.
Definition: Camera.cpp:202
Common base for panoramic cameras.
Definition: Camera.h:287
virtual Vector getUpVector() const override
Returns the reference "up" direction of the camera.
Definition: Camera.cpp:392
virtual Optional< float > getCutoff() const override
Returns the clipping distance from plane passing through origin, perpendicular to camera direction.
Definition: Camera.cpp:396
virtual void setPosition(const Vector &newPosition) override
Moves the camera to new position in world space.
Definition: Camera.cpp:411
virtual void pan(const Pixel offset) override
Moves the camera by relative offset in image space.
Definition: Camera.cpp:423
CameraParams data
Definition: Camera.h:289
virtual Optional< ProjectedPoint > project(const Vector &r) const override
Returns projected position of particle on the image.
Definition: Camera.cpp:376
virtual void setTarget(const Vector &newTarget) override
Definition: Camera.cpp:415
virtual Pixel getSize() const override
Returns the current resolution of the camera.
Definition: Camera.cpp:380
virtual void autoSetup(const Storage &storage) override
Initializes the camera, using the provided particle storage.
Definition: Camera.cpp:366
virtual Optional< float > getWorldToPixel() const override
Returns the world-to-pixel ratio.
Definition: Camera.cpp:401
virtual AffineMatrix getFrame() const override
Returns the transformation matrix converting camera space to world space.
Definition: Camera.cpp:384
virtual void setCutoff(const Optional< float > newCutoff) override
Modifies the clipping distance of the camera.
Definition: Camera.cpp:405
virtual void zoom(const Pixel UNUSED(fixedPoint), const float magnitude) override
Definition: Camera.cpp:407
virtual void transform(const AffineMatrix &matrix) override
Transforms the current view by given matrix.
Definition: Camera.cpp:419
virtual void update()
Definition: Camera.cpp:432
PanoCameraBase(const CameraParams &data)
Definition: Camera.cpp:361
AffineMatrix matrix
Definition: Camera.h:290
virtual Vector getTarget() const override
Returns the current target point of the camera.
Definition: Camera.cpp:388
virtual void resize(const Pixel newSize) override
Changes the image size.
Definition: Camera.cpp:427
virtual Pair< Vector > getTrackedPoint(const Storage &storage) const override
Definition: Camera.cpp:9
Vector dir
Unit direction of the camera.
Definition: Camera.h:231
virtual Pixel getSize() const override
Returns the current resolution of the camera.
Definition: Camera.cpp:275
virtual AffineMatrix getFrame() const override
Returns the transformation matrix converting camera space to world space.
Definition: Camera.cpp:279
virtual void setCutoff(const Optional< float > newCutoff) override
Modifies the clipping distance of the camera.
Definition: Camera.cpp:298
virtual Vector getUpVector() const override
Returns the reference "up" direction of the camera.
Definition: Camera.cpp:316
virtual Optional< ProjectedPoint > project(const Vector &r) const override
Returns projected position of particle on the image.
Definition: Camera.cpp:239
virtual void setTarget(const Vector &newTarget) override
Definition: Camera.cpp:311
virtual Optional< float > getWorldToPixel() const override
Returns the world-to-pixel ratio.
Definition: Camera.cpp:294
virtual void transform(const AffineMatrix &matrix) override
Transforms the current view by given matrix.
Definition: Camera.cpp:320
virtual void setPosition(const Vector &newPosition) override
Moves the camera to new position in world space.
Definition: Camera.cpp:306
virtual void autoSetup(const Storage &storage) override
Initializes the camera, using the provided particle storage.
Definition: Camera.cpp:226
virtual Vector getTarget() const override
Returns the current target point of the camera.
Definition: Camera.cpp:285
virtual void resize(const Pixel newSize) override
Changes the image size.
Definition: Camera.cpp:337
virtual void pan(const Pixel offset) override
Moves the camera by relative offset in image space.
Definition: Camera.cpp:329
virtual Optional< float > getCutoff() const override
Returns the clipping distance from plane passing through origin, perpendicular to camera direction.
Definition: Camera.cpp:289
Vector up
Up vector of the camera, size of which of represents the image size at unit distance.
Definition: Camera.h:234
virtual void zoom(const Pixel UNUSED(fixedPoint), const float magnitude) override
Definition: Camera.cpp:300
virtual Optional< CameraRay > unproject(const Coords &coords) const override
Returns a ray in particle coordinates corresponding to given coordinates in the image plane.
Definition: Camera.cpp:264
PerspectiveCamera(const CameraParams &data)
Definition: Camera.cpp:219
Generic container for storing scalar, vector or tensor quantity and its derivatives.
Definition: Quantity.h:200
INLINE Array< TValue > & getValue()
Returns a reference to array of quantity values.
Definition: Quantity.h:287
INLINE Array< TValue > & getDt()
Returns a reference to array of first derivatives of quantity.
Definition: Quantity.h:307
SphericalCamera(const CameraParams &data)
Definition: Camera.cpp:491
virtual Optional< CameraRay > unproject(const Coords &coords) const override
Returns a ray in particle coordinates corresponding to given coordinates in the image plane.
Definition: Camera.cpp:496
Array with fixed number of allocated elements.
Definition: StaticArray.h:19
Container storing all quantities used within the simulations.
Definition: Storage.h:230
Quantity & getQuantity(const QuantityId key)
Retrieves quantity with given key from the storage.
Definition: Storage.cpp:150
Size getParticleCnt() const
Returns the number of particles.
Definition: Storage.cpp:445
bool has(const QuantityId key) const
Checks if the storage contains quantity with given key.
Definition: Storage.cpp:130
Array< TValue > & getValue(const QuantityId key)
Retrieves a quantity values from the storage, given its key and value type.
Definition: Storage.cpp:191
struct CameraParams::@20 perspective
Pixel imageSize
Size of the image.
Definition: Camera.h:136
struct CameraParams::@21 ortho
Float fov
Field of view (angle)
Definition: Camera.h:152
Vector position
Camera position in space.
Definition: Camera.h:139
Optional< float > cutoff
Cutoff distance of the camera.
Definition: Camera.h:161
Interval clipping
Defines the clipping planes of the camera.
Definition: Camera.h:148
Vector target
Look-at point in space.
Definition: Camera.h:142
Vector up
Up vector of the camera (direction)
Definition: Camera.h:145
Ray given by origin and target point.
Definition: Camera.h:56
Vector origin
Definition: Camera.h:57
Vector target
Definition: Camera.h:58
Definition: Point.h:115
Definition: Point.h:101
Represents a particle projected onto image plane.
Definition: Camera.h:46