paysages3d/src/basics/CappedCylinder.h

44 lines
1.1 KiB
C
Raw Normal View History

#pragma once
2015-10-15 18:21:32 +00:00
#include "basics_global.h"
#include "InfiniteCylinder.h"
#include "Sphere.h"
2015-10-15 18:21:32 +00:00
namespace paysages {
namespace basics {
/**
* Geometric cylinder, with capped ends (not infinite).
*/
class BASICSSHARED_EXPORT CappedCylinder : public InfiniteCylinder {
public:
CappedCylinder() = default;
2015-10-15 18:21:32 +00:00
CappedCylinder(const Vector3 &base, const Vector3 &direction, double radius, double length);
inline double getLength() const {
return length;
}
2015-10-15 18:21:32 +00:00
/**
* Check the intersection between the cylinder and an infinite ray.
*
* Returns the number of intersections (0, 1 or 2) and fill the intersection points.
2015-10-15 18:21:32 +00:00
*/
int findRayIntersection(const InfiniteRay &ray, Vector3 *first_intersection, Vector3 *second_intersection) const;
2015-10-15 18:21:32 +00:00
/**
* Check if a point projects in the length of the finite cylinder.
*/
bool checkPointProjection(Vector3 *point) const;
virtual void save(PackStream *stream) const override;
virtual void load(PackStream *stream) override;
private:
2015-10-15 18:21:32 +00:00
double length;
Sphere container;
2015-10-15 18:21:32 +00:00
};
}
}