32 #if MRPT_HAS_OPENGL_GLUT 37 GLUquadricObj*
obj = gluNewQuadric();
40 const float absHeight = std::abs(mHeight);
47 gluCylinder(
obj, mBaseRadius, mTopRadius, absHeight, mSlices, mStacks);
51 if (mHasBottomBase) gluDisk(
obj, 0, mBaseRadius, mSlices, 1);
52 if (mHasTopBase && mTopRadius > 0)
56 gluDisk(
obj, 0, mTopRadius, mSlices, 1);
59 gluDeleteQuadric(
obj);
67 out[
"baseRadius"] = mBaseRadius;
68 out[
"topRadius"] = mTopRadius;
69 out[
"height"] = mHeight;
70 out[
"slices"] = mSlices;
71 out[
"stacks"] = mStacks;
72 out[
"hasBottomBase"] = mHasBottomBase;
73 out[
"hasTopBase"] = mHasTopBase;
83 mBaseRadius =
static_cast<float>(
in[
"baseRadius"]);
84 mTopRadius =
static_cast<float>(
in[
"topRadius"]);
85 mHeight =
static_cast<float>(
in[
"height"]);
88 mHasBottomBase =
static_cast<bool>(
in[
"hasBottomBase"]);
89 mHasTopBase =
static_cast<bool>(
in[
"hasTopBase"]);
99 writeToStreamRender(out);
101 out << mBaseRadius << mTopRadius << mHeight << mSlices << mStacks
102 << mHasBottomBase << mHasTopBase;
110 readFromStreamRender(
in);
111 in >> mBaseRadius >> mTopRadius >> mHeight >> mSlices >> mStacks >>
112 mHasBottomBase >> mHasTopBase;
133 return (
t = -
b /
a) >= 0;
139 t = (-
b - delta) /
a;
142 else if (-
b + delta > 0)
144 t = (-
b + delta) /
a;
165 if (!reachesHeight(lin.
pBase.
z))
return false;
167 return getRadius(static_cast<float>(lin.
pBase.
z),
r)
183 if (nDist <= mBaseRadius)
192 if (tZ0 > 0 && (!fnd || tZ0 < dist))
197 if (nDist <= mTopRadius)
204 if (mBaseRadius == mTopRadius)
211 if ((!fnd || nDist < dist) &&
220 double slope = (mTopRadius - mBaseRadius) / mHeight;
225 (mBaseRadius + slope * lin.
pBase.
z) * slope *
230 if ((!fnd || nDist < dist) &&
243 bb_min.x = -std::max(mBaseRadius, mTopRadius);
247 bb_max.x = std::max(mBaseRadius, mTopRadius);
void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated) ...
double x
X,Y,Z coordinates.
GLAPI void GLAPIENTRY glEnable(GLenum cap)
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
To be added to all CSerializable-classes implementation files.
GLAPI void GLAPIENTRY glPopMatrix(void)
TPoint3D pBase
Base point.
#define GL_ONE_MINUS_SRC_ALPHA
GLsizei GLsizei GLuint * obj
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
GLAPI void GLAPIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)
Virtual base class for "schematic archives" (JSON, XML,...)
A renderizable object suitable for rendering with OpenGL's display lists.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
T square(const T x)
Inline function for the square of a number.
This base provides a set of functions for maths stuff.
std::array< double, 3 > director
Director vector.
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
A cylinder or cone whose base lies in the XY plane.
void getBoundingBox(mrpt::math::TPoint3D &bb_min, mrpt::math::TPoint3D &bb_max) const override
Evaluates the bounding box of this object (including possible children) in the coordinate frame of th...
void unitarize()
Unitarize director vector.
#define SCHEMA_DESERIALIZE_DATATYPE_VERSION()
For use inside serializeFrom(CSchemeArchiveBase) methods.
GLAPI void GLAPIENTRY glTranslatef(GLfloat x, GLfloat y, GLfloat z)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Virtual base class for "archives": classes abstracting I/O streams.
GLdouble GLdouble GLdouble r
void createFromPoseX(const mrpt::math::TPose3D &p, TLine3D &r)
Gets a 3D line corresponding to the X axis in a given pose.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
bool traceRay(const mrpt::poses::CPose3D &o, double &dist) const override
Ray tracing.
bool solveEqn(double a, double b, double c, double &t)
double getEpsilon()
Gets the value of the geometric epsilon (default = 1e-5)
void checkOpenGLError()
Checks glGetError and throws an exception if an error situation is found.
The namespace for 3D scene representation and rendering.
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
#define SCHEMA_SERIALIZE_DATATYPE_VERSION(ser_version)
For use inside all serializeTo(CSchemeArchiveBase) methods.
GLAPI void GLAPIENTRY glPushMatrix(void)
unsigned __int32 uint32_t
GLAPI void GLAPIENTRY glDisable(GLenum cap)
GLubyte GLubyte GLubyte a
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
3D line, represented by a base point and a director vector.