183 uint vertexCount =
static_cast<uint
>(
mCaption.size() * 6);
203 mRenderOp.vertexData->vertexCount = vertexCount;
204 mRenderOp.operationType = RenderOperation::OT_TRIANGLE_LIST;
207 VertexDeclaration* decl =
mRenderOp.vertexData->vertexDeclaration;
208 VertexBufferBinding* bind =
mRenderOp.vertexData->vertexBufferBinding;
212 if (!decl->findElementBySemantic(VES_POSITION))
215 offset += VertexElement::getTypeSize(VET_FLOAT3);
217 if (!decl->findElementBySemantic(VES_TEXTURE_COORDINATES))
218 decl->addElement(
POS_TEX_BINDING, offset, Ogre::VET_FLOAT2, Ogre::VES_TEXTURE_COORDINATES, 0);
220 HardwareVertexBufferSharedPtr ptbuf = HardwareBufferManager::getSingleton().createVertexBuffer(decl->getVertexSize(
POS_TEX_BINDING),
222 HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY);
226 if (!decl->findElementBySemantic(VES_DIFFUSE))
229 HardwareVertexBufferSharedPtr cbuf = HardwareBufferManager::getSingleton().createVertexBuffer(decl->getVertexSize(
COLOUR_BINDING),
231 HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY);
235 Real* pPCBuff = (Real*)malloc(ptbuf->getSizeInBytes());
236 Real* oPCBuff = pPCBuff;
238 float largestWidth = 0;
239 float left = 0 * 2.0 - 1.0;
240 float top = -((0 * 2.0) - 1.0);
247 Ogre::Vector3 min = Ogre::Vector3::ZERO, max = Ogre::Vector3::ZERO, currPos = Ogre::Vector3::ZERO;
248 Ogre::Real maxSquaredRadius = 0.0f;
252 std::string::iterator i, iend;
261 for (i =
mCaption.begin(); i != iend; ++i)
268 for (i =
mCaption.begin(); i != iend; ++i)
273 for (std::string::iterator j = i; j != iend && *j !=
'\n'; j++)
285 left = 0 * 2.0 - 1.0;
300 Real horiz_height =
mpFont->getGlyphAspectRatio(*i);
302 Ogre::Font::UVRect utmp;
303 utmp =
mpFont->getGlyphTexCoords(*i);
317 *pPCBuff++ = left - (len / 2);
325 currPos = Ogre::Vector3(left, top, -1.0);
327 currPos = Ogre::Vector3(left - (len / 2), top, -1.0);
331 maxSquaredRadius = currPos.squaredLength();
336 min.makeFloor(currPos);
337 max.makeCeil(currPos);
338 maxSquaredRadius = std::max(maxSquaredRadius, currPos.squaredLength());
347 *pPCBuff++ = left - (len / 2);
355 currPos = Ogre::Vector3(left, top, -1.0);
357 currPos = Ogre::Vector3(left - (len / 2), top, -1.0);
358 min.makeFloor(currPos);
359 max.makeCeil(currPos);
360 maxSquaredRadius = std::max(maxSquaredRadius, currPos.squaredLength());
369 *pPCBuff++ = left - (len / 2);
378 currPos = Ogre::Vector3(left, top, -1.0);
380 currPos = Ogre::Vector3(left - (len / 2), top, -1.0);
381 min.makeFloor(currPos);
382 max.makeCeil(currPos);
383 maxSquaredRadius = std::max(maxSquaredRadius, currPos.squaredLength());
392 *pPCBuff++ = left - (len / 2);
398 currPos = Ogre::Vector3(left, top, -1.0);
399 min.makeFloor(currPos);
400 max.makeCeil(currPos);
401 maxSquaredRadius = std::max(maxSquaredRadius, currPos.squaredLength());
410 *pPCBuff++ = left - (len / 2);
416 currPos = Ogre::Vector3(left, top, -1.0);
417 min.makeFloor(currPos);
418 max.makeCeil(currPos);
419 maxSquaredRadius = std::max(maxSquaredRadius, currPos.squaredLength());
427 *pPCBuff++ = left - (len / 2);
434 currPos = Ogre::Vector3(left, top, -1.0);
435 min.makeFloor(currPos);
436 max.makeCeil(currPos);
437 maxSquaredRadius = std::max(maxSquaredRadius, currPos.squaredLength());
442 float currentWidth = (left + 1) / 2 - 0;
443 if (currentWidth > largestWidth)
444 largestWidth = currentWidth;
449 ptbuf->writeData(0, ptbuf->getSizeInBytes(), oPCBuff,
true);
453 mAABB = Ogre::AxisAlignedBox(min, max);
454 mRadius = Ogre::Math::Sqrt(maxSquaredRadius);
This creates a billboarding object that displays a text.
void setColor(const Ogre::ColourValue &color)
void getRenderOperation(Ogre::RenderOperation &op)
MovableText(const std::string &name, const std::string &caption, const std::string &fontName="highcontrast_black", Ogre::Real charHeight=1.0, const Ogre::ColourValue &color=Ogre::ColourValue::Black)
const Ogre::Quaternion & getWorldOrientation(void) const
void setTextAlignment(const HorizontalAlignment &horizontalAlignment, const VerticalAlignment &verticalAlignment)
void getWorldTransforms(Ogre::Matrix4 *xform) const
void setFontName(const std::string &fontName)
void setCaption(const std::string &caption)
const Ogre::Vector3 & getWorldPosition(void) const