33 void QuatPosToMatrix(
const Ogre::Quaternion& _quat,
const Ogre::Vector3 &pos, dFloat* matrix)
40 Vector3 xcol, ycol, zcol;
42 Ogre::Quaternion quat(_quat);
44 quat.ToRotationMatrix(rot);
46 xcol = rot.GetColumn(0);
47 ycol = rot.GetColumn(1);
48 zcol = rot.GetColumn(2);
51 matrix[0] = dFloat(xcol.x);
52 matrix[1] = dFloat(xcol.y);
53 matrix[2] = dFloat(xcol.z);
54 matrix[3] = dFloat(0.0);
56 matrix[4] = dFloat(ycol.x);
57 matrix[5] = dFloat(ycol.y);
58 matrix[6] = dFloat(ycol.z);
59 matrix[7] = dFloat(0.0);
61 matrix[8] = dFloat(zcol.x);
62 matrix[9] = dFloat(zcol.y);
63 matrix[10] = dFloat(zcol.z);
64 matrix[11] = dFloat(0.0);
66 matrix[12] = dFloat(pos.x);
67 matrix[13] = dFloat(pos.y);
68 matrix[14] = dFloat(pos.z);
69 matrix[15] = dFloat(1.0);
75 matrix_out = Ogre::Matrix4(Ogre::Real(matrix_in[0]), Ogre::Real(matrix_in[4]), Ogre::Real(matrix_in[8]), Ogre::Real(matrix_in[12]),
76 Ogre::Real(matrix_in[1]), Ogre::Real(matrix_in[5]), Ogre::Real(matrix_in[9]), Ogre::Real(matrix_in[13]),
77 Ogre::Real(matrix_in[2]), Ogre::Real(matrix_in[6]), Ogre::Real(matrix_in[10]), Ogre::Real(matrix_in[14]),
78 Ogre::Real(matrix_in[3]), Ogre::Real(matrix_in[7]), Ogre::Real(matrix_in[11]), Ogre::Real(matrix_in[15]));
84 matrix_out[0] = matrix_in[0][0];
85 matrix_out[1] = matrix_in[1][0];
86 matrix_out[2] = matrix_in[2][0];
87 matrix_out[3] = matrix_in[3][0];
89 matrix_out[4] = matrix_in[0][1];
90 matrix_out[5] = matrix_in[1][1];
91 matrix_out[6] = matrix_in[2][1];
92 matrix_out[7] = matrix_in[3][1];
94 matrix_out[8] = matrix_in[0][2];
95 matrix_out[9] = matrix_in[1][2];
96 matrix_out[10] = matrix_in[2][2];
97 matrix_out[11] = matrix_in[3][2];
99 matrix_out[12] = matrix_in[0][3];
100 matrix_out[13] = matrix_in[1][3];
101 matrix_out[14] = matrix_in[2][3];
102 matrix_out[15] = matrix_in[3][3];
135 Ogre::Vector3& retpt, Ogre::Vector3& retnormal,
int threadIndex)
142 gPt.m_x = dFloat(globalpt.x);
143 gPt.m_y = dFloat(globalpt.y);
144 gPt.m_z = dFloat(globalpt.z);
149 retpt.x = Ogre::Real(fretPt.m_x);
150 retpt.y = Ogre::Real(fretPt.m_y);
151 retpt.z = Ogre::Real(fretPt.m_z);
153 retnormal.x = Ogre::Real(fretNorm.m_x);
154 retnormal.y = Ogre::Real(fretNorm.m_y);
155 retnormal.z = Ogre::Real(fretNorm.m_z);
165 Ogre::Vector3& retPosA, Ogre::Vector3& retPosB, Ogre::Vector3& retNorm,
int threadIndex)
177 retPosA.x = Ogre::Real(fretPosA.m_x);
178 retPosA.y = Ogre::Real(fretPosA.m_y);
179 retPosA.z = Ogre::Real(fretPosA.m_z);
181 retPosB.x = Ogre::Real(fretPosB.m_x);
182 retPosB.y = Ogre::Real(fretPosB.m_y);
183 retPosB.z = Ogre::Real(fretPosB.m_z);
185 retNorm.x = Ogre::Real(fretNorm.m_x);
186 retNorm.y = Ogre::Real(fretNorm.m_y);
187 retNorm.z = Ogre::Real(fretNorm.m_z);
262 MovableText::MovableText(
const String &name,
const String &caption,
const String &fontName, Real charHeight,
const ColourValue &color)
267 , mFontName(fontName)
268 , mCharHeight(charHeight)
270 , mType(
"MovableText")
271 , mTimeUntilNextToggle(0)
273 , mUpdateColors(true)
275 , mHorizontalAlignment(H_LEFT)
276 , mVerticalAlignment(V_BELOW)
277 , mGlobalTranslation(0.0)
278 , mLocalTranslation(0.0)
281 throw Exception(Exception::ERR_INVALIDPARAMS,
"Trying to create MovableText without name",
"MovableText::MovableText");
284 throw Exception(Exception::ERR_INVALIDPARAMS,
"Trying to create MovableText without caption",
"MovableText::MovableText");
418 unsigned int vertexCount =
static_cast<unsigned int>(
mCaption.size() * 6);
438 mRenderOp.vertexData->vertexCount = vertexCount;
439 mRenderOp.operationType = Ogre::RenderOperation::OT_TRIANGLE_LIST;
442 VertexDeclaration *decl =
mRenderOp.vertexData->vertexDeclaration;
443 VertexBufferBinding *bind =
mRenderOp.vertexData->vertexBufferBinding;
447 if (!decl->findElementBySemantic(Ogre::VES_POSITION))
448 decl->addElement(
POS_TEX_BINDING, offset, Ogre::VET_FLOAT3, Ogre::VES_POSITION);
450 offset += VertexElement::getTypeSize(Ogre::VET_FLOAT3);
452 if (!decl->findElementBySemantic(Ogre::VES_TEXTURE_COORDINATES))
453 decl->addElement(
POS_TEX_BINDING, offset, Ogre::VET_FLOAT2, Ogre::VES_TEXTURE_COORDINATES, 0);
455 offset += VertexElement::getTypeSize(Ogre::VET_FLOAT2);
457 HardwareVertexBufferSharedPtr ptbuf = HardwareBufferManager::getSingleton().createVertexBuffer(decl->getVertexSize(
POS_TEX_BINDING),
459 HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY);
463 if (!decl->findElementBySemantic(VES_DIFFUSE))
466 HardwareVertexBufferSharedPtr cbuf = HardwareBufferManager::getSingleton().createVertexBuffer(decl->getVertexSize(
COLOUR_BINDING),
468 HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY);
472 float *pPCBuff =
static_cast<float*
>(ptbuf->lock(HardwareBuffer::HBL_DISCARD));
474 float largestWidth = 0;
475 float left = 0 * 2.0 - 0.1;
476 float top = -((0 * 2.0) - 0.1);
484 Ogre::Vector3 min, max, currPos;
485 Ogre::Real maxSquaredRadius;
488#define GetMax(x,y) x>y ? x : y
491 String::iterator i, iend;
496 Real verticalOffset = 0;
506 verticalOffset = 0.0f;
510 top += verticalOffset;
511 for (i =
mCaption.begin(); i != iend; ++i)
514 top += verticalOffset * 2.0f;
517 for (i =
mCaption.begin(); i != iend; ++i)
522 for (String::iterator j = i; j != iend && *j !=
'\n'; j++)
534 left = 0 * 2.0f - 0.1f;
549 Real horiz_height =
mpFont->getGlyphAspectRatio(*i);
551 Ogre::Font::UVRect utmp;
552 utmp =
mpFont->getGlyphTexCoords(*i);
566 *pPCBuff++ = left - (len / 2);
574 currPos = Ogre::Vector3(left, top, -0.1);
576 currPos = Ogre::Vector3(left - (len / 2), top, -0.1);
580 maxSquaredRadius = currPos.squaredLength();
585 min.makeFloor(currPos);
586 max.makeCeil(currPos);
587 maxSquaredRadius = GetMax(maxSquaredRadius, currPos.squaredLength());
596 *pPCBuff++ = left - (len / 2);
604 currPos = Ogre::Vector3(left, top, -0.1f);
606 currPos = Ogre::Vector3(left - (len / 2.0f), top, -0.1f);
607 min.makeFloor(currPos);
608 max.makeCeil(currPos);
609 maxSquaredRadius = GetMax(maxSquaredRadius, currPos.squaredLength());
618 *pPCBuff++ = left - (len / 2.0f);
627 currPos = Ogre::Vector3(left, top, -0.1f);
629 currPos = Ogre::Vector3(left - (len / 2.0f), top, -0.1f);
630 min.makeFloor(currPos);
631 max.makeCeil(currPos);
632 maxSquaredRadius = GetMax(maxSquaredRadius, currPos.squaredLength());
641 *pPCBuff++ = left - (len / 2.0f);
647 currPos = Ogre::Vector3(left, top, -0.1f);
648 min.makeFloor(currPos);
649 max.makeCeil(currPos);
650 maxSquaredRadius = GetMax(maxSquaredRadius, currPos.squaredLength());
659 *pPCBuff++ = left - (len / 2.0f);
665 currPos = Ogre::Vector3(left, top, -0.1f);
666 min.makeFloor(currPos);
667 max.makeCeil(currPos);
668 maxSquaredRadius = GetMax(maxSquaredRadius, currPos.squaredLength());
676 *pPCBuff++ = left - (len / 2.0f);
683 currPos = Ogre::Vector3(left, top, -0.1f);
684 min.makeFloor(currPos);
685 max.makeCeil(currPos);
686 maxSquaredRadius = GetMax(maxSquaredRadius, currPos.squaredLength());
691 float currentWidth = (left + 0.1f) / 2.0f;
692 if (currentWidth > largestWidth)
693 largestWidth = currentWidth;
700 mAABB = Ogre::AxisAlignedBox(min, max);
701 mRadius = Ogre::Math::Sqrt(maxSquaredRadius);
MovableText(const Ogre::String &name, const Ogre::String &caption, const Ogre::String &fontName, Ogre::Real charHeight, const Ogre::ColourValue &color=Ogre::ColourValue::White)
void visitRenderables(Ogre::Renderable::Visitor *visitor, bool debugRenderables=false)
void setTextAlignment(const HorizontalAlignment &horizontalAlignment, const VerticalAlignment &verticalAlignment)