26 void
CArrow::onUpdateBuffers_Triangles()
36 const P3f p0(m_x0, m_y0, m_z0), p1(m_x1, m_y1, m_z1);
38 const float P10_norm = p.norm();
41 p *= (1.0f / P10_norm);
43 setLocalRepresentativePoint((p0 + p1) * 0.5f);
56 const float dAng = 2 *
M_PIf / m_slices;
59 std::vector<mrpt::math::TPoint2Df> cc(m_slices);
60 for (
unsigned int i = 0; i < m_slices; i++, a += dAng)
69 const float r0 = m_smallRadius, r1 = m_largeRadius,
70 h0 = P10_norm * (1.0f - m_headRatio), h1 = P10_norm;
72 const float wall_tilt = 0;
73 const float coswt = std::cos(wall_tilt), sinwt = std::sin(wall_tilt);
75 const float head_tilt = std::atan2(r1, P10_norm * m_headRatio);
76 const float cosht = std::cos(head_tilt), sinht = std::sin(head_tilt);
79 for (
unsigned int i = 0; i < m_slices; i++)
81 const auto ip = (i + 1) % m_slices;
89 T.
rotateVector(V3f(-coswt * cc[i].y, coswt * cc[i].x, sinwt)),
90 T.
rotateVector(V3f(-coswt * cc[ip].y, coswt * cc[ip].x, sinwt)),
91 T.
rotateVector(V3f(-coswt * cc[i].y, coswt * cc[i].x, sinwt)));
99 T.
rotateVector(V3f(-coswt * cc[ip].y, coswt * cc[ip].x, sinwt)),
100 T.
rotateVector(V3f(-coswt * cc[ip].y, coswt * cc[ip].x, sinwt)),
101 T.
rotateVector(V3f(-coswt * cc[i].y, coswt * cc[i].x, sinwt)));
105 for (
unsigned int i = 0; i < m_slices; i++)
107 const auto ip = (i + 1) % m_slices;
114 T.
rotateVector(V3f(-cosht * cc[i].y, cosht * cc[i].x, sinht)),
115 T.
rotateVector(V3f(-cosht * cc[ip].y, cosht * cc[ip].x, sinht)),
116 T.
rotateVector(V3f(-cosht * cc[i].y, cosht * cc[i].x, sinht)));
120 for (
auto& t : tris) t.setColor(m_color);
126 writeToStreamRender(
out);
127 out << m_x0 << m_y0 << m_z0;
128 out << m_x1 << m_y1 << m_z1;
129 out << m_headRatio << m_smallRadius << m_largeRadius;
141 readFromStreamRender(in);
142 in >> m_x0 >> m_y0 >> m_z0;
143 in >> m_x1 >> m_y1 >> m_z1;
144 in >> m_headRatio >> m_smallRadius >> m_largeRadius;
147 float arrow_roll, arrow_pitch, arrow_yaw;
148 in >> arrow_roll >> arrow_pitch >> arrow_yaw;
150 if (version >= 2) in >> m_slices;
168 out[
"headRatio"] = m_headRatio;
169 out[
"smallRadius"] = m_smallRadius;
170 out[
"largeRadius"] = m_largeRadius;
171 out[
"slices"] = m_slices;
182 m_x0 =
static_cast<float>(in[
"x0"]);
183 m_y0 =
static_cast<float>(in[
"y0"]);
184 m_z0 =
static_cast<float>(in[
"z0"]);
185 m_x1 =
static_cast<float>(in[
"x1"]);
186 m_y1 =
static_cast<float>(in[
"y1"]);
187 m_z1 =
static_cast<float>(in[
"z1"]);
188 m_headRatio =
static_cast<float>(in[
"headRatio"]);
189 m_smallRadius =
static_cast<float>(in[
"smallRadius"]);
190 m_largeRadius =
static_cast<float>(in[
"largeRadius"]);
191 m_slices =
static_cast<unsigned int>(in[
"slices"]);
201 bb_min.x = std::min(m_x0, m_x1);
202 bb_min.y = std::min(m_y0, m_y1);
203 bb_min.z = std::min(m_z0, m_z1);
205 bb_max.x = std::max(m_x0, m_x1);
206 bb_max.y = std::max(m_y0, m_y1);
207 bb_max.z = std::max(m_z0, m_z1);
CMatrixFixed< Scalar, BLOCK_ROWS, BLOCK_COLS > blockCopy(int start_row=0, int start_col=0) const
const blockCopy(): Returns a copy of the given block
A compile-time fixed-size numeric matrix container.
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...
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
To be added to all CSerializable-classes implementation files.
void notifyChange() const
Call to enable calling renderUpdateBuffers() before the next render() rendering iteration.
Renderizable generic renderer for objects using the triangles shader.
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
mrpt::math::TVector3D rotateVector(const mrpt::math::TVector3D &local) const
Rotates a vector (i.e.
Virtual base class for "schematic archives" (JSON, XML,...)
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
This base provides a set of functions for maths stuff.
#define ASSERT_ABOVEEQ_(__A, __B)
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
#define SCHEMA_DESERIALIZE_DATATYPE_VERSION()
For use inside serializeFrom(CSchemeArchiveBase) methods.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
CMatrixDouble44 generateAxisBaseFromDirectionAndAxis(const mrpt::math::TVector3D &vec, uint8_t coord)
Creates a homogeneus matrix (4x4) such that the coordinate given (0 for x, 1 for y, 2 for z) corresponds to the provided vector.
Virtual base class for "archives": classes abstracting I/O streams.
std::vector< mrpt::opengl::TTriangle > m_triangles
List of triangles.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
mrpt::vision::TStereoCalibResults out
#define ASSERT_ABOVE_(__A, __B)
The namespace for 3D scene representation and rendering.
void composePoint(double lx, double ly, double lz, double &gx, double &gy, double &gz, mrpt::optional_ref< mrpt::math::CMatrixDouble33 > out_jacobian_df_dpoint=std::nullopt, mrpt::optional_ref< mrpt::math::CMatrixDouble36 > out_jacobian_df_dpose=std::nullopt, mrpt::optional_ref< mrpt::math::CMatrixDouble36 > out_jacobian_df_dse3=std::nullopt, bool use_small_rot_approx=false) const
An alternative, slightly more efficient way of doing with G and L being 3D points and P this 6D pose...
TPoint3D_< float > TPoint3Df
#define ASSERT_BELOWEQ_(__A, __B)
#define SCHEMA_SERIALIZE_DATATYPE_VERSION(ser_version)
For use inside all serializeTo(CSchemeArchiveBase) methods.