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);