This commit is contained in:
hiker 2016-10-27 11:13:19 +11:00
commit 94346ae64d
4 changed files with 23 additions and 21 deletions

@ -50,14 +50,28 @@ STKTextBillboard::STKTextBillboard(core::stringw text, FontWithFace* font,
void STKTextBillboard::updateAbsolutePosition() void STKTextBillboard::updateAbsolutePosition()
{ {
// Make billboard always face the camera
scene::ICameraSceneNode* curr_cam =
irr_driver->getSceneManager()->getActiveCamera();
if (!curr_cam) return;
core::quaternion q(curr_cam->getViewMatrix());
q.W = -q.W;
if (Parent) if (Parent)
{ {
// Override to not use the parent's rotation // Override to not use the parent's rotation
AbsoluteTransformation = getRelativeTransformation(); core::vector3df wc = RelativeTranslation;
AbsoluteTransformation.setTranslation(AbsoluteTransformation.getTranslation() + Parent->getAbsolutePosition()); Parent->getAbsoluteTransformation().transformVect(wc);
AbsoluteTransformation.setTranslation(wc);
q.getMatrix(AbsoluteTransformation, wc);
} }
else else
AbsoluteTransformation = getRelativeTransformation(); {
q.getMatrix(AbsoluteTransformation, RelativeTranslation);
}
core::matrix4 m;
m.setScale(RelativeScale);
AbsoluteTransformation *= m;
} }
scene::IMesh* STKTextBillboard::getTextMesh(core::stringw text, FontWithFace* font) scene::IMesh* STKTextBillboard::getTextMesh(core::stringw text, FontWithFace* font)
@ -171,18 +185,6 @@ scene::IMesh* STKTextBillboard::getTextMesh(core::stringw text, FontWithFace* fo
return Mesh; return Mesh;
} }
void STKTextBillboard::updateNoGL()
{
scene::ICameraSceneNode* curr_cam = irr_driver->getSceneManager()->getActiveCamera();
core::vector3df cam_pos = curr_cam->getPosition();
core::vector3df text_pos = this->getAbsolutePosition();
float angle = atan2(text_pos.X - cam_pos.X, text_pos.Z - cam_pos.Z);
this->setRotation(core::vector3df(0.0f, angle * 180.0f / M_PI, 0.0f));
updateAbsolutePosition();
STKMeshSceneNode::updateNoGL();
}
void STKTextBillboard::collectChar(video::ITexture* texture, void STKTextBillboard::collectChar(video::ITexture* texture,
const core::rect<float>& destRect, const core::rect<float>& destRect,
const core::rect<s32>& sourceRect, const core::rect<s32>& sourceRect,

@ -74,8 +74,6 @@ public:
const irr::core::vector3df& position, const irr::core::vector3df& position,
const irr::core::vector3df& size); const irr::core::vector3df& size);
virtual void updateNoGL() OVERRIDE;
virtual scene::ESCENE_NODE_TYPE getType() const OVERRIDE virtual scene::ESCENE_NODE_TYPE getType() const OVERRIDE
{ {
return scene::ESNT_TEXT; return scene::ESNT_TEXT;

@ -105,6 +105,7 @@ namespace Scripting
core::vector3df(1.5f, 1.5f, 1.5f)); core::vector3df(1.5f, 1.5f, 1.5f));
World::getWorld()->getTrack()->addNode(tb); World::getWorld()->getTrack()->addNode(tb);
tb->drop();
} }
else else
{ {

@ -453,7 +453,8 @@ void RaceGUI::drawEnergyMeter(int x, int y, const AbstractKart *kart,
(int)offset.Y-gauge_height, (int)offset.Y-gauge_height,
(int)offset.X + gauge_width, (int)offset.X + gauge_width,
(int)offset.Y) /* dest rect */, (int)offset.Y) /* dest rect */,
core::rect<s32>(0, 0, 256, 256) /* source rect */, core::rect<s32>(core::position2d<s32>(0,0),
m_gauge_empty->getSize()) /* source rect */,
NULL /* clip rect */, NULL /* colors */, NULL /* clip rect */, NULL /* colors */,
true /* alpha */); true /* alpha */);