Make billboard text display properly when viewing in any direction
This commit is contained in:
parent
e31a7ca4a8
commit
a38c8f0c19
@ -54,7 +54,9 @@ void STKTextBillboard::updateAbsolutePosition()
|
|||||||
{
|
{
|
||||||
// Override to not use the parent's rotation
|
// Override to not use the parent's rotation
|
||||||
AbsoluteTransformation = getRelativeTransformation();
|
AbsoluteTransformation = getRelativeTransformation();
|
||||||
AbsoluteTransformation.setTranslation(AbsoluteTransformation.getTranslation() + Parent->getAbsolutePosition());
|
core::vector3df wc = RelativeTranslation;
|
||||||
|
Parent->getAbsoluteTransformation().transformVect(wc);
|
||||||
|
AbsoluteTransformation.setTranslation(wc);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
AbsoluteTransformation = getRelativeTransformation();
|
AbsoluteTransformation = getRelativeTransformation();
|
||||||
@ -173,11 +175,15 @@ scene::IMesh* STKTextBillboard::getTextMesh(core::stringw text, FontWithFace* fo
|
|||||||
|
|
||||||
void STKTextBillboard::updateNoGL()
|
void STKTextBillboard::updateNoGL()
|
||||||
{
|
{
|
||||||
scene::ICameraSceneNode* curr_cam = irr_driver->getSceneManager()->getActiveCamera();
|
scene::ICameraSceneNode* curr_cam =irr_driver->getSceneManager()->getActiveCamera();
|
||||||
core::vector3df cam_pos = curr_cam->getPosition();
|
btMatrix3x3 m;
|
||||||
core::vector3df text_pos = this->getAbsolutePosition();
|
m.setFromOpenGLSubMatrix(curr_cam->getViewMatrix().pointer());
|
||||||
float angle = atan2(text_pos.X - cam_pos.X, text_pos.Z - cam_pos.Z);
|
btQuaternion q;
|
||||||
this->setRotation(core::vector3df(0.0f, angle * 180.0f / M_PI, 0.0f));
|
m.getRotation(q);
|
||||||
|
q.setW(-q.getW());
|
||||||
|
Vec3 hpr;
|
||||||
|
hpr.setHPR(q);
|
||||||
|
this->setRotation(hpr.toIrrHPR());
|
||||||
updateAbsolutePosition();
|
updateAbsolutePosition();
|
||||||
|
|
||||||
STKMeshSceneNode::updateNoGL();
|
STKMeshSceneNode::updateNoGL();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user