| 152 | |
| 153 | |
| 154 | void TextSceneNode::getPoints(fvec3 points[5]) const { |
| 155 | const WorldText& text = renderNode.text; |
| 156 | |
| 157 | float yp = 0.0f; |
| 158 | float yn = 0.0f; |
| 159 | if (!renderNode.lines.empty()) { |
| 160 | const float ySpan = (float)(renderNode.lines.size() - 1) * |
| 161 | (renderNode.lineStep / renderNode.fontSize); |
| 162 | if (ySpan < 0.0f) { |
| 163 | yp = +1.5f; |
| 164 | yn = ySpan - 0.5f; |
| 165 | } |
| 166 | else { |
| 167 | yp = +1.5f + ySpan; |
| 168 | yn = -0.5f; |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | float xn = +1.0e20f; |
| 173 | float xp = -1.0e20f; |
| 174 | const std::vector<float>& widths = renderNode.widths; |
| 175 | if (renderNode.fixedWidth > 0.0f) { |
| 176 | xn = renderNode.fixedWidth * -text.justify; |
| 177 | xp = xn + renderNode.fixedWidth; |
| 178 | } |
| 179 | else { |
| 180 | for (size_t i = 0; i < widths.size(); i++) { |
| 181 | float n = widths[i] * -text.justify; |
| 182 | float p = n + widths[i]; |
| 183 | if (xn > n) { xn = n; } |
| 184 | if (xp < p) { xp = p; } |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | // adjust for fontSize, and add some margin |
| 189 | xp = (xp / renderNode.fontSize) + 0.5f; |
| 190 | xn = (xn / renderNode.fontSize) - 0.5f; |
| 191 | |
| 192 | points[0] = fvec3(xn, yn, 0.0f); |
| 193 | points[1] = fvec3(xp, yn, 0.0f); |
| 194 | points[2] = fvec3(xp, yp, 0.0f); |
| 195 | points[3] = fvec3(xn, yp, 0.0f); |
| 196 | points[4] = fvec3(0.0f, 0.0f, 0.0f); // origin |
| 197 | |
| 198 | MeshTransform xform = text.xform; |
| 199 | MeshTransform::Tool xformTool(xform); |
| 200 | for (int i = 0; i < 5; i++) { |
| 201 | xformTool.modifyVertex(points[i]); |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | |
| 206 | float TextSceneNode::getMaxDist(const fvec3 points[5]) const { |
no test coverage detected